From a83aef0cb54304c37d4a137f5e567d20c1866f26 Mon Sep 17 00:00:00 2001 From: shachafy Date: Wed, 28 Aug 2024 23:37:01 +0300 Subject: [PATCH 1/3] feat: tcksift2 --- nipype/interfaces/mrtrix3/utils.py | 38 +++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/nipype/interfaces/mrtrix3/utils.py b/nipype/interfaces/mrtrix3/utils.py index 8a69232ecd..4dcef14629 100644 --- a/nipype/interfaces/mrtrix3/utils.py +++ b/nipype/interfaces/mrtrix3/utils.py @@ -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 @@ -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 + >>> tcksift2 = mrt.TckSift2() + >>> tcksift2.inputs.in_file = 'streamlines.tck' + >>> tcksift2.inputs.in_fod = 'fod.mif' + >>> tcksift2.inputs.out_weights = 'streamlines_weights.txt' + >>> tcksift2.cmdline # doctest: +ELLIPSIS + '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 + + class BrainMaskInputSpec(MRTrix3BaseInputSpec): in_file = File( exists=True, From 45618bc7a83f7beb1e78ff522e3a2247aa8fba0c Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Sun, 6 Oct 2024 12:01:31 -0400 Subject: [PATCH 2/3] make specs --- .../mrtrix3/tests/test_auto_TckSift2.py | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 nipype/interfaces/mrtrix3/tests/test_auto_TckSift2.py diff --git a/nipype/interfaces/mrtrix3/tests/test_auto_TckSift2.py b/nipype/interfaces/mrtrix3/tests/test_auto_TckSift2.py new file mode 100644 index 0000000000..7ee92fa257 --- /dev/null +++ b/nipype/interfaces/mrtrix3/tests/test_auto_TckSift2.py @@ -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 From a49f154b21a09f7ce19e5d48c4eada3506343f7d Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Sun, 6 Oct 2024 12:02:11 -0400 Subject: [PATCH 3/3] Update nipype/interfaces/mrtrix3/utils.py --- nipype/interfaces/mrtrix3/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/mrtrix3/utils.py b/nipype/interfaces/mrtrix3/utils.py index 4dcef14629..0a71e9c8f9 100644 --- a/nipype/interfaces/mrtrix3/utils.py +++ b/nipype/interfaces/mrtrix3/utils.py @@ -40,7 +40,7 @@ class TckSift2(CommandLine): >>> tcksift2.inputs.in_file = 'streamlines.tck' >>> tcksift2.inputs.in_fod = 'fod.mif' >>> tcksift2.inputs.out_weights = 'streamlines_weights.txt' - >>> tcksift2.cmdline # doctest: +ELLIPSIS + >>> tcksift2.cmdline 'tcksift2 streamlines.tck fod.mif streamlines_weights.txt' >>> tcksift2.run() # doctest: +SKIP """