Skip to content

FIX: Reuse _gen_filename logic in ants.LaplacianThickness #2734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2018

Conversation

yarikoptic
Copy link
Member

Without this fix it

@effigies
Copy link
Member

Any chance of a test?

@yarikoptic
Copy link
Member Author

oh, there are real tests for the interfaces? ;) what would be the best example to follow?

@oesteban
Copy link
Contributor

oesteban commented Oct 12, 2018

Can't we just use name_source for this?

 class LaplacianThicknessInputSpec(ANTSCommandInputSpec):
     input_wm = File(
         argstr='%s',
         mandatory=True,
         copyfile=True,
         desc='white matter segmentation image',
         position=1)
     input_gm = File(
         argstr='%s',
         mandatory=True,
         copyfile=True,
         desc='gray matter segmentation image',
         position=2)
     output_image = File(
         desc='name of output file',
         argstr='%s',
         position=3,
         name_source=['input_wm'],
         name_template='%s_thickness',
         keep_extension=True,
         hash_files=False)
     smooth_param = traits.Float(argstr='smoothparam=%d', desc='', position=4)
     prior_thickness = traits.Float(
         argstr='priorthickval=%d', desc='', position=5)
     dT = traits.Float(argstr='dT=%d', desc='', position=6)
     sulcus_prior = traits.Bool(argstr='use-sulcus-prior', desc='', position=7)
     opt_tolerance = traits.Float(
         argstr='optional-laplacian-tolerance=%d', desc='', position=8)
 
 
 class LaplacianThicknessOutputSpec(TraitedSpec):
     output_image = File(exists=True, desc='Cortical thickness')
 
 
 class LaplacianThickness(ANTSCommand):
     """Calculates the cortical thickness from an anatomical image
 
     Examples
     --------
 
     >>> from nipype.interfaces.ants import LaplacianThickness
     >>> cort_thick = LaplacianThickness()
     >>> cort_thick.inputs.input_wm = 'white_matter.nii.gz'
     >>> cort_thick.inputs.input_gm = 'gray_matter.nii.gz'
     >>> cort_thick.cmdline
     'LaplacianThickness white_matter.nii.gz gray_matter.nii.gz white_matter_thickness.nii.gz'

     >>> cort_thick.inputs.output_image = 'output_thickness.nii.gz'
     >>> cort_thick.cmdline
     'LaplacianThickness white_matter.nii.gz gray_matter.nii.gz output_thickness.nii.gz'
 
     """
 
     _cmd = 'LaplacianThickness'
     input_spec = LaplacianThicknessInputSpec
     output_spec = LaplacianThicknessOutputSpec

(and both _gen_filename and _list_outputs definitions can go away). We would need to re-generate specs (make spec).

EDITED: added a doctest (hopefully to cover @effigies' request)

@effigies
Copy link
Member

👍 to @oesteban's suggestion, including doctest. Consistency with the post-run outputs should already be tested in a more generic context (hopefully with a cheap interface).

@yarikoptic
Copy link
Member Author

Guys, I am not sure if I am to do anything, or may be this could get merged and then altogether or instead be replaced with @oesteban 's version?

@oesteban
Copy link
Contributor

I'm happy with whatever you prefer. Or if you want me to push to this branch. I just would like to see that we abandon gen_filename and genfile at some point in time 👍

@effigies effigies changed the title BF: reuse _gen_filename logic for output_name if not defined FIX: Reuse _gen_filename logic in ants.LaplacianThickness Oct 23, 2018
@effigies effigies added this to the 1.1.4 milestone Oct 23, 2018
@effigies
Copy link
Member

@oesteban We can move to name_source in a separate PR.

@effigies effigies merged commit b1d5de3 into nipy:master Oct 23, 2018
oesteban added a commit that referenced this pull request Oct 24, 2018
@yarikoptic yarikoptic deleted the bf-ants-laplacianthickness branch January 11, 2019 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

genfile'ed output name "is not remembered" to be used later (in self.aggregate_outputs)?
3 participants