@@ -64,7 +64,8 @@ class WarpTimeSeriesImageMultiTransform(ANTSCommand):
6464 >>> wtsimt.inputs.reference_image = 'ants_deformed.nii.gz'
6565 >>> wtsimt.inputs.transformation_series = ['ants_Warp.nii.gz','ants_Affine.txt']
6666 >>> 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'
6869
6970 """
7071
@@ -99,7 +100,7 @@ def _list_outputs(self):
99100 ext )))
100101 return outputs
101102
102- def _run_interface (self , runtime ):
103+ def _run_interface (self , runtime , correct_return_codes = [ 0 ] ):
103104 runtime = super (WarpTimeSeriesImageMultiTransform , self )._run_interface (runtime , correct_return_codes = [0 , 1 ])
104105 if "100 % complete" not in runtime .stdout :
105106 self .raise_exception (runtime )
@@ -113,7 +114,7 @@ class WarpImageMultiTransformInputSpec(ANTSCommandInputSpec):
113114 desc = ('image to apply transformation to (generally a '
114115 'coregistered functional)' ), position = 2 )
115116 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' ])
117118 out_postfix = File ("_wimt" , usedefault = True , hash_files = False ,
118119 desc = ('Postfix that is prepended to all output '
119120 'files (default = _wimt)' ), xor = ['output_image' ])
@@ -159,15 +160,18 @@ class WarpImageMultiTransform(ANTSCommand):
159160 >>> wimt.inputs.reference_image = 'ants_deformed.nii.gz'
160161 >>> wimt.inputs.transformation_series = ['ants_Warp.nii.gz','ants_Affine.txt']
161162 >>> 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'
163165
164166 >>> wimt = WarpImageMultiTransform()
165167 >>> wimt.inputs.input_image = 'diffusion_weighted.nii'
166168 >>> 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']
168171 >>> wimt.inputs.invert_affine = [1]
169172 >>> 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'
171175
172176 """
173177
@@ -221,9 +225,8 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec):
221225 desc = ('image to apply transformation to (generally a '
222226 'coregistered functional)' ),
223227 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 )
227230 out_postfix = traits .Str ("_trans" , usedefault = True ,
228231 desc = ('Postfix that is appended to all output '
229232 'files (default = _trans)' ))
@@ -245,12 +248,13 @@ class ApplyTransformsInputSpec(ANTSCommandInputSpec):
245248 # interpolation_alpha = traits.Float(requires=['interpolation_sigma'])
246249 # bspline_order = traits.Int(3, requires=['interpolation'])
247250 transforms = InputMultiPath (
248- File (exists = True ), argstr = '%s' , mandatory = True , desc = ( '' ) )
251+ File (exists = True ), argstr = '%s' , mandatory = True , desc = 'transform files' )
249252 invert_transform_flags = InputMultiPath (traits .Bool ())
250253 default_value = traits .Float (
251254 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' )
254258
255259
256260class ApplyTransformsOutputSpec (TraitedSpec ):
@@ -275,7 +279,8 @@ class ApplyTransforms(ANTSCommand):
275279 >>> at.inputs.transforms = ['trans.mat', 'ants_Warp.nii.gz']
276280 >>> at.inputs.invert_transform_flags = [False, False]
277281 >>> 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]'
279284
280285
281286 """
@@ -292,7 +297,7 @@ def _gen_filename(self, name):
292297 return output
293298 return None
294299
295- def _getTransformFileNames (self ):
300+ def _get_transform_filenames (self ):
296301 retval = []
297302 for ii in range (len (self .inputs .transforms )):
298303 if isdefined (self .inputs .invert_transform_flags ):
@@ -302,22 +307,23 @@ def _getTransformFileNames(self):
302307 retval .append ("--transform [%s,%d]" %
303308 (self .inputs .transforms [ii ], invert_code ))
304309 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." ))
306312 else :
307313 retval .append ("--transform %s" % self .inputs .transforms [ii ])
308314 return " " .join (retval )
309315
310- def _getOutputWarpedFileName (self ):
316+ def _get_output_warped_filename (self ):
311317 if isdefined (self .inputs .print_out_composite_warp_file ):
312318 return "--output [%s,%s]" % (self ._gen_filename ("output_image" ), self .inputs .print_out_composite_warp_file )
313319 else :
314320 return "--output %s" % (self ._gen_filename ("output_image" ))
315321
316322 def _format_arg (self , opt , spec , val ):
317323 if opt == "output_image" :
318- return self ._getOutputWarpedFileName ()
324+ return self ._get_output_warped_filename ()
319325 elif opt == "transforms" :
320- return self ._getTransformFileNames ()
326+ return self ._get_transform_filenames ()
321327 elif opt == 'interpolation' :
322328 # TODO: handle multilabel, gaussian, and bspline options
323329 return '--interpolation %s' % self .inputs .interpolation
@@ -348,12 +354,12 @@ class ApplyTransformsToPointsInputSpec(ANTSCommandInputSpec):
348354 "expecting." ),
349355 exists = True )
350356 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' ],
352358 hash_files = False , name_template = '%s_transformed.csv' )
353359 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' )
355361 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' )
357363
358364
359365class ApplyTransformsToPointsOutputSpec (TraitedSpec ):
@@ -374,15 +380,16 @@ class ApplyTransformsToPoints(ANTSCommand):
374380 >>> at.inputs.transforms = ['trans.mat', 'ants_Warp.nii.gz']
375381 >>> at.inputs.invert_transform_flags = [False, False]
376382 >>> 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]'
378385
379386
380387 """
381388 _cmd = 'antsApplyTransformsToPoints'
382389 input_spec = ApplyTransformsToPointsInputSpec
383390 output_spec = ApplyTransformsToPointsOutputSpec
384391
385- def _getTransformFileNames (self ):
392+ def _get_transform_filenames (self ):
386393 retval = []
387394 for ii in range (len (self .inputs .transforms )):
388395 if isdefined (self .inputs .invert_transform_flags ):
@@ -392,12 +399,13 @@ def _getTransformFileNames(self):
392399 retval .append ("--transform [%s,%d]" %
393400 (self .inputs .transforms [ii ], invert_code ))
394401 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." ))
396404 else :
397405 retval .append ("--transform %s" % self .inputs .transforms [ii ])
398406 return " " .join (retval )
399407
400408 def _format_arg (self , opt , spec , val ):
401409 if opt == "transforms" :
402- return self ._getTransformFileNames ()
410+ return self ._get_transform_filenames ()
403411 return super (ApplyTransformsToPoints , self )._format_arg (opt , spec , val )
0 commit comments