Skip to content

ENH: Add MRTrix3 interfaces (pared-down gh-3426) #3445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions nipype/interfaces/mrtrix3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,32 @@
# vi: set ft=python sts=4 ts=4 sw=4 et:
# -*- coding: utf-8 -*-
"""MRTrix3 provides software tools to perform various types of diffusion MRI analyses."""
from .connectivity import BuildConnectome, LabelConfig, LabelConvert
from .preprocess import (
ACTPrepareFSL,
DWIBiasCorrect,
DWIDenoise,
DWIPreproc,
MRDeGibbs,
ReplaceFSwithFIRST,
ResponseSD,
)
from .reconst import ConstrainedSphericalDeconvolution, EstimateFOD, FitTensor
from .tracking import Tractography
from .utils import (
Mesh2PVE,
Generate5tt,
TCK2VTK,
BrainMask,
TensorMetrics,
ComputeTDI,
TCK2VTK,
MRMath,
DWIExtract,
Generate5tt,
Mesh2PVE,
MRCat,
MRConvert,
MRMath,
MRResize,
DWIExtract,
SHConv,
MRTransform,
SH2Amp,
SHConv,
TensorMetrics,
TransformFSLConvert,
)
from .preprocess import (
ResponseSD,
ACTPrepareFSL,
ReplaceFSwithFIRST,
DWIPreproc,
DWIDenoise,
MRDeGibbs,
DWIBiasCorrect,
)
from .tracking import Tractography
from .reconst import FitTensor, EstimateFOD, ConstrainedSphericalDeconvolution
from .connectivity import LabelConfig, LabelConvert, BuildConnectome
11 changes: 11 additions & 0 deletions nipype/interfaces/mrtrix3/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ class MRTrix3BaseInputSpec(CommandLineInputSpec):
exists=True, argstr="-fslgrad %s %s", desc="bvecs file in FSL format"
)
in_bval = File(exists=True, desc="bvals file in FSL format")
out_bvec = File(
exists=False,
argstr="-export_grad_fsl %s %s",
desc="export bvec file in FSL format",
)
out_bval = File(
exists=False,
desc="export bval file in FSL format",
)


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

if name == "in_bvec":
return trait_spec.argstr % (value, self.inputs.in_bval)
if name == "out_bvec":
return trait_spec.argstr % (value, self.inputs.out_bval)

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

Expand Down
7 changes: 7 additions & 0 deletions nipype/interfaces/mrtrix3/tests/test_auto_BrainMask.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ def test_BrainMask_inputs():
argstr="-nthreads %d",
nohash=True,
),
out_bval=dict(
extensions=None,
),
out_bvec=dict(
argstr="-export_grad_fsl %s %s",
extensions=None,
),
out_file=dict(
argstr="%s",
extensions=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ def test_ConstrainedSphericalDeconvolution_inputs():
argstr="-nthreads %d",
nohash=True,
),
out_bval=dict(
extensions=None,
),
out_bvec=dict(
argstr="-export_grad_fsl %s %s",
extensions=None,
),
predicted_signal=dict(
argstr="-predicted_signal %s",
extensions=None,
Expand Down
7 changes: 7 additions & 0 deletions nipype/interfaces/mrtrix3/tests/test_auto_DWIBiasCorrect.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ def test_DWIBiasCorrect_inputs():
argstr="-nthreads %d",
nohash=True,
),
out_bval=dict(
extensions=None,
),
out_bvec=dict(
argstr="-export_grad_fsl %s %s",
extensions=None,
),
out_file=dict(
argstr="%s",
extensions=None,
Expand Down
7 changes: 7 additions & 0 deletions nipype/interfaces/mrtrix3/tests/test_auto_DWIDenoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ def test_DWIDenoise_inputs():
argstr="-nthreads %d",
nohash=True,
),
out_bval=dict(
extensions=None,
),
out_bvec=dict(
argstr="-export_grad_fsl %s %s",
extensions=None,
),
out_file=dict(
argstr="%s",
extensions=None,
Expand Down
7 changes: 7 additions & 0 deletions nipype/interfaces/mrtrix3/tests/test_auto_DWIExtract.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ def test_DWIExtract_inputs():
argstr="-nthreads %d",
nohash=True,
),
out_bval=dict(
extensions=None,
),
out_bvec=dict(
argstr="-export_grad_fsl %s %s",
extensions=None,
),
out_file=dict(
argstr="%s",
extensions=None,
Expand Down
7 changes: 7 additions & 0 deletions nipype/interfaces/mrtrix3/tests/test_auto_DWIPreproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ def test_DWIPreproc_inputs():
argstr="-nthreads %d",
nohash=True,
),
out_bval=dict(
extensions=None,
),
out_bvec=dict(
argstr="-export_grad_fsl %s %s",
extensions=None,
),
out_file=dict(
argstr="%s",
extensions=None,
Expand Down
7 changes: 7 additions & 0 deletions nipype/interfaces/mrtrix3/tests/test_auto_EstimateFOD.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ def test_EstimateFOD_inputs():
argstr="-nthreads %d",
nohash=True,
),
out_bval=dict(
extensions=None,
),
out_bvec=dict(
argstr="-export_grad_fsl %s %s",
extensions=None,
),
predicted_signal=dict(
argstr="-predicted_signal %s",
extensions=None,
Expand Down
7 changes: 7 additions & 0 deletions nipype/interfaces/mrtrix3/tests/test_auto_FitTensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ def test_FitTensor_inputs():
argstr="-nthreads %d",
nohash=True,
),
out_bval=dict(
extensions=None,
),
out_bvec=dict(
argstr="-export_grad_fsl %s %s",
extensions=None,
),
out_file=dict(
argstr="%s",
extensions=None,
Expand Down
7 changes: 7 additions & 0 deletions nipype/interfaces/mrtrix3/tests/test_auto_Generate5tt.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ def test_Generate5tt_inputs():
argstr="-nthreads %d",
nohash=True,
),
out_bval=dict(
extensions=None,
),
out_bvec=dict(
argstr="-export_grad_fsl %s %s",
extensions=None,
),
out_file=dict(
argstr="%s",
extensions=None,
Expand Down
80 changes: 80 additions & 0 deletions nipype/interfaces/mrtrix3/tests/test_auto_MRCat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
from ..utils import MRCat


def test_MRCat_inputs():
input_map = dict(
args=dict(
argstr="%s",
),
axis=dict(
argstr="-axis %s",
),
bval_scale=dict(
argstr="-bvalue_scaling %s",
),
datatype=dict(
argstr="-datatype %s",
),
environ=dict(
nohash=True,
usedefault=True,
),
grad_file=dict(
argstr="-grad %s",
extensions=None,
xor=["grad_fsl"],
),
grad_fsl=dict(
argstr="-fslgrad %s %s",
xor=["grad_file"],
),
in_bval=dict(
extensions=None,
),
in_bvec=dict(
argstr="-fslgrad %s %s",
extensions=None,
),
in_files=dict(
argstr="%s",
mandatory=True,
position=-2,
),
nthreads=dict(
argstr="-nthreads %d",
nohash=True,
),
out_bval=dict(
extensions=None,
),
out_bvec=dict(
argstr="-export_grad_fsl %s %s",
extensions=None,
),
out_file=dict(
argstr="%s",
extensions=None,
mandatory=True,
position=-1,
usedefault=True,
),
)
inputs = MRCat.input_spec()

for key, metadata in list(input_map.items()):
for metakey, value in list(metadata.items()):
assert getattr(inputs.traits()[key], metakey) == value


def test_MRCat_outputs():
output_map = dict(
out_file=dict(
extensions=None,
),
)
outputs = MRCat.output_spec()

for key, metadata in list(output_map.items()):
for metakey, value in list(metadata.items()):
assert getattr(outputs.traits()[key], metakey) == value
26 changes: 26 additions & 0 deletions nipype/interfaces/mrtrix3/tests/test_auto_MRConvert.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,27 @@ def test_MRConvert_inputs():
mandatory=True,
position=-2,
),
json_export=dict(
argstr="-json_export %s",
extensions=None,
mandatory=False,
),
json_import=dict(
argstr="-json_import %s",
extensions=None,
mandatory=False,
),
nthreads=dict(
argstr="-nthreads %d",
nohash=True,
),
out_bval=dict(
extensions=None,
),
out_bvec=dict(
argstr="-export_grad_fsl %s %s",
extensions=None,
),
out_file=dict(
argstr="%s",
extensions=None,
Expand All @@ -73,6 +90,15 @@ def test_MRConvert_inputs():

def test_MRConvert_outputs():
output_map = dict(
json_export=dict(
extensions=None,
),
out_bval=dict(
extensions=None,
),
out_bvec=dict(
extensions=None,
),
out_file=dict(
extensions=None,
),
Expand Down
7 changes: 7 additions & 0 deletions nipype/interfaces/mrtrix3/tests/test_auto_MRDeGibbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ def test_MRDeGibbs_inputs():
argstr="-nthreads %d",
nohash=True,
),
out_bval=dict(
extensions=None,
),
out_bvec=dict(
argstr="-export_grad_fsl %s %s",
extensions=None,
),
out_file=dict(
argstr="%s",
extensions=None,
Expand Down
7 changes: 7 additions & 0 deletions nipype/interfaces/mrtrix3/tests/test_auto_MRMath.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ def test_MRMath_inputs():
mandatory=True,
position=-2,
),
out_bval=dict(
extensions=None,
),
out_bvec=dict(
argstr="-export_grad_fsl %s %s",
extensions=None,
),
out_file=dict(
argstr="%s",
extensions=None,
Expand Down
7 changes: 7 additions & 0 deletions nipype/interfaces/mrtrix3/tests/test_auto_MRResize.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ def test_MRResize_inputs():
argstr="-nthreads %d",
nohash=True,
),
out_bval=dict(
extensions=None,
),
out_bvec=dict(
argstr="-export_grad_fsl %s %s",
extensions=None,
),
out_file=dict(
argstr="%s",
extensions=None,
Expand Down
Loading