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] Add Text2Vest and Vest2Text interfaces #3447

Merged
merged 5 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions nipype/interfaces/fsl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
RobustFOV,
CopyGeom,
MotionOutliers,
Text2Vest,
Vest2Text,
)

from .epi import (
Expand Down
45 changes: 45 additions & 0 deletions nipype/interfaces/fsl/tests/test_auto_Text2Vest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
from ..utils import Text2Vest


def test_Text2Vest_inputs():
input_map = dict(
args=dict(
argstr="%s",
),
environ=dict(
nohash=True,
usedefault=True,
),
in_file=dict(
argstr="%s",
extensions=None,
mandatory=True,
position=0,
),
out_file=dict(
argstr="%s",
extensions=None,
mandatory=True,
position=1,
),
output_type=dict(),
)
inputs = Text2Vest.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_Text2Vest_outputs():
output_map = dict(
out_file=dict(
extensions=None,
),
)
outputs = Text2Vest.output_spec()

for key, metadata in list(output_map.items()):
for metakey, value in list(metadata.items()):
assert getattr(outputs.traits()[key], metakey) == value
45 changes: 45 additions & 0 deletions nipype/interfaces/fsl/tests/test_auto_Vest2Text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
from ..utils import Vest2Text


def test_Vest2Text_inputs():
input_map = dict(
args=dict(
argstr="%s",
),
environ=dict(
nohash=True,
usedefault=True,
),
in_file=dict(
argstr="%s",
extensions=None,
mandatory=True,
position=0,
),
out_file=dict(
argstr="%s",
extensions=None,
mandatory=True,
position=1,
),
output_type=dict(),
)
inputs = Vest2Text.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_Vest2Text_outputs():
output_map = dict(
out_file=dict(
extensions=None,
),
)
outputs = Vest2Text.output_spec()

for key, metadata in list(output_map.items()):
for metakey, value in list(metadata.items()):
assert getattr(outputs.traits()[key], metakey) == value
87 changes: 87 additions & 0 deletions nipype/interfaces/fsl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2834,3 +2834,90 @@ class MotionOutliers(FSLCommand):
input_spec = MotionOutliersInputSpec
output_spec = MotionOutliersOutputSpec
_cmd = "fsl_motion_outliers"


class Text2VestInputSpec(FSLCommandInputSpec):
in_file = File(
exists=True,
mandatory=True,
desc="plain text file representing your design, contrast, or f-test matrix",
argstr="%s",
position=0,
)

out_file = File(
mandatory=True,
desc=(
"file name to store matrix data in the format used by FSL tools"
" (e.g., design.mat, design.con design.fts)"
),
argstr="%s",
position=1,
)


class Text2VestOutputSpec(TraitedSpec):
out_file = File(exists=True, desc="matrix data in the format used by FSL tools")


class Text2Vest(FSLCommand):
"""
Use FSL Text2Vest`https://web.mit.edu/fsl_v5.0.10/fsl/doc/wiki/GLM(2f)CreatingDesignMatricesByHand.html`_
to convert your plain text design matrix data into the format used by the FSL tools.
Examples
--------
>>> from nipype.interfaces.fsl import Text2Vest
>>> t2v = Text2Vest()
>>> t2v.inputs.in_file = "design.txt"
>>> t2v.inputs.out_file = "design.mat"
>>> t2v.cmdline # doctest: +ELLIPSIS
'Text2Vest design.txt design.mat'
>>> res = t2v.run() # doctest: +SKIP
"""

input_spec = Text2VestInputSpec
output_spec = Text2VestOutputSpec

_cmd = "Text2Vest"


class Vest2TextInputSpec(FSLCommandInputSpec):
in_file = File(
exists=True,
mandatory=True,
desc="matrix data stored in the format used by FSL tools",
argstr="%s",
position=0,
)

out_file = File(
mandatory=True,
desc="file name to store text output from matrix",
argstr="%s",
position=1,
)


class Vest2TextOutputSpec(TraitedSpec):
out_file = File(exists=True, desc="plain text representation of FSL matrix")


class Vest2Text(FSLCommand):
"""
Use FSL Vest2Text`https://web.mit.edu/fsl_v5.0.10/fsl/doc/wiki/GLM(2f)CreatingDesignMatricesByHand.html`_
to convert your design.mat design.con and design.fts files into plain text.
Examples
--------
>>> from nipype.interfaces.fsl import Vest2Text
>>> v2t = Vest2Text()
>>> v2t.inputs.in_file = "design.mat"
>>> v2t.inputs.out_file = "design.txt"
>>> v2t.cmdline # doctest: +ELLIPSIS
'Vest2Text design.mat design.txt'
>>> res = v2t.run() # doctest: +SKIP
"""

input_spec = Vest2TextInputSpec
output_spec = Vest2TextOutputSpec

_cmd = "Vest2Text"
6 changes: 6 additions & 0 deletions nipype/testing/data/design.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/NumWaves 3
/NumPoints 3
/Matrix
0 0 0
0 0 0
0 0 0
3 changes: 3 additions & 0 deletions nipype/testing/data/design.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
0 0 0
0 0 0
0 0 0