Skip to content
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
11 changes: 11 additions & 0 deletions nipype/interfaces/fsl/maths.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,17 @@ def _format_arg(self, name, spec, value):
return arg
return super(Threshold, self)._format_arg(name, spec, value)

class StdImageInput(MathsInput):

dimension = traits.Enum("T", "X", "Y", "Z", usedefault=True, argstr="-%sstd", position=4,
desc="dimension to standard deviate across")


class StdImage(MathsCommand):
"""Use fslmaths to generate a standard deviation in an image across a given dimension.
"""
input_spec = StdImageInput
_suffix = "_std"

class MeanImageInput(MathsInput):

Expand Down
55 changes: 55 additions & 0 deletions nipype/interfaces/fsl/tests/test_auto_StdImage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
from ....testing import assert_equal
from ..maths import StdImage


def test_StdImage_inputs():
input_map = dict(args=dict(argstr='%s',
),
dimension=dict(argstr='-%sstd',
position=4,
usedefault=True,
),
environ=dict(nohash=True,
usedefault=True,
),
ignore_exception=dict(nohash=True,
usedefault=True,
),
in_file=dict(argstr='%s',
mandatory=True,
position=2,
),
internal_datatype=dict(argstr='-dt %s',
position=1,
),
nan2zeros=dict(argstr='-nan',
position=3,
),
out_file=dict(argstr='%s',
genfile=True,
hash_files=False,
position=-2,
),
output_datatype=dict(argstr='-odt %s',
position=-1,
),
output_type=dict(),
terminal_output=dict(nohash=True,
),
)
inputs = StdImage.input_spec()

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


def test_StdImage_outputs():
output_map = dict(out_file=dict(),
)
outputs = StdImage.output_spec()

for key, metadata in list(output_map.items()):
for metakey, value in list(metadata.items()):
yield assert_equal, getattr(outputs.traits()[key], metakey), value
27 changes: 27 additions & 0 deletions nipype/interfaces/fsl/tests/test_maths.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,33 @@ def test_meanimage(fsl_output_type=None):
clean_directory(testdir, origdir)
set_output_type(prev_type)

@skipif(no_fsl)
def test_stdimage(fsl_output_type=None):
prev_type = set_output_type(fsl_output_type)
files, testdir, origdir, out_ext = create_files_in_directory()

# Get the command
stder = fsl.StdImage(in_file="a.nii",out_file="b.nii")

# Test the underlying command
yield assert_equal, stder.cmd, "fslmaths"

# Test the defualt opstring
yield assert_equal, stder.cmdline, "fslmaths a.nii -Tstd b.nii"

# Test the other dimensions
cmdline = "fslmaths a.nii -%sstd b.nii"
for dim in ["X","Y","Z","T"]:
stder.inputs.dimension=dim
yield assert_equal, stder.cmdline, cmdline%dim

# Test the auto naming
stder = fsl.StdImage(in_file="a.nii")
yield assert_equal, stder.cmdline, "fslmaths a.nii -Tstd %s"%os.path.join(testdir, "a_std.nii")

# Clean up our mess
clean_directory(testdir, origdir)
set_output_type(prev_type)

@skipif(no_fsl)
def test_maximage(fsl_output_type=None):
Expand Down