Skip to content

Commit acf3a69

Browse files
committed
[ENH] ants.ApplyTransform - Accept 'identity' keyword
Closes nipy#2126
1 parent 66411f4 commit acf3a69

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

nipype/interfaces/ants/resampling.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,15 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec):
243243
'Gaussian',
244244
'BSpline',
245245
argstr='%s', usedefault=True)
246-
interpolation_parameters = traits.Either(traits.Tuple(traits.Int()), # BSpline (order)
247-
traits.Tuple(traits.Float(), # Gaussian/MultiLabel (sigma, alpha)
248-
traits.Float())
249-
)
250-
transforms = InputMultiPath(File(exists=True), argstr='%s', mandatory=True,
251-
desc='transform files: will be applied in reverse order. For '
252-
'example, the last specified transform will be applied first.')
246+
interpolation_parameters = traits.Either(
247+
traits.Tuple(traits.Int()), # BSpline (order)
248+
traits.Tuple(traits.Float(), # Gaussian/MultiLabel (sigma, alpha)
249+
traits.Float())
250+
)
251+
transforms = traits.Either(
252+
InputMultiPath(File(exists=True)), 'identity', argstr='%s', mandatory=True,
253+
desc='transform files: will be applied in reverse order. For '
254+
'example, the last specified transform will be applied first.')
253255
invert_transform_flags = InputMultiPath(traits.Bool())
254256
default_value = traits.Float(0.0, argstr='--default-value %g', usedefault=True)
255257
print_out_composite_warp_file = traits.Bool(False, requires=["output_image"],
@@ -269,6 +271,15 @@ class ApplyTransforms(ANTSCommand):
269271
--------
270272
271273
>>> from nipype.interfaces.ants import ApplyTransforms
274+
>>> at = ApplyTransforms()
275+
>>> at.inputs.input_image = 'moving1.nii'
276+
>>> at.inputs.reference_image = 'fixed1.nii'
277+
>>> at.inputs.transforms = 'identity'
278+
>>> at.cmdline # doctest: +ALLOW_UNICODE
279+
'antsApplyTransforms --default-value 0 --input moving1.nii \
280+
--interpolation Linear --output moving_trans.nii \
281+
--reference-image fixed1.nii -t identity'
282+
272283
>>> at = ApplyTransforms()
273284
>>> at.inputs.dimension = 3
274285
>>> at.inputs.input_image = 'moving1.nii'
@@ -338,6 +349,8 @@ def _format_arg(self, opt, spec, val):
338349
if opt == "output_image":
339350
return self._get_output_warped_filename()
340351
elif opt == "transforms":
352+
if val == 'identity':
353+
return '-t identity'
341354
return self._get_transform_filenames()
342355
elif opt == 'interpolation':
343356
if self.inputs.interpolation in ['BSpline', 'MultiLabel', 'Gaussian'] and \

0 commit comments

Comments
 (0)