@@ -64,7 +64,8 @@ class WarpTimeSeriesImageMultiTransform(ANTSCommand):
64
64
>>> wtsimt.inputs.reference_image = 'ants_deformed.nii.gz'
65
65
>>> wtsimt.inputs.transformation_series = ['ants_Warp.nii.gz','ants_Affine.txt']
66
66
>>> wtsimt.cmdline
67
- 'WarpTimeSeriesImageMultiTransform 4 resting.nii resting_wtsimt.nii -R ants_deformed.nii.gz ants_Warp.nii.gz ants_Affine.txt'
67
+ 'WarpTimeSeriesImageMultiTransform 4 resting.nii resting_wtsimt.nii -R ants_deformed.nii.gz ants_Warp.nii.gz \
68
+ ants_Affine.txt'
68
69
69
70
"""
70
71
@@ -99,7 +100,7 @@ def _list_outputs(self):
99
100
ext )))
100
101
return outputs
101
102
102
- def _run_interface (self , runtime ):
103
+ def _run_interface (self , runtime , correct_return_codes = [ 0 ] ):
103
104
runtime = super (WarpTimeSeriesImageMultiTransform , self )._run_interface (runtime , correct_return_codes = [0 , 1 ])
104
105
if "100 % complete" not in runtime .stdout :
105
106
self .raise_exception (runtime )
@@ -113,7 +114,7 @@ class WarpImageMultiTransformInputSpec(ANTSCommandInputSpec):
113
114
desc = ('image to apply transformation to (generally a '
114
115
'coregistered functional)' ), position = 2 )
115
116
output_image = File (genfile = True , hash_files = False , argstr = '%s' ,
116
- desc = ( 'name of the output warped image' ) , position = 3 , xor = ['out_postfix' ])
117
+ desc = 'name of the output warped image' , position = 3 , xor = ['out_postfix' ])
117
118
out_postfix = File ("_wimt" , usedefault = True , hash_files = False ,
118
119
desc = ('Postfix that is prepended to all output '
119
120
'files (default = _wimt)' ), xor = ['output_image' ])
@@ -159,15 +160,18 @@ class WarpImageMultiTransform(ANTSCommand):
159
160
>>> wimt.inputs.reference_image = 'ants_deformed.nii.gz'
160
161
>>> wimt.inputs.transformation_series = ['ants_Warp.nii.gz','ants_Affine.txt']
161
162
>>> wimt.cmdline
162
- 'WarpImageMultiTransform 3 structural.nii structural_wimt.nii -R ants_deformed.nii.gz ants_Warp.nii.gz ants_Affine.txt'
163
+ 'WarpImageMultiTransform 3 structural.nii structural_wimt.nii -R ants_deformed.nii.gz ants_Warp.nii.gz \
164
+ ants_Affine.txt'
163
165
164
166
>>> wimt = WarpImageMultiTransform()
165
167
>>> wimt.inputs.input_image = 'diffusion_weighted.nii'
166
168
>>> wimt.inputs.reference_image = 'functional.nii'
167
- >>> wimt.inputs.transformation_series = ['func2anat_coreg_Affine.txt','func2anat_InverseWarp.nii.gz','dwi2anat_Warp.nii.gz','dwi2anat_coreg_Affine.txt']
169
+ >>> wimt.inputs.transformation_series = ['func2anat_coreg_Affine.txt','func2anat_InverseWarp.nii.gz', \
170
+ 'dwi2anat_Warp.nii.gz','dwi2anat_coreg_Affine.txt']
168
171
>>> wimt.inputs.invert_affine = [1]
169
172
>>> wimt.cmdline
170
- 'WarpImageMultiTransform 3 diffusion_weighted.nii diffusion_weighted_wimt.nii -R functional.nii -i func2anat_coreg_Affine.txt func2anat_InverseWarp.nii.gz dwi2anat_Warp.nii.gz dwi2anat_coreg_Affine.txt'
173
+ 'WarpImageMultiTransform 3 diffusion_weighted.nii diffusion_weighted_wimt.nii -R functional.nii \
174
+ -i func2anat_coreg_Affine.txt func2anat_InverseWarp.nii.gz dwi2anat_Warp.nii.gz dwi2anat_coreg_Affine.txt'
171
175
172
176
"""
173
177
@@ -221,9 +225,8 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec):
221
225
desc = ('image to apply transformation to (generally a '
222
226
'coregistered functional)' ),
223
227
exists = True )
224
- output_image = traits .Str (argstr = '--output %s' ,
225
- desc = ('output file name' ), genfile = True ,
226
- hash_files = False )
228
+ output_image = traits .Str (argstr = '--output %s' , desc = 'output file name' ,
229
+ genfile = True , hash_files = False )
227
230
out_postfix = traits .Str ("_trans" , usedefault = True ,
228
231
desc = ('Postfix that is appended to all output '
229
232
'files (default = _trans)' ))
@@ -245,12 +248,13 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec):
245
248
# interpolation_alpha = traits.Float(requires=['interpolation_sigma'])
246
249
# bspline_order = traits.Int(3, requires=['interpolation'])
247
250
transforms = InputMultiPath (
248
- File (exists = True ), argstr = '%s' , mandatory = True , desc = ( '' ) )
251
+ File (exists = True ), argstr = '%s' , mandatory = True , desc = 'transform files' )
249
252
invert_transform_flags = InputMultiPath (traits .Bool ())
250
253
default_value = traits .Float (
251
254
0.0 , argstr = '--default-value %g' , usedefault = True )
252
- print_out_composite_warp_file = traits .Enum (
253
- 0 , 1 , requires = ["output_image" ], desc = ('' )) # TODO: Change to boolean
255
+ # TODO: Change to boolean
256
+ print_out_composite_warp_file = traits .Enum (0 , 1 , requires = ["output_image" ],
257
+ desc = 'output a composite warp file instead of a transformed image' )
254
258
255
259
256
260
class ApplyTransformsOutputSpec (TraitedSpec ):
@@ -275,7 +279,8 @@ class ApplyTransforms(ANTSCommand):
275
279
>>> at.inputs.transforms = ['trans.mat', 'ants_Warp.nii.gz']
276
280
>>> at.inputs.invert_transform_flags = [False, False]
277
281
>>> at.cmdline
278
- 'antsApplyTransforms --default-value 0 --dimensionality 3 --input moving1.nii --interpolation Linear --output deformed_moving1.nii --reference-image fixed1.nii --transform [trans.mat,0] --transform [ants_Warp.nii.gz,0]'
282
+ 'antsApplyTransforms --default-value 0 --dimensionality 3 --input moving1.nii --interpolation Linear \
283
+ --output deformed_moving1.nii --reference-image fixed1.nii --transform [trans.mat,0] --transform [ants_Warp.nii.gz,0]'
279
284
280
285
281
286
"""
@@ -292,7 +297,7 @@ def _gen_filename(self, name):
292
297
return output
293
298
return None
294
299
295
- def _getTransformFileNames (self ):
300
+ def _get_transform_filenames (self ):
296
301
retval = []
297
302
for ii in range (len (self .inputs .transforms )):
298
303
if isdefined (self .inputs .invert_transform_flags ):
@@ -302,22 +307,23 @@ def _getTransformFileNames(self):
302
307
retval .append ("--transform [%s,%d]" %
303
308
(self .inputs .transforms [ii ], invert_code ))
304
309
else :
305
- raise Exception ("ERROR: The useInverse list must have the same number of entries as the transformsFileName list." )
310
+ raise Exception (("ERROR: The useInverse list must have the same number "
311
+ "of entries as the transformsFileName list." ))
306
312
else :
307
313
retval .append ("--transform %s" % self .inputs .transforms [ii ])
308
314
return " " .join (retval )
309
315
310
- def _getOutputWarpedFileName (self ):
316
+ def _get_output_warped_filename (self ):
311
317
if isdefined (self .inputs .print_out_composite_warp_file ):
312
318
return "--output [%s,%s]" % (self ._gen_filename ("output_image" ), self .inputs .print_out_composite_warp_file )
313
319
else :
314
320
return "--output %s" % (self ._gen_filename ("output_image" ))
315
321
316
322
def _format_arg (self , opt , spec , val ):
317
323
if opt == "output_image" :
318
- return self ._getOutputWarpedFileName ()
324
+ return self ._get_output_warped_filename ()
319
325
elif opt == "transforms" :
320
- return self ._getTransformFileNames ()
326
+ return self ._get_transform_filenames ()
321
327
elif opt == 'interpolation' :
322
328
# TODO: handle multilabel, gaussian, and bspline options
323
329
return '--interpolation %s' % self .inputs .interpolation
@@ -348,12 +354,12 @@ class ApplyTransformsToPointsInputSpec(ANTSCommandInputSpec):
348
354
"expecting." ),
349
355
exists = True )
350
356
output_file = traits .Str (argstr = '--output %s' ,
351
- desc = ( 'Name of the output CSV file' ) , name_source = ['input_file' ],
357
+ desc = 'Name of the output CSV file' , name_source = ['input_file' ],
352
358
hash_files = False , name_template = '%s_transformed.csv' )
353
359
transforms = traits .List (File (exists = True ), argstr = '%s' , mandatory = True ,
354
- desc = ( 'transforms that will be applied to the points' ) )
360
+ desc = 'transforms that will be applied to the points' )
355
361
invert_transform_flags = traits .List (traits .Bool (),
356
- desc = ( 'list indicating if a transform should be reversed' ) )
362
+ desc = 'list indicating if a transform should be reversed' )
357
363
358
364
359
365
class ApplyTransformsToPointsOutputSpec (TraitedSpec ):
@@ -374,15 +380,16 @@ class ApplyTransformsToPoints(ANTSCommand):
374
380
>>> at.inputs.transforms = ['trans.mat', 'ants_Warp.nii.gz']
375
381
>>> at.inputs.invert_transform_flags = [False, False]
376
382
>>> at.cmdline
377
- 'antsApplyTransformsToPoints --dimensionality 3 --input moving.csv --output moving_transformed.csv --transform [trans.mat,0] --transform [ants_Warp.nii.gz,0]'
383
+ 'antsApplyTransformsToPoints --dimensionality 3 --input moving.csv --output moving_transformed.csv \
384
+ --transform [trans.mat,0] --transform [ants_Warp.nii.gz,0]'
378
385
379
386
380
387
"""
381
388
_cmd = 'antsApplyTransformsToPoints'
382
389
input_spec = ApplyTransformsToPointsInputSpec
383
390
output_spec = ApplyTransformsToPointsOutputSpec
384
391
385
- def _getTransformFileNames (self ):
392
+ def _get_transform_filenames (self ):
386
393
retval = []
387
394
for ii in range (len (self .inputs .transforms )):
388
395
if isdefined (self .inputs .invert_transform_flags ):
@@ -392,12 +399,13 @@ def _getTransformFileNames(self):
392
399
retval .append ("--transform [%s,%d]" %
393
400
(self .inputs .transforms [ii ], invert_code ))
394
401
else :
395
- raise Exception ("ERROR: The useInverse list must have the same number of entries as the transformsFileName list." )
402
+ raise Exception (("ERROR: The useInverse list must have the same number "
403
+ "of entries as the transformsFileName list." ))
396
404
else :
397
405
retval .append ("--transform %s" % self .inputs .transforms [ii ])
398
406
return " " .join (retval )
399
407
400
408
def _format_arg (self , opt , spec , val ):
401
409
if opt == "transforms" :
402
- return self ._getTransformFileNames ()
410
+ return self ._get_transform_filenames ()
403
411
return super (ApplyTransformsToPoints , self )._format_arg (opt , spec , val )
0 commit comments