Skip to content
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

ENH: tcksift2 #3668

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
50 changes: 50 additions & 0 deletions nipype/interfaces/mrtrix3/tests/test_auto_TckSift2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
from ..utils import TckSift2


def test_TckSift2_inputs():
input_map = dict(
args=dict(
argstr="%s",
),
environ=dict(
nohash=True,
usedefault=True,
),
in_file=dict(
argstr="%s",
extensions=None,
mandatory=True,
position=-3,
),
in_fod=dict(
argstr="%s",
extensions=None,
mandatory=True,
position=-2,
),
out_weights=dict(
argstr="%s",
extensions=None,
mandatory=True,
position=-1,
),
)
inputs = TckSift2.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_TckSift2_outputs():
output_map = dict(
out_weights=dict(
extensions=None,
),
)
outputs = TckSift2.output_spec()

for key, metadata in list(output_map.items()):
for metakey, value in list(metadata.items()):
assert getattr(outputs.traits()[key], metakey) == value
38 changes: 37 additions & 1 deletion nipype/interfaces/mrtrix3/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
# -*- coding: utf-8 -*-

import os.path as op

from ...utils.filemanip import split_filename
Expand All @@ -19,6 +18,43 @@
from .base import MRTrix3BaseInputSpec, MRTrix3Base


class TckSift2InputSpec(CommandLineInputSpec):
in_file = File(exists=True, argstr="%s", mandatory=True, position=-3, desc="input streamlines file")
in_fod = File(exists=True, argstr="%s", mandatory=True, position=-2, desc="input FOD file")
out_weights = File(argstr="%s", mandatory=True, position=-1, desc="output weights file")


class TckSift2OutputSpec(TraitedSpec):
out_weights = File(exists=True, desc="output weights file")


class TckSift2(CommandLine):
"""
Interface for MRTrix's tcksift2 command

Example
-------

>>> import nipype.interfaces.mrtrix3 as mrt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this to work, this needs to be added to

from .utils import (
TCK2VTK,
BrainMask,
ComputeTDI,
DWIExtract,
Generate5tt,
Mesh2PVE,
MRCat,
MRConvert,
MRMath,
MRResize,
MRTransform,
SH2Amp,
SHConv,
TensorMetrics,
TransformFSLConvert,
MaskFilter,
MTNormalise,
Generate5tt2gmwmi,
)

>>> tcksift2 = mrt.TckSift2()
>>> tcksift2.inputs.in_file = 'streamlines.tck'
>>> tcksift2.inputs.in_fod = 'fod.mif'
>>> tcksift2.inputs.out_weights = 'streamlines_weights.txt'
>>> tcksift2.cmdline
'tcksift2 streamlines.tck fod.mif streamlines_weights.txt'
>>> tcksift2.run() # doctest: +SKIP
"""

_cmd = 'tcksift2'
input_spec = TckSift2InputSpec
output_spec = TckSift2OutputSpec

def _list_outputs(self):
outputs = self.output_spec().get()
outputs["out_weights"] = op.abspath(self.inputs.out_weights)
return outputs

Check warning on line 55 in nipype/interfaces/mrtrix3/utils.py

View check run for this annotation

Codecov / codecov/patch

nipype/interfaces/mrtrix3/utils.py#L53-L55

Added lines #L53 - L55 were not covered by tests


class BrainMaskInputSpec(MRTrix3BaseInputSpec):
in_file = File(
exists=True,
Expand Down
Loading