@@ -223,7 +223,7 @@ def _list_outputs(self):
223
223
224
224
225
225
class N4BiasFieldCorrectionInputSpec (ANTSCommandInputSpec ):
226
- dimension = traits .Enum (3 , 2 , argstr = '--image-dimension %d' ,
226
+ dimension = traits .Enum (3 , 2 , argstr = '-d %d' ,
227
227
usedefault = True ,
228
228
desc = 'image dimension (2 or 3)' )
229
229
input_image = File (argstr = '--input-image %s' , mandatory = True ,
@@ -237,8 +237,7 @@ class N4BiasFieldCorrectionInputSpec(ANTSCommandInputSpec):
237
237
bspline_fitting_distance = traits .Float (argstr = "--bspline-fitting %s" )
238
238
bspline_order = traits .Int (requires = ['bspline_fitting_distance' ])
239
239
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" )
242
241
convergence_threshold = traits .Float (requires = ['n_iterations' ])
243
242
save_bias = traits .Bool (False , mandatory = True , usedefault = True ,
244
243
desc = ('True if the estimated bias should be saved'
@@ -277,26 +276,33 @@ class N4BiasFieldCorrection(ANTSCommand):
277
276
>>> n4.inputs.bspline_fitting_distance = 300
278
277
>>> n4.inputs.shrink_factor = 3
279
278
>>> n4.inputs.n_iterations = [50,50,30,20]
280
- >>> n4.inputs.convergence_threshold = 1e-6
281
279
>>> n4.cmdline
282
280
'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 \
285
283
--shrink-factor 3'
286
284
287
285
>>> n4_2 = copy.deepcopy(n4)
288
- >>> n4_2.inputs.bspline_order = 5
286
+ >>> n4_2.inputs.convergence_threshold = 1e-6
289
287
>>> 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 \
292
290
--convergence [ 50x50x30x20, 1e-06 ] --output structural_corrected.nii \
293
291
--shrink-factor 3'
294
292
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
298
295
>>> 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 \
300
306
--output [ structural_corrected.nii, structural_bias.nii ]'
301
307
"""
302
308
@@ -335,10 +341,12 @@ def _format_arg(self, name, trait_spec, value):
335
341
newval = '[ %g ]' % value
336
342
return trait_spec .argstr % newval
337
343
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 ])
342
350
return trait_spec .argstr % newval
343
351
344
352
return super (N4BiasFieldCorrection ,
0 commit comments