@@ -223,7 +223,7 @@ def _list_outputs(self):
223223
224224
225225class N4BiasFieldCorrectionInputSpec (ANTSCommandInputSpec ):
226- dimension = traits .Enum (3 , 2 , argstr = '--image-dimension %d' ,
226+ dimension = traits .Enum (3 , 2 , argstr = '-d %d' ,
227227 usedefault = True ,
228228 desc = 'image dimension (2 or 3)' )
229229 input_image = File (argstr = '--input-image %s' , mandatory = True ,
@@ -237,8 +237,7 @@ class N4BiasFieldCorrectionInputSpec(ANTSCommandInputSpec):
237237 bspline_fitting_distance = traits .Float (argstr = "--bspline-fitting %s" )
238238 bspline_order = traits .Int (requires = ['bspline_fitting_distance' ])
239239 shrink_factor = traits .Int (argstr = "--shrink-factor %d" )
240- n_iterations = traits .List (traits .Int (), argstr = "--convergence %s" ,
241- requires = ['convergence_threshold' ])
240+ n_iterations = traits .List (traits .Int (), argstr = "--convergence %s" )
242241 convergence_threshold = traits .Float (requires = ['n_iterations' ])
243242 save_bias = traits .Bool (False , mandatory = True , usedefault = True ,
244243 desc = ('True if the estimated bias should be saved'
@@ -277,26 +276,33 @@ class N4BiasFieldCorrection(ANTSCommand):
277276 >>> n4.inputs.bspline_fitting_distance = 300
278277 >>> n4.inputs.shrink_factor = 3
279278 >>> n4.inputs.n_iterations = [50,50,30,20]
280- >>> n4.inputs.convergence_threshold = 1e-6
281279 >>> n4.cmdline
282280 'N4BiasFieldCorrection --bspline-fitting [ 300 ] \
283- --image-dimension 3 --input-image structural.nii \
284- --convergence [ 50x50x30x20, 1e-06 ] --output structural_corrected.nii \
281+ -d 3 --input-image structural.nii \
282+ --convergence [ 50x50x30x20 ] --output structural_corrected.nii \
285283 --shrink-factor 3'
286284
287285 >>> n4_2 = copy.deepcopy(n4)
288- >>> n4_2.inputs.bspline_order = 5
286+ >>> n4_2.inputs.convergence_threshold = 1e-6
289287 >>> n4_2.cmdline
290- 'N4BiasFieldCorrection --bspline-fitting [ 300, 5 ] \
291- --image-dimension 3 --input-image structural.nii \
288+ 'N4BiasFieldCorrection --bspline-fitting [ 300 ] \
289+ -d 3 --input-image structural.nii \
292290 --convergence [ 50x50x30x20, 1e-06 ] --output structural_corrected.nii \
293291 --shrink-factor 3'
294292
295- >>> n4_3 = N4BiasFieldCorrection()
296- >>> n4_3.inputs.input_image = 'structural.nii'
297- >>> n4_3.inputs.save_bias = True
293+ >>> n4_3 = copy.deepcopy(n4_2)
294+ >>> n4_3.inputs.bspline_order = 5
298295 >>> n4_3.cmdline
299- 'N4BiasFieldCorrection --image-dimension 3 --input-image structural.nii \
296+ 'N4BiasFieldCorrection --bspline-fitting [ 300, 5 ] \
297+ -d 3 --input-image structural.nii \
298+ --convergence [ 50x50x30x20, 1e-06 ] --output structural_corrected.nii \
299+ --shrink-factor 3'
300+
301+ >>> n4_4 = N4BiasFieldCorrection()
302+ >>> n4_4.inputs.input_image = 'structural.nii'
303+ >>> n4_4.inputs.save_bias = True
304+ >>> n4_4.cmdline
305+ 'N4BiasFieldCorrection -d 3 --input-image structural.nii \
300306 --output [ structural_corrected.nii, structural_bias.nii ]'
301307 """
302308
@@ -335,10 +341,12 @@ def _format_arg(self, name, trait_spec, value):
335341 newval = '[ %g ]' % value
336342 return trait_spec .argstr % newval
337343
338- if ((name == 'n_iterations' ) and
339- (isdefined (self .inputs .convergence_threshold ))):
340- newval = '[ %s, %g ]' % ('x' .join ([str (elt ) for elt in value ]),
341- self .inputs .convergence_threshold )
344+ if name == 'n_iterations' :
345+ if isdefined (self .inputs .convergence_threshold ):
346+ newval = '[ %s, %g ]' % ('x' .join ([str (elt ) for elt in value ]),
347+ self .inputs .convergence_threshold )
348+ else :
349+ newval = '[ %s ]' % 'x' .join ([str (elt ) for elt in value ])
342350 return trait_spec .argstr % newval
343351
344352 return super (N4BiasFieldCorrection ,
0 commit comments