Skip to content

Commit f2f504e

Browse files
josephmjeoesteban
authored andcommitted
update dwidenoise, mrdegibbs and dwibiascorrect
1 parent a147cbe commit f2f504e

File tree

5 files changed

+49
-75
lines changed

5 files changed

+49
-75
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: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ def test_DWIBiasCorrect_inputs():
1515
nohash=True,
1616
usedefault=True,
1717
),
18-
fsl_grad=dict(
19-
argstr='-fslgrad %s %s',
20-
extensions=None,
21-
xor=('mrtrix_grad', 'fsl_grad'),
22-
),
2318
grad_file=dict(
2419
argstr='-grad %s',
2520
extensions=None,
21+
xor=['grad_fsl'],
22+
),
23+
grad_fsl=dict(
24+
argstr='-fslgrad %s %s',
25+
xor=['grad_file'],
2626
),
27-
grad_fsl=dict(argstr='-fslgrad %s %s', ),
2827
in_bval=dict(extensions=None, ),
2928
in_bvec=dict(
3029
argstr='-fslgrad %s %s',
@@ -40,11 +39,6 @@ def test_DWIBiasCorrect_inputs():
4039
argstr='-mask %s',
4140
extensions=None,
4241
),
43-
mrtrix_grad=dict(
44-
argstr='-grad %s',
45-
extensions=None,
46-
xor=('mrtrix_grad', 'fsl_grad'),
47-
),
4842
nthreads=dict(
4943
argstr='-nthreads %d',
5044
nohash=True,
@@ -60,13 +54,11 @@ def test_DWIBiasCorrect_inputs():
6054
),
6155
use_ants=dict(
6256
argstr='-ants',
63-
usedefault=True,
64-
xor=('use_ants', 'use_fsl'),
57+
xor=['use_fsl'],
6558
),
6659
use_fsl=dict(
6760
argstr='-fsl',
68-
min_ver='5.0.10',
69-
xor=('use_ants', 'use_fsl'),
61+
xor=['use_ants'],
7062
),
7163
)
7264
inputs = DWIBiasCorrect.input_spec()

nipype/interfaces/mrtrix3/tests/test_auto_DWIDenoise.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ def test_DWIDenoise_inputs():
1515
grad_file=dict(
1616
argstr='-grad %s',
1717
extensions=None,
18+
xor=['grad_fsl'],
19+
),
20+
grad_fsl=dict(
21+
argstr='-fslgrad %s %s',
22+
xor=['grad_file'],
1823
),
19-
grad_fsl=dict(argstr='-fslgrad %s %s', ),
2024
in_bval=dict(extensions=None, ),
2125
in_bvec=dict(
2226
argstr='-fslgrad %s %s',
@@ -36,6 +40,10 @@ def test_DWIDenoise_inputs():
3640
noise=dict(
3741
argstr='-noise %s',
3842
extensions=None,
43+
genfile=True,
44+
keep_extension=True,
45+
name_source='in_file',
46+
name_template='%s_noise',
3947
),
4048
nthreads=dict(
4149
argstr='-nthreads %d',

nipype/interfaces/mrtrix3/tests/test_auto_MRDeGibbs.py

Lines changed: 8 additions & 14 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(
@@ -21,8 +20,12 @@ def test_MRDeGibbs_inputs():
2120
grad_file=dict(
2221
argstr='-grad %s',
2322
extensions=None,
23+
xor=['grad_fsl'],
24+
),
25+
grad_fsl=dict(
26+
argstr='-fslgrad %s %s',
27+
xor=['grad_file'],
2428
),
25-
grad_fsl=dict(argstr='-fslgrad %s %s', ),
2629
in_bval=dict(extensions=None, ),
2730
in_bvec=dict(
2831
argstr='-fslgrad %s %s',
@@ -34,18 +37,9 @@ def test_MRDeGibbs_inputs():
3437
mandatory=True,
3538
position=-2,
3639
),
37-
maxW=dict(
38-
argstr='-maxW %d',
39-
usedefault=True,
40-
),
41-
minW=dict(
42-
argstr='-minW %d',
43-
usedefault=True,
44-
),
45-
nshifts=dict(
46-
argstr='-nshifts %d',
47-
usedefault=True,
48-
),
40+
maxW=dict(argstr='-maxW %d', ),
41+
minW=dict(argstr='-minW %d', ),
42+
nshifts=dict(argstr='-nshifts %d', ),
4943
nthreads=dict(
5044
argstr='-nthreads %d',
5145
nohash=True,

0 commit comments

Comments
 (0)