Skip to content

Commit 9cbbd96

Browse files
rciricoesteban
authored andcommitted
(enh) additional arguments to ANTs N4BiasFieldCorrection
1 parent 216db0d commit 9cbbd96

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

nipype/interfaces/ants/segmentation.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,18 @@ class N4BiasFieldCorrectionInputSpec(ANTSCommandInputSpec):
317317
The result is that the range can "drift" from the original at each iteration.
318318
This option rescales to the [min,max] range of the original image intensities
319319
within the user-specified mask.""")
320+
histogram_fwhm = traits.Float(
321+
0.15, usedefault=True,
322+
argstr='--histogram-sharpening %s',
323+
desc='Histogram sharpening parameter: FWHM')
324+
histogram_wiener_noise = traits.Float(
325+
0.01, usedefault=True,
326+
requires=['histogram_fwhm'],
327+
desc='Histogram sharpening parameter: Wiener noise')
328+
histogram_bins = traits.Int(
329+
200, usedefault=True,
330+
requires=['histogram_fwhm', 'histogram_wiener_noise'],
331+
desc='Histogram sharpening parameter: number of bins')
320332

321333

322334
class N4BiasFieldCorrectionOutputSpec(TraitedSpec):
@@ -414,6 +426,16 @@ def _format_arg(self, name, trait_spec, value):
414426
[str(elt) for elt in value])
415427
return trait_spec.argstr % newval
416428

429+
if name == 'histogram_fwhm':
430+
newval = '[ %f' % value
431+
if isdefined(self.inputs.histogram_wiener_noise):
432+
newval = '%s, %f' % (
433+
newval, self.inputs.histogram_wiener_noise)
434+
if isdefined(self.inputs.histogram_bins):
435+
newval = '%s, %d' % (newval, self.inputs.histogram_bins)
436+
newval = '%s ]' % newval
437+
return trait_spec.argstr % newval
438+
417439
return super(N4BiasFieldCorrection, self)._format_arg(
418440
name, trait_spec, value)
419441

nipype/interfaces/ants/tests/test_auto_N4BiasFieldCorrection.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ def test_N4BiasFieldCorrection_inputs():
2525
nohash=True,
2626
usedefault=True,
2727
),
28+
histogram_bins=dict(
29+
requires=['histogram_fwhm', 'histogram_wiener_noise'],
30+
usedefault=True,
31+
),
32+
histogram_fwhm=dict(
33+
argstr='--histogram-sharpening %s',
34+
usedefault=True,
35+
),
36+
histogram_wiener_noise=dict(
37+
requires=['histogram_fwhm'],
38+
usedefault=True,
39+
),
2840
input_image=dict(
2941
argstr='--input-image %s',
3042
extensions=None,
@@ -51,6 +63,7 @@ def test_N4BiasFieldCorrection_inputs():
5163
min_ver='2.1.0',
5264
usedefault=True,
5365
),
66+
rescale_intensities=dict(argstr='--rescale-intensities %d', ),
5467
save_bias=dict(
5568
mandatory=True,
5669
usedefault=True,

0 commit comments

Comments
 (0)