Skip to content

Commit af8d36c

Browse files
effigiesGalKeplerZviBaratz
committed
ENH: Add MRTrix3 interfaces (pared-down gh-3426)
Co-authored-by: GalBenZvi <hershkovitz1@mail.tau.ac.il> Co-authored-by: Zvi Baratz <z.baratz@gmail.com>
1 parent e31573b commit af8d36c

22 files changed

+780
-20
lines changed

nipype/interfaces/mrtrix3/__init__.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,32 @@
22
# vi: set ft=python sts=4 ts=4 sw=4 et:
33
# -*- coding: utf-8 -*-
44
"""MRTrix3 provides software tools to perform various types of diffusion MRI analyses."""
5+
from .connectivity import BuildConnectome, LabelConfig, LabelConvert
6+
from .preprocess import (
7+
ACTPrepareFSL,
8+
DWIBiasCorrect,
9+
DWIDenoise,
10+
DWIPreproc,
11+
MRDeGibbs,
12+
ReplaceFSwithFIRST,
13+
ResponseSD,
14+
)
15+
from .reconst import ConstrainedSphericalDeconvolution, EstimateFOD, FitTensor
16+
from .tracking import Tractography
517
from .utils import (
6-
Mesh2PVE,
7-
Generate5tt,
18+
TCK2VTK,
819
BrainMask,
9-
TensorMetrics,
1020
ComputeTDI,
11-
TCK2VTK,
12-
MRMath,
21+
DWIExtract,
22+
Generate5tt,
23+
Mesh2PVE,
24+
MRCat,
1325
MRConvert,
26+
MRMath,
1427
MRResize,
15-
DWIExtract,
16-
SHConv,
28+
MRTransform,
1729
SH2Amp,
30+
SHConv,
31+
TensorMetrics,
32+
TransformFSLConvert,
1833
)
19-
from .preprocess import (
20-
ResponseSD,
21-
ACTPrepareFSL,
22-
ReplaceFSwithFIRST,
23-
DWIPreproc,
24-
DWIDenoise,
25-
MRDeGibbs,
26-
DWIBiasCorrect,
27-
)
28-
from .tracking import Tractography
29-
from .reconst import FitTensor, EstimateFOD, ConstrainedSphericalDeconvolution
30-
from .connectivity import LabelConfig, LabelConvert, BuildConnectome

nipype/interfaces/mrtrix3/base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ class MRTrix3BaseInputSpec(CommandLineInputSpec):
7979
exists=True, argstr="-fslgrad %s %s", desc="bvecs file in FSL format"
8080
)
8181
in_bval = File(exists=True, desc="bvals file in FSL format")
82+
out_bvec = File(
83+
exists=False,
84+
argstr="-export_grad_fsl %s %s",
85+
desc="export bvec file in FSL format",
86+
)
87+
out_bval = File(
88+
exists=False,
89+
desc="export bval file in FSL format",
90+
)
8291

8392

8493
class MRTrix3Base(CommandLine):
@@ -96,6 +105,8 @@ def _format_arg(self, name, trait_spec, value):
96105

97106
if name == "in_bvec":
98107
return trait_spec.argstr % (value, self.inputs.in_bval)
108+
if name == "out_bvec":
109+
return trait_spec.argstr % (value, self.inputs.out_bval)
99110

100111
return super(MRTrix3Base, self)._format_arg(name, trait_spec, value)
101112

nipype/interfaces/mrtrix3/tests/test_auto_BrainMask.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ def test_BrainMask_inputs():
4040
argstr="-nthreads %d",
4141
nohash=True,
4242
),
43+
out_bval=dict(
44+
extensions=None,
45+
),
46+
out_bvec=dict(
47+
argstr="-export_grad_fsl %s %s",
48+
extensions=None,
49+
),
4350
out_file=dict(
4451
argstr="%s",
4552
extensions=None,

nipype/interfaces/mrtrix3/tests/test_auto_ConstrainedSphericalDeconvolution.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ def test_ConstrainedSphericalDeconvolution_inputs():
7777
argstr="-nthreads %d",
7878
nohash=True,
7979
),
80+
out_bval=dict(
81+
extensions=None,
82+
),
83+
out_bvec=dict(
84+
argstr="-export_grad_fsl %s %s",
85+
extensions=None,
86+
),
8087
predicted_signal=dict(
8188
argstr="-predicted_signal %s",
8289
extensions=None,

nipype/interfaces/mrtrix3/tests/test_auto_DWIBiasCorrect.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ def test_DWIBiasCorrect_inputs():
4848
argstr="-nthreads %d",
4949
nohash=True,
5050
),
51+
out_bval=dict(
52+
extensions=None,
53+
),
54+
out_bvec=dict(
55+
argstr="-export_grad_fsl %s %s",
56+
extensions=None,
57+
),
5158
out_file=dict(
5259
argstr="%s",
5360
extensions=None,

nipype/interfaces/mrtrix3/tests/test_auto_DWIDenoise.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ def test_DWIDenoise_inputs():
5555
argstr="-nthreads %d",
5656
nohash=True,
5757
),
58+
out_bval=dict(
59+
extensions=None,
60+
),
61+
out_bvec=dict(
62+
argstr="-export_grad_fsl %s %s",
63+
extensions=None,
64+
),
5865
out_file=dict(
5966
argstr="%s",
6067
extensions=None,

nipype/interfaces/mrtrix3/tests/test_auto_DWIExtract.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ def test_DWIExtract_inputs():
4646
argstr="-nthreads %d",
4747
nohash=True,
4848
),
49+
out_bval=dict(
50+
extensions=None,
51+
),
52+
out_bvec=dict(
53+
argstr="-export_grad_fsl %s %s",
54+
extensions=None,
55+
),
4956
out_file=dict(
5057
argstr="%s",
5158
extensions=None,

nipype/interfaces/mrtrix3/tests/test_auto_DWIPreproc.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ def test_DWIPreproc_inputs():
5656
argstr="-nthreads %d",
5757
nohash=True,
5858
),
59+
out_bval=dict(
60+
extensions=None,
61+
),
62+
out_bvec=dict(
63+
argstr="-export_grad_fsl %s %s",
64+
extensions=None,
65+
),
5966
out_file=dict(
6067
argstr="%s",
6168
extensions=None,

nipype/interfaces/mrtrix3/tests/test_auto_EstimateFOD.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ def test_EstimateFOD_inputs():
8080
argstr="-nthreads %d",
8181
nohash=True,
8282
),
83+
out_bval=dict(
84+
extensions=None,
85+
),
86+
out_bvec=dict(
87+
argstr="-export_grad_fsl %s %s",
88+
extensions=None,
89+
),
8390
predicted_signal=dict(
8491
argstr="-predicted_signal %s",
8592
extensions=None,

nipype/interfaces/mrtrix3/tests/test_auto_FitTensor.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ def test_FitTensor_inputs():
4747
argstr="-nthreads %d",
4848
nohash=True,
4949
),
50+
out_bval=dict(
51+
extensions=None,
52+
),
53+
out_bvec=dict(
54+
argstr="-export_grad_fsl %s %s",
55+
extensions=None,
56+
),
5057
out_file=dict(
5158
argstr="%s",
5259
extensions=None,

nipype/interfaces/mrtrix3/tests/test_auto_Generate5tt.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ def test_Generate5tt_inputs():
4545
argstr="-nthreads %d",
4646
nohash=True,
4747
),
48+
out_bval=dict(
49+
extensions=None,
50+
),
51+
out_bvec=dict(
52+
argstr="-export_grad_fsl %s %s",
53+
extensions=None,
54+
),
4855
out_file=dict(
4956
argstr="%s",
5057
extensions=None,
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from ..utils import MRCat
3+
4+
5+
def test_MRCat_inputs():
6+
input_map = dict(
7+
args=dict(
8+
argstr="%s",
9+
),
10+
axis=dict(
11+
argstr="-axis %s",
12+
),
13+
bval_scale=dict(
14+
argstr="-bvalue_scaling %s",
15+
),
16+
datatype=dict(
17+
argstr="-datatype %s",
18+
),
19+
environ=dict(
20+
nohash=True,
21+
usedefault=True,
22+
),
23+
grad_file=dict(
24+
argstr="-grad %s",
25+
extensions=None,
26+
xor=["grad_fsl"],
27+
),
28+
grad_fsl=dict(
29+
argstr="-fslgrad %s %s",
30+
xor=["grad_file"],
31+
),
32+
in_bval=dict(
33+
extensions=None,
34+
),
35+
in_bvec=dict(
36+
argstr="-fslgrad %s %s",
37+
extensions=None,
38+
),
39+
in_files=dict(
40+
argstr="%s",
41+
mandatory=True,
42+
position=-2,
43+
),
44+
nthreads=dict(
45+
argstr="-nthreads %d",
46+
nohash=True,
47+
),
48+
out_bval=dict(
49+
extensions=None,
50+
),
51+
out_bvec=dict(
52+
argstr="-export_grad_fsl %s %s",
53+
extensions=None,
54+
),
55+
out_file=dict(
56+
argstr="%s",
57+
extensions=None,
58+
mandatory=True,
59+
position=-1,
60+
usedefault=True,
61+
),
62+
)
63+
inputs = MRCat.input_spec()
64+
65+
for key, metadata in list(input_map.items()):
66+
for metakey, value in list(metadata.items()):
67+
assert getattr(inputs.traits()[key], metakey) == value
68+
69+
70+
def test_MRCat_outputs():
71+
output_map = dict(
72+
out_file=dict(
73+
extensions=None,
74+
),
75+
)
76+
outputs = MRCat.output_spec()
77+
78+
for key, metadata in list(output_map.items()):
79+
for metakey, value in list(metadata.items()):
80+
assert getattr(outputs.traits()[key], metakey) == value

nipype/interfaces/mrtrix3/tests/test_auto_MRConvert.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,27 @@ def test_MRConvert_inputs():
4444
mandatory=True,
4545
position=-2,
4646
),
47+
json_export=dict(
48+
argstr="-json_export %s",
49+
extensions=None,
50+
mandatory=False,
51+
),
52+
json_import=dict(
53+
argstr="-json_import %s",
54+
extensions=None,
55+
mandatory=False,
56+
),
4757
nthreads=dict(
4858
argstr="-nthreads %d",
4959
nohash=True,
5060
),
61+
out_bval=dict(
62+
extensions=None,
63+
),
64+
out_bvec=dict(
65+
argstr="-export_grad_fsl %s %s",
66+
extensions=None,
67+
),
5168
out_file=dict(
5269
argstr="%s",
5370
extensions=None,
@@ -73,6 +90,15 @@ def test_MRConvert_inputs():
7390

7491
def test_MRConvert_outputs():
7592
output_map = dict(
93+
json_export=dict(
94+
extensions=None,
95+
),
96+
out_bval=dict(
97+
extensions=None,
98+
),
99+
out_bvec=dict(
100+
extensions=None,
101+
),
76102
out_file=dict(
77103
extensions=None,
78104
),

nipype/interfaces/mrtrix3/tests/test_auto_MRDeGibbs.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ def test_MRDeGibbs_inputs():
5959
argstr="-nthreads %d",
6060
nohash=True,
6161
),
62+
out_bval=dict(
63+
extensions=None,
64+
),
65+
out_bvec=dict(
66+
argstr="-export_grad_fsl %s %s",
67+
extensions=None,
68+
),
6269
out_file=dict(
6370
argstr="%s",
6471
extensions=None,

nipype/interfaces/mrtrix3/tests/test_auto_MRMath.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ def test_MRMath_inputs():
4848
mandatory=True,
4949
position=-2,
5050
),
51+
out_bval=dict(
52+
extensions=None,
53+
),
54+
out_bvec=dict(
55+
argstr="-export_grad_fsl %s %s",
56+
extensions=None,
57+
),
5158
out_file=dict(
5259
argstr="%s",
5360
extensions=None,

nipype/interfaces/mrtrix3/tests/test_auto_MRResize.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ def test_MRResize_inputs():
4949
argstr="-nthreads %d",
5050
nohash=True,
5151
),
52+
out_bval=dict(
53+
extensions=None,
54+
),
55+
out_bvec=dict(
56+
argstr="-export_grad_fsl %s %s",
57+
extensions=None,
58+
),
5259
out_file=dict(
5360
argstr="%s",
5461
extensions=None,

0 commit comments

Comments
 (0)