Skip to content

Commit db0cfd4

Browse files
author
blakedewey
committed
Updated N4BiasFieldCorrection
Added weight_image to input spec. Added bspline_order to input spec and updated arg formatting for bspline_fitting_distance to allow for bspline_order to be set. Updated n_iterations and convergence_threshold arg formatting to conform with other arg formatting for this class.
1 parent 5cb003c commit db0cfd4

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

nipype/interfaces/ants/segmentation.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,17 +229,16 @@ class N4BiasFieldCorrectionInputSpec(ANTSCommandInputSpec):
229229
desc=('image to apply transformation to (generally a '
230230
'coregistered functional)'))
231231
mask_image = File(argstr='--mask-image %s')
232+
weight_image = File(argstr='--weight-image %s')
232233
output_image = traits.Str(argstr='--output %s',
233234
desc=('output file name'), genfile=True,
234235
hash_files=False)
235-
bspline_fitting_distance = traits.Float(argstr="--bsline-fitting [%g]")
236+
bspline_fitting_distance = traits.Float(argstr="--bspline-fitting %s")
237+
bspline_order = traits.Int(requires=['bspline_fitting_distance'])
236238
shrink_factor = traits.Int(argstr="--shrink-factor %d")
237-
n_iterations = traits.List(traits.Int(), argstr="--convergence [ %s",
238-
sep="x", requires=['convergence_threshold'],
239-
position=1)
240-
convergence_threshold = traits.Float(argstr=",%g]",
241-
requires=['n_iterations'],
242-
position=2)
239+
n_iterations = traits.List(traits.Int(), argstr="--convergence %s",
240+
requires=['convergence_threshold'])
241+
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'
245244
' to file.'), xor=['bias_image'])
@@ -315,7 +314,20 @@ def _format_arg(self, name, trait_spec, value):
315314
(self.inputs.save_bias or isdefined(self.inputs.bias_image))):
316315
bias_image = self._gen_filename('bias_image')
317316
output = self._gen_filename('output_image')
318-
newval = '[%s,%s]' % (output, bias_image)
317+
newval = '[ %s, %s ]' % (output, bias_image)
318+
return trait_spec.argstr % newval
319+
320+
if name == 'bspline_fitting_distance':
321+
if isdefined(self.inputs.bspline_order):
322+
newval = '[ %g, %d ]' % (value, self.inputs.bspline_order)
323+
else:
324+
newval = '[ %g ]' % value
325+
return trait_spec.argstr % newval
326+
327+
if ((name == 'n_iterations') and
328+
(isdefined(self.inputs.convergence_threshold))):
329+
newval = '[ %s, %g ]' % ('x'.join([str(elt) for elt in value]),
330+
self.inputs.convergence_threshold)
319331
return trait_spec.argstr % newval
320332

321333
return super(N4BiasFieldCorrection,

nipype/interfaces/ants/tests/test_auto_N4BiasFieldCorrection.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ def test_N4BiasFieldCorrection_inputs():
77
),
88
bias_image=dict(hash_files=False,
99
),
10-
bspline_fitting_distance=dict(argstr='--bsline-fitting [%g]',
10+
bspline_fitting_distance=dict(argstr='--bspline-fitting %s',
1111
),
12-
convergence_threshold=dict(argstr=',%g]',
13-
position=2,
14-
requires=['n_iterations'],
12+
bspline_order=dict(requires=['bspline_fitting_distance'],
13+
),
14+
convergence_threshold=dict(requires=['n_iterations'],
1515
),
1616
dimension=dict(argstr='--image-dimension %d',
1717
usedefault=True,
@@ -27,10 +27,8 @@ def test_N4BiasFieldCorrection_inputs():
2727
),
2828
mask_image=dict(argstr='--mask-image %s',
2929
),
30-
n_iterations=dict(argstr='--convergence [ %s',
31-
position=1,
30+
n_iterations=dict(argstr='--convergence %s',
3231
requires=['convergence_threshold'],
33-
sep='x',
3432
),
3533
num_threads=dict(nohash=True,
3634
usedefault=True,
@@ -48,6 +46,8 @@ def test_N4BiasFieldCorrection_inputs():
4846
terminal_output=dict(mandatory=True,
4947
nohash=True,
5048
),
49+
weight_image=dict(argstr='--weight-image %s',
50+
),
5151
)
5252
inputs = N4BiasFieldCorrection.input_spec()
5353

0 commit comments

Comments
 (0)