@@ -28,16 +28,18 @@ class DWIDenoiseInputSpec(MRTrix3BaseInputSpec):
28
28
desc = 'set the window size of the denoising filter. (default = 5,5,5)' )
29
29
noise = File (
30
30
argstr = '-noise %s' ,
31
- desc = 'noise map' )
31
+ desc = 'the output noise map' )
32
32
out_file = File (name_template = '%s_denoised' ,
33
33
name_source = 'in_file' ,
34
34
keep_extension = True ,
35
- argstr = "%s" ,
35
+ argstr = '%s' ,
36
36
position = - 1 ,
37
- desc = "the output denoised DWI image" )
37
+ desc = 'the output denoised DWI image' ,
38
+ genfile = True )
38
39
39
40
class DWIDenoiseOutputSpec (TraitedSpec ):
40
- out_file = File (desc = "the output denoised DWI image" , exists = True )
41
+ noise = File (desc = 'the output noise map' , exists = True )
42
+ out_file = File (desc = 'the output denoised DWI image' , exists = True )
41
43
42
44
class DWIDenoise (MRTrix3Base ):
43
45
"""
@@ -74,6 +76,174 @@ class DWIDenoise(MRTrix3Base):
74
76
input_spec = DWIDenoiseInputSpec
75
77
output_spec = DWIDenoiseOutputSpec
76
78
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
+
86
+
87
+ class MRDeGibbsInputSpec (MRTrix3BaseInputSpec ):
88
+ in_file = File (
89
+ exists = True ,
90
+ argstr = '%s' ,
91
+ position = - 2 ,
92
+ mandatory = True ,
93
+ desc = 'input DWI image' )
94
+ axes = traits .ListInt (
95
+ default_value = [0 ,1 ],
96
+ usedefault = True ,
97
+ sep = ',' ,
98
+ minlen = 2 ,
99
+ maxlen = 2 ,
100
+ argstr = '-axes %s' ,
101
+ desc = 'indicate the plane in which the data was acquired (axial = 0,1; '
102
+ 'coronal = 0,2; sagittal = 1,2' )
103
+ nshifts = traits .Int (
104
+ default_value = 20 ,
105
+ usedefault = True ,
106
+ argstr = '-nshifts %d' ,
107
+ desc = 'discretization of subpixel spacing (default = 20)' )
108
+ minW = traits .Int (
109
+ default_value = 1 ,
110
+ usedefault = True ,
111
+ argstr = '-minW %d' ,
112
+ desc = 'left border of window used for total variation (TV) computation '
113
+ '(default = 1)' )
114
+ maxW = traits .Int (
115
+ default_value = 3 ,
116
+ usedefault = True ,
117
+ argstr = '-maxW %d' ,
118
+ desc = 'right border of window used for total variation (TV) computation '
119
+ '(default = 3)' )
120
+ out_file = File (name_template = '%s_unr' ,
121
+ name_source = 'in_file' ,
122
+ keep_extension = True ,
123
+ argstr = '%s' ,
124
+ position = - 1 ,
125
+ desc = 'the output unringed DWI image' ,
126
+ genfile = True )
127
+
128
+ class MRDeGibbsOutputSpec (TraitedSpec ):
129
+ out_file = File (desc = 'the output unringed DWI image' , exists = True )
130
+
131
+ class MRDeGibbs (MRTrix3Base ):
132
+ """
133
+ Remove Gibbs ringing artifacts.
134
+
135
+ This application attempts to remove Gibbs ringing artefacts from MRI images
136
+ using the method of local subvoxel-shifts proposed by Kellner et al.
137
+
138
+ This command is designed to run on data directly after it has been
139
+ reconstructed by the scanner, before any interpolation of any kind has
140
+ taken place. You should not run this command after any form of motion
141
+ correction (e.g. not after dwipreproc). Similarly, if you intend running
142
+ dwidenoise, you should run this command afterwards, since it has the
143
+ potential to alter the noise structure, which would impact on dwidenoise's
144
+ performance.
145
+
146
+ Note that this method is designed to work on images acquired with full
147
+ k-space coverage. Running this method on partial Fourier ('half-scan') data
148
+ may lead to suboptimal and/or biased results, as noted in the original
149
+ reference below. There is currently no means of dealing with this; users
150
+ should exercise caution when using this method on partial Fourier data, and
151
+ inspect its output for any obvious artefacts.
152
+
153
+ For more information, see
154
+ <https://mrtrix.readthedocs.io/en/latest/reference/commands/mrdegibbs.html>
155
+
156
+ Example
157
+ -------
158
+
159
+ >>> import nipype.interfaces.mrtrix3 as mrt
160
+ >>> unring = mrt.MRDeGibbs()
161
+ >>> unring.inputs.in_file = 'dwi.mif'
162
+ >>> unring.cmdline
163
+ 'mrdegibbs -axes 0,1 -maxW 3 -minW 1 -nshifts 20 dwi.mif dwi_unr.mif'
164
+ >>> unring.run() # doctest: +SKIP
165
+ """
166
+
167
+ _cmd = 'mrdegibbs'
168
+ input_spec = MRDeGibbsInputSpec
169
+ output_spec = MRDeGibbsOutputSpec
170
+
171
+
172
+ class DWIBiasCorrectInputSpec (MRTrix3BaseInputSpec ):
173
+ in_file = File (
174
+ exists = True ,
175
+ argstr = '%s' ,
176
+ position = - 2 ,
177
+ mandatory = True ,
178
+ desc = 'input DWI image' )
179
+ in_mask = File (
180
+ argstr = '-mask %s' ,
181
+ desc = 'input mask image for bias field estimation' )
182
+ _xor_methods = ('use_ants' , 'use_fsl' )
183
+ use_ants = traits .Bool (
184
+ default_value = True ,
185
+ usedefault = True ,
186
+ argstr = '-ants' ,
187
+ desc = 'use ANTS N4 to estimate the inhomogeneity field' ,
188
+ xor = _xor_methods )
189
+ use_fsl = traits .Bool (
190
+ argstr = '-fsl' ,
191
+ 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 )
203
+ bias = File (
204
+ argstr = '-bias %s' ,
205
+ desc = 'bias field' )
206
+ out_file = File (name_template = '%s_biascorr' ,
207
+ name_source = 'in_file' ,
208
+ keep_extension = True ,
209
+ argstr = '%s' ,
210
+ position = - 1 ,
211
+ desc = 'the output bias corrected DWI image' ,
212
+ genfile = True )
213
+
214
+ class DWIBiasCorrectOutputSpec (TraitedSpec ):
215
+ bias = File (desc = 'the output bias field' , exists = True )
216
+ out_file = File (desc = 'the output bias corrected DWI image' , exists = True )
217
+
218
+ class DWIBiasCorrect (MRTrix3Base ):
219
+ """
220
+ Perform B1 field inhomogeneity correction for a DWI volume series.
221
+
222
+ For more information, see
223
+ <https://mrtrix.readthedocs.io/en/latest/reference/scripts/dwibiascorrect.html>
224
+
225
+ Example
226
+ -------
227
+
228
+ >>> import nipype.interfaces.mrtrix3 as mrt
229
+ >>> bias_correct = mrt.DWIBiasCorrect()
230
+ >>> bias_correct.inputs.in_file = 'dwi.mif'
231
+ >>> bias_correct.cmdline
232
+ 'dwibiascorrect -ants dwi.mif dwi_biascorr.mif'
233
+ >>> bias_correct.run() # doctest: +SKIP
234
+ """
235
+
236
+ _cmd = 'dwibiascorrect'
237
+ input_spec = DWIBiasCorrectInputSpec
238
+ output_spec = DWIBiasCorrectOutputSpec
239
+
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
+
77
247
78
248
class ResponseSDInputSpec (MRTrix3BaseInputSpec ):
79
249
algorithm = traits .Enum (
0 commit comments