From 45afd838b1ee6c26d75f5481d11767f3901badc3 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Tue, 23 Oct 2018 17:27:59 -0700 Subject: [PATCH 1/2] [ENH] Move ``nipype.interfaces.ants.LaplacianThickness`` to use ``name_source`` Ref. #2734 --- nipype/interfaces/ants/segmentation.py | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/nipype/interfaces/ants/segmentation.py b/nipype/interfaces/ants/segmentation.py index b0ce64764c..04d212ec0f 100644 --- a/nipype/interfaces/ants/segmentation.py +++ b/nipype/interfaces/ants/segmentation.py @@ -203,7 +203,9 @@ class LaplacianThicknessInputSpec(ANTSCommandInputSpec): desc='name of output file', argstr='%s', position=3, - genfile=True, + 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( @@ -228,6 +230,9 @@ class LaplacianThickness(ANTSCommand): >>> 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' @@ -238,22 +243,6 @@ class LaplacianThickness(ANTSCommand): input_spec = LaplacianThicknessInputSpec output_spec = LaplacianThicknessOutputSpec - def _gen_filename(self, name): - if name == 'output_image': - output = self.inputs.output_image - if not isdefined(output): - _, name, ext = split_filename(self.inputs.input_wm) - output = name + '_thickness' + ext - return output - return None - - def _list_outputs(self): - outputs = self._outputs().get() - if not outputs.get('output_image', None) \ - or not isdefined(outputs['output_image']): - outputs['output_image'] = self._gen_filename('output_image') - return outputs - class N4BiasFieldCorrectionInputSpec(ANTSCommandInputSpec): dimension = traits.Enum( From 8502192cb94fb0cc5e2dde6201bea2bb8b64e1e9 Mon Sep 17 00:00:00 2001 From: Oscar Esteban Date: Tue, 23 Oct 2018 21:56:14 -0700 Subject: [PATCH 2/2] update specs --- nipype/interfaces/ants/tests/test_auto_LaplacianThickness.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nipype/interfaces/ants/tests/test_auto_LaplacianThickness.py b/nipype/interfaces/ants/tests/test_auto_LaplacianThickness.py index 8f9a13d832..f45efecfbf 100644 --- a/nipype/interfaces/ants/tests/test_auto_LaplacianThickness.py +++ b/nipype/interfaces/ants/tests/test_auto_LaplacianThickness.py @@ -36,8 +36,10 @@ def test_LaplacianThickness_inputs(): ), output_image=dict( argstr='%s', - genfile=True, hash_files=False, + keep_extension=True, + name_source=['input_wm'], + name_template='%s_thickness', position=3, ), prior_thickness=dict(