Skip to content

Commit 1067924

Browse files
josephmjeoesteban
authored andcommitted
update dwidenoise, mrdegibbs and dwibiascorrect
1 parent 25b5a04 commit 1067924

File tree

4 files changed

+30
-62
lines changed

4 files changed

+30
-62
lines changed

nipype/interfaces/mrtrix3/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ class MRTrix3BaseInputSpec(CommandLineInputSpec):
4747
grad_file = File(
4848
exists=True,
4949
argstr='-grad %s',
50-
desc='dw gradient scheme (MRTrix format')
50+
desc='dw gradient scheme (MRTrix format)',
51+
xor=['grad_fsl'])
5152
grad_fsl = traits.Tuple(
5253
File(exists=True),
5354
File(exists=True),
5455
argstr='-fslgrad %s %s',
55-
desc='(bvecs, bvals) dw gradient scheme (FSL format')
56+
desc='(bvecs, bvals) dw gradient scheme (FSL format)',
57+
xor=['grad_file'])
5658
bval_scale = traits.Enum(
5759
'yes',
5860
'no',

nipype/interfaces/mrtrix3/preprocess.py

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,27 @@ class DWIDenoiseInputSpec(MRTrix3BaseInputSpec):
2323
argstr='-mask %s',
2424
position=1,
2525
desc='mask image')
26-
extent = traits.Tuple((traits.Int, traits.Int, traits.Int),
26+
extent = traits.Tuple(
27+
(traits.Int, traits.Int, traits.Int),
2728
argstr='-extent %d,%d,%d',
2829
desc='set the window size of the denoising filter. (default = 5,5,5)')
2930
noise = File(
3031
argstr='-noise %s',
31-
desc='the output noise map')
32-
out_file = File(name_template='%s_denoised',
32+
name_template='%s_noise',
3333
name_source='in_file',
3434
keep_extension=True,
35+
desc='the output noise map',
36+
genfile=True)
37+
out_file = File(
3538
argstr='%s',
3639
position=-1,
40+
name_template='%s_denoised',
41+
name_source='in_file',
42+
keep_extension=True,
3743
desc='the output denoised DWI image',
3844
genfile=True)
3945

46+
4047
class DWIDenoiseOutputSpec(TraitedSpec):
4148
noise = File(desc='the output noise map', exists=True)
4249
out_file = File(desc='the output denoised DWI image', exists=True)
@@ -76,13 +83,6 @@ class DWIDenoise(MRTrix3Base):
7683
input_spec = DWIDenoiseInputSpec
7784
output_spec = DWIDenoiseOutputSpec
7885

79-
def _list_outputs(self):
80-
outputs = self.output_spec().get()
81-
outputs['out_file'] = op.abspath(self.inputs.out_file)
82-
if self.inputs.noise != Undefined:
83-
outputs['noise'] = op.abspath(self.inputs.noise)
84-
return outputs
85-
8686

8787
class MRDeGibbsInputSpec(MRTrix3BaseInputSpec):
8888
in_file = File(
@@ -92,32 +92,29 @@ class MRDeGibbsInputSpec(MRTrix3BaseInputSpec):
9292
mandatory=True,
9393
desc='input DWI image')
9494
axes = traits.ListInt(
95-
default_value=[0,1],
96-
usedefault=True,
95+
[0,1],
9796
sep=',',
9897
minlen=2,
9998
maxlen=2,
10099
argstr='-axes %s',
101100
desc='indicate the plane in which the data was acquired (axial = 0,1; '
102101
'coronal = 0,2; sagittal = 1,2')
103102
nshifts = traits.Int(
104-
default_value=20,
105-
usedefault=True,
103+
20,
106104
argstr='-nshifts %d',
107105
desc='discretization of subpixel spacing (default = 20)')
108106
minW = traits.Int(
109-
default_value=1,
110-
usedefault=True,
107+
1,
111108
argstr='-minW %d',
112109
desc='left border of window used for total variation (TV) computation '
113110
'(default = 1)')
114111
maxW = traits.Int(
115-
default_value=3,
116-
usedefault=True,
112+
3,
117113
argstr='-maxW %d',
118114
desc='right border of window used for total variation (TV) computation '
119115
'(default = 3)')
120-
out_file = File(name_template='%s_unr',
116+
out_file = File(
117+
name_template='%s_unr',
121118
name_source='in_file',
122119
keep_extension=True,
123120
argstr='%s',
@@ -160,7 +157,7 @@ class MRDeGibbs(MRTrix3Base):
160157
>>> unring = mrt.MRDeGibbs()
161158
>>> unring.inputs.in_file = 'dwi.mif'
162159
>>> unring.cmdline
163-
'mrdegibbs -axes 0,1 -maxW 3 -minW 1 -nshifts 20 dwi.mif dwi_unr.mif'
160+
'mrdegibbs dwi.mif dwi_unr.mif'
164161
>>> unring.run() # doctest: +SKIP
165162
"""
166163

@@ -179,31 +176,19 @@ class DWIBiasCorrectInputSpec(MRTrix3BaseInputSpec):
179176
in_mask = File(
180177
argstr='-mask %s',
181178
desc='input mask image for bias field estimation')
182-
_xor_methods = ('use_ants', 'use_fsl')
183179
use_ants = traits.Bool(
184-
default_value=True,
185-
usedefault=True,
186180
argstr='-ants',
187181
desc='use ANTS N4 to estimate the inhomogeneity field',
188-
xor=_xor_methods)
182+
xor=['use_fsl'])
189183
use_fsl = traits.Bool(
190184
argstr='-fsl',
191185
desc='use FSL FAST to estimate the inhomogeneity field',
192-
xor=_xor_methods,
193-
min_ver='5.0.10')
194-
_xor_grads = ('mrtrix_grad', 'fsl_grad')
195-
mrtrix_grad = File(
196-
argstr='-grad %s',
197-
desc='diffusion gradient table in MRtrix format',
198-
xor=_xor_grads)
199-
fsl_grad = File(
200-
argstr='-fslgrad %s %s',
201-
desc='diffusion gradient table in FSL bvecs/bvals format',
202-
xor=_xor_grads)
186+
xor=['use_ants'])
203187
bias = File(
204188
argstr='-bias %s',
205189
desc='bias field')
206-
out_file = File(name_template='%s_biascorr',
190+
out_file = File(
191+
name_template='%s_biascorr',
207192
name_source='in_file',
208193
keep_extension=True,
209194
argstr='%s',
@@ -237,13 +222,6 @@ class DWIBiasCorrect(MRTrix3Base):
237222
input_spec = DWIBiasCorrectInputSpec
238223
output_spec = DWIBiasCorrectOutputSpec
239224

240-
def _list_outputs(self):
241-
outputs = self.output_spec().get()
242-
outputs['out_file'] = op.abspath(self.inputs.out_file)
243-
if self.inputs.bias != Undefined:
244-
outputs['bias'] = op.abspath(self.inputs.bias)
245-
return outputs
246-
247225

248226
class ResponseSDInputSpec(MRTrix3BaseInputSpec):
249227
algorithm = traits.Enum(

nipype/interfaces/mrtrix3/tests/test_auto_DWIBiasCorrect.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@ def test_DWIBiasCorrect_inputs():
4444
),
4545
use_ants=dict(
4646
argstr='-ants',
47-
usedefault=True,
48-
xor=('use_ants', 'use_fsl'),
47+
xor=['use_fsl'],
4948
),
5049
use_fsl=dict(
5150
argstr='-fsl',
52-
min_ver='5.0.10',
53-
xor=('use_ants', 'use_fsl'),
51+
xor=['use_ants'],
5452
),
5553
)
5654
inputs = DWIBiasCorrect.input_spec()

nipype/interfaces/mrtrix3/tests/test_auto_MRDeGibbs.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ def test_MRDeGibbs_inputs():
1111
maxlen=2,
1212
minlen=2,
1313
sep=',',
14-
usedefault=True,
1514
),
1615
bval_scale=dict(argstr='-bvalue_scaling %s', ),
1716
environ=dict(
@@ -27,18 +26,9 @@ def test_MRDeGibbs_inputs():
2726
mandatory=True,
2827
position=-2,
2928
),
30-
maxW=dict(
31-
argstr='-maxW %d',
32-
usedefault=True,
33-
),
34-
minW=dict(
35-
argstr='-minW %d',
36-
usedefault=True,
37-
),
38-
nshifts=dict(
39-
argstr='-nshifts %d',
40-
usedefault=True,
41-
),
29+
maxW=dict(argstr='-maxW %d', ),
30+
minW=dict(argstr='-minW %d', ),
31+
nshifts=dict(argstr='-nshifts %d', ),
4232
nthreads=dict(
4333
argstr='-nthreads %d',
4434
nohash=True,

0 commit comments

Comments
 (0)