Skip to content

Commit ee81bc4

Browse files
committed
ENH: Add multiple output option for wrapped Ants DenoiseImage
1 parent f5c1229 commit ee81bc4

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

nipype/interfaces/ants/segmentation.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -803,9 +803,8 @@ class DenoiseImageInputSpec(ANTSCommandInputSpec):
803803
'as a specified-dimensional image. If not '
804804
'specified, the program tries to infer the '
805805
'dimensionality from the input image.')
806-
input_image = File(exists=True, argstr="-i %s",
807-
mandatory=True, desc='A scalar image is expected '
808-
'as input for noise correction.')
806+
input_image = File(exists=True, argstr="-i %s", mandatory=True,
807+
desc='A scalar image is expected as input for noise correction.')
809808
noise_model = traits.Enum('Gaussian', 'Rician', argstr='-n %s', usedefault=True,
810809
desc=('Employ a Rician or Gaussian noise model.'))
811810
shrink_factor = traits.Int(default_value=1, usedefault=True, argstr='-s %s',
@@ -814,7 +813,7 @@ class DenoiseImageInputSpec(ANTSCommandInputSpec):
814813
'the input image can be resampled. The shrink '
815814
'factor, specified as a single integer, describes '
816815
'this resampling. Shrink factor = 1 is the default.'))
817-
output_image = traits.List(traits.Str(), argstr="-o %s...",
816+
output_image = traits.List(traits.Str(), argstr="",
818817
desc='The output consists of the noise corrected '
819818
'version of the input image. Optionally, one '
820819
'can also output the estimated noise image.')
@@ -826,6 +825,7 @@ class DenoiseImageInputSpec(ANTSCommandInputSpec):
826825

827826
class DenoiseImageOutputSpec(TraitedSpec):
828827
output_corrected_image = File(exists=True)
828+
output_noise_image = File(exists=True)
829829
# TODO: optional outputs - output_noise_image
830830

831831

@@ -839,7 +839,18 @@ class DenoiseImage(ANTSCommand):
839839
output_spec = DenoiseImageOutputSpec
840840
_cmd = 'DenoiseImage'
841841

842+
def _format_arg(self, opt, spec, val):
843+
if opt == 'output_image':
844+
if len(val) == 1:
845+
retval = '-o {0}'.format(val[0])
846+
elif len(val) == 2:
847+
retval = '-o [{0},{1}]'.format(val[0], val[1])
848+
return retval
849+
return super(ANTSCommand, self)._format_arg(opt, spec, val)
850+
842851
def _list_outputs(self):
843852
outputs = self._outputs().get()
844-
outputs['output_corrected_image'] = os.path.abspath(self.inputs.output_image)
845-
return outputs
853+
outputs['output_corrected_image'] = os.path.abspath(self.inputs.output_image[0][0])
854+
if len(self.inputs.output_image) == 2:
855+
outputs['output_noise_image'] = os.path.abspath(self.inputs.output_image[0][1])
856+
return outputs

0 commit comments

Comments
 (0)