Skip to content

Commit 6a49acd

Browse files
committed
initial attempt at adding mrtrix commands
1 parent ef02ff0 commit 6a49acd

File tree

3 files changed

+146
-4
lines changed

3 files changed

+146
-4
lines changed

nipype/interfaces/fsl/epi.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,7 @@ def _list_outputs(self):
13831383
# If the output directory isn't defined, the interface seems to use
13841384
# the default but not set its value in `self.inputs.output_dir`
13851385
if not isdefined(self.inputs.output_dir):
1386-
out_dir = os.path.abspath(os.path.basename(self.inputs.base_name) + '.qc.nii.gz')
1386+
out_dir = os.path.abspath(os.path.basename(self.inputs.base_name) + '.qc')
13871387
else:
13881388
out_dir = os.path.abspath(self.inputs.output_dir)
13891389

@@ -1421,4 +1421,3 @@ def _list_outputs(self):
14211421
outputs['clean_volumes'] = clean_volumes
14221422

14231423
return outputs
1424-

nipype/interfaces/mrtrix3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from .utils import (Mesh2PVE, Generate5tt, BrainMask, TensorMetrics,
77
ComputeTDI, TCK2VTK, MRMath, MRConvert, DWIExtract)
88
from .preprocess import (ResponseSD, ACTPrepareFSL, ReplaceFSwithFIRST,
9-
DWIDenoise)
9+
DWIDenoise, MRDeGibbs, DWIBiasCorrect)
1010
from .tracking import Tractography
1111
from .reconst import FitTensor, EstimateFOD
1212
from .connectivity import LabelConfig, LabelConvert, BuildConnectome

nipype/interfaces/mrtrix3/preprocess.py

Lines changed: 144 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DWIDenoiseInputSpec(MRTrix3BaseInputSpec):
2121
mask = File(
2222
exists=True,
2323
argstr='-mask %s',
24-
position=1,
24+
#osition=1,
2525
desc='mask image')
2626
extent = traits.Tuple((traits.Int, traits.Int, traits.Int),
2727
argstr='-extent %d,%d,%d',
@@ -75,6 +75,149 @@ class DWIDenoise(MRTrix3Base):
7575
output_spec = DWIDenoiseOutputSpec
7676

7777

78+
class MRDeGibbsInputSpec(MRTrix3BaseInputSpec):
79+
in_file = File(
80+
exists=True,
81+
argstr='%s',
82+
position=-2,
83+
mandatory=True,
84+
desc='input DWI image')
85+
axes = InputMultiObject(
86+
traits.Int,
87+
value=[0],
88+
usedefault=True,
89+
argstr='-axes %d',
90+
desc='select the slice axes (default = 0)')
91+
nshifts = InputMultiObject(
92+
traits.Int,
93+
value=[20],
94+
usedefault=True,
95+
argstr='-nshifts %d',
96+
desc='discretizaiton of subpixel spacing (default = 20)')
97+
minW = InputMultiObject(
98+
traits.Int,
99+
value=[1],
100+
usedefault=True,
101+
argstr='-minW %d',
102+
desc='left border of window used for TV computation (default = 1)')
103+
maxW = InputMultiObject(
104+
traits.Int,
105+
value=[3],
106+
usedefault=True,
107+
argstr='-maxW %d',
108+
desc='right border of window used for TV computation (default = 3)')
109+
out_file = File(name_template='%s_unring',
110+
name_source='in_file',
111+
keep_extension=True,
112+
argstr="%s",
113+
position=-1,
114+
desc="the output unringed DWI image")
115+
116+
class MRDeGibbsOutputSpec(TraitedSpec):
117+
out_file = File(desc="the output unringed DWI image", exists=True)
118+
119+
class MRDeGibbs(MRTrix3Base):
120+
"""
121+
Remove Gibbs ringing artifacts.
122+
123+
This application attempts to remove Gibbs ringing artefacts from MRI images
124+
using the method of local subvoxel-shifts proposed by Kellner et al.
125+
126+
This command is designed to run on data directly after it has been
127+
reconstructed by the scanner, before any interpolation of any kind has
128+
taken place. You should not run this command after any form of motion
129+
correction (e.g. not after dwipreproc). Similarly, if you intend running
130+
dwidenoise, you should run this command afterwards, since it has the
131+
potential to alter the noise structure, which would impact on dwidenoise’s
132+
performance.
133+
134+
Note that this method is designed to work on images acquired with full
135+
k-space coverage. Running this method on partial Fourier (‘half-scan’) data
136+
may lead to suboptimal and/or biased results, as noted in the original
137+
reference below. There is currently no means of dealing with this; users
138+
should exercise caution when using this method on partial Fourier data, and
139+
inspect its output for any obvious artefacts.
140+
141+
For more information, see
142+
<https://mrtrix.readthedocs.io/en/latest/reference/commands/mrdegibbs.html>
143+
144+
Example
145+
-------
146+
147+
>>> import nipype.interfaces.mrtrix3 as mrt
148+
>>> unring = mrt.MRDeGibbs()
149+
>>> unring.inputs.in_file = 'dwi.mif'
150+
>>> unring.cmdline
151+
'mrdegibbs dwi.mif dwi_unring.mif'
152+
>>> unring.run()
153+
"""
154+
155+
_cmd = 'mrdegibbs'
156+
input_spec = MRDeGibbsInputSpec
157+
output_spec = MRDeGibbsOutputSpec
158+
159+
160+
class DWIBiasCorrectInputSpec(MRTrix3BaseInputSpec):
161+
in_file = File(
162+
exists=True,
163+
argstr='%s',
164+
position=-2,
165+
mandatory=True,
166+
desc='input DWI image')
167+
mask = File(
168+
argstr='-mask %s',
169+
desc='mask image')
170+
bias = File(
171+
argstr='-bias %s',
172+
desc='bias field')
173+
ants = traits.Bool(
174+
True,
175+
argstr='-ants',
176+
desc='use ANTS N4')
177+
fsl = traits.Bool(
178+
False,
179+
argstr='-fsl',
180+
desc='use FSL FAST',
181+
min_ver='5.0.10')
182+
grad = File(
183+
argstr='-grad %s',
184+
desc='diffusion gradient table in MRtrix format')
185+
fslgrad = File(
186+
argstr='-fslgrad %s %s',
187+
desc='diffusion gradient table in FSL bvecs/bvals format')
188+
out_file = File(name_template='%s_unbias',
189+
name_source='in_file',
190+
keep_extension=True,
191+
argstr="%s",
192+
position=-1,
193+
desc="the output bias corrected DWI image")
194+
195+
class DWIBiasCorrectOutputSpec(TraitedSpec):
196+
out_file = File(desc="the output bias corrected DWI image", exists=True)
197+
198+
class DWIBiasCorrect(MRTrix3Base):
199+
"""
200+
Perform B1 field inhomogeneity correction for a DWI volume series.
201+
202+
For more information, see
203+
<https://mrtrix.readthedocs.io/en/latest/reference/scripts/dwibiascorrect.html>
204+
205+
Example
206+
-------
207+
208+
>>> import nipype.interfaces.mrtrix3 as mrt
209+
>>> bias_correct = mrt.DWIBiasCorrect()
210+
>>> bias_correct.inputs.in_file = 'dwi.mif'
211+
>>> bias_correct.cmdline
212+
'dwibiascorrect dwi.mif dwi_unbias.mif'
213+
>>> bias_correct.run()
214+
"""
215+
216+
_cmd = 'dwibiascorrect'
217+
input_spec = DWIBiasCorrectInputSpec
218+
output_spec = DWIBiasCorrectOutputSpec
219+
220+
78221
class ResponseSDInputSpec(MRTrix3BaseInputSpec):
79222
algorithm = traits.Enum(
80223
'msmt_5tt',

0 commit comments

Comments
 (0)