@@ -276,26 +276,33 @@ class N4BiasFieldCorrection(ANTSCommand):
276
276
>>> n4.inputs.bspline_fitting_distance = 300
277
277
>>> n4.inputs.shrink_factor = 3
278
278
>>> n4.inputs.n_iterations = [50,50,30,20]
279
- >>> n4.inputs.convergence_threshold = 1e-6
280
279
>>> n4.cmdline
281
280
'N4BiasFieldCorrection --bspline-fitting [ 300 ] \
282
- --image-dimension 3 --input-image structural.nii \
283
- --convergence [ 50x50x30x20, 1e-06 ] --output structural_corrected.nii \
281
+ -d 3 --input-image structural.nii \
282
+ --convergence [ 50x50x30x20 ] --output structural_corrected.nii \
284
283
--shrink-factor 3'
285
284
286
285
>>> n4_2 = copy.deepcopy(n4)
287
- >>> n4_2 .inputs.bspline_order = 5
286
+ >>> n4 .inputs.convergence_threshold = 1e-6
288
287
>>> n4_2.cmdline
289
- 'N4BiasFieldCorrection --bspline-fitting [ 300, 5 ] \
290
- --image-dimension 3 --input-image structural.nii \
288
+ 'N4BiasFieldCorrection --bspline-fitting [ 300 ] \
289
+ -d 3 --input-image structural.nii \
291
290
--convergence [ 50x50x30x20, 1e-06 ] --output structural_corrected.nii \
292
291
--shrink-factor 3'
293
292
294
- >>> n4_3 = N4BiasFieldCorrection()
295
- >>> n4_3.inputs.input_image = 'structural.nii'
296
- >>> n4_3.inputs.save_bias = True
293
+ >>> n4_3 = copy.deepcopy(n4)
294
+ >>> n4_3.inputs.bspline_order = 5
297
295
>>> n4_3.cmdline
298
- '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 \
299
306
--output [ structural_corrected.nii, structural_bias.nii ]'
300
307
"""
301
308
@@ -334,10 +341,12 @@ def _format_arg(self, name, trait_spec, value):
334
341
newval = '[ %g ]' % value
335
342
return trait_spec .argstr % newval
336
343
337
- if ((name == 'n_iterations' ) and
338
- (isdefined (self .inputs .convergence_threshold ))):
339
- newval = '[ %s, %g ]' % ('x' .join ([str (elt ) for elt in value ]),
340
- 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 ])
341
350
return trait_spec .argstr % newval
342
351
343
352
return super (N4BiasFieldCorrection ,
0 commit comments