@@ -247,10 +247,12 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec):
247
247
traits .Tuple (traits .Float (), # Gaussian/MultiLabel (sigma, alpha)
248
248
traits .Float ())
249
249
)
250
- transforms = InputMultiPath (
251
- File (exists = True ), argstr = '%s' , desc = 'transform files: will be applied in reverse order. '
252
- 'For example, the last specified transform will be applied first; if this input is not '
253
- 'set, the identity transform is used' )
250
+ transforms = traits .Either (InputMultiPath (File (exists = True ), desc = 'transform files: will be '
251
+ 'applied in reverse order. For example, the last '
252
+ 'specified transform will be applied first.' ),
253
+ traits .Enum ('identity' , desc = 'use the identity transform' ),
254
+ mandatory = True ,
255
+ argstr = '%s' )
254
256
invert_transform_flags = InputMultiPath (traits .Bool ())
255
257
default_value = traits .Float (0.0 , argstr = '--default-value %g' , usedefault = True )
256
258
print_out_composite_warp_file = traits .Bool (False , requires = ["output_image" ],
@@ -294,12 +296,24 @@ class ApplyTransforms(ANTSCommand):
294
296
>>> at1.inputs.default_value = 0
295
297
>>> at1.inputs.transforms = ['ants_Warp.nii.gz', 'trans.mat']
296
298
>>> at1.inputs.invert_transform_flags = [False, False]
297
- >>> at1.cmdline # doctest: +IGNORE_UNICODE
299
+ >>> at1.cmdline
298
300
'antsApplyTransforms --default-value 0 --dimensionality 3 --input moving1.nii --interpolation BSpline[ 5 ] \
299
301
--output deformed_moving1.nii --reference-image fixed1.nii --transform [ ants_Warp.nii.gz, 0 ] \
300
302
--transform [ trans.mat, 0 ]'
301
303
302
-
304
+ >>> atid = ApplyTransforms()
305
+ >>> atid.inputs.dimension = 3
306
+ >>> atid.inputs.input_image = 'moving1.nii'
307
+ >>> atid.inputs.reference_image = 'fixed1.nii'
308
+ >>> atid.inputs.output_image = 'deformed_moving1.nii'
309
+ >>> atid.inputs.interpolation = 'BSpline'
310
+ >>> atid.inputs.interpolation_parameters = (5,)
311
+ >>> atid.inputs.default_value = 0
312
+ >>> atid.inputs.transforms = 'identity'
313
+ >>> atid.cmdline
314
+ 'antsApplyTransforms --default-value 0 --dimensionality 3 --input moving1.nii \
315
+ --interpolation BSpline[ 5 ] --output deformed_moving1.nii --reference-image fixed1.nii \
316
+ --transform identity'
303
317
"""
304
318
_cmd = 'antsApplyTransforms'
305
319
input_spec = ApplyTransformsInputSpec
@@ -315,6 +329,9 @@ def _gen_filename(self, name):
315
329
return None
316
330
317
331
def _get_transform_filenames (self ):
332
+ ''' the input transforms may be a list of files or the keyword 'identity' '''
333
+ if self .inputs .transforms == 'identity' :
334
+ return "--transform identity"
318
335
retval = []
319
336
for ii in range (len (self .inputs .transforms )):
320
337
if isdefined (self .inputs .invert_transform_flags ):
0 commit comments