From 0749b1e6e48599fc7aadd12954758ab75a00860d Mon Sep 17 00:00:00 2001 From: Leonie Lampe Date: Wed, 15 Jun 2016 11:15:51 +0200 Subject: [PATCH 1/6] Update maths.py --- nipype/interfaces/fsl/maths.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nipype/interfaces/fsl/maths.py b/nipype/interfaces/fsl/maths.py index 1660d9612f..4fcaff5122 100644 --- a/nipype/interfaces/fsl/maths.py +++ b/nipype/interfaces/fsl/maths.py @@ -103,6 +103,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="-%sTstd", 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): From 9f491b56a3588bb074159cbf983b1bd6dcbe141b Mon Sep 17 00:00:00 2001 From: Leonie Lampe Date: Wed, 15 Jun 2016 11:42:44 +0200 Subject: [PATCH 2/6] Update maths.py --- nipype/interfaces/fsl/maths.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/fsl/maths.py b/nipype/interfaces/fsl/maths.py index 4fcaff5122..c5afb95ccc 100644 --- a/nipype/interfaces/fsl/maths.py +++ b/nipype/interfaces/fsl/maths.py @@ -105,7 +105,7 @@ def _format_arg(self, name, spec, value): class StdImageInput(MathsInput): - dimension = traits.Enum("T", "X", "Y", "Z", usedefault=True, argstr="-%sTstd", position=4, + dimension = traits.Enum("T", "X", "Y", "Z", usedefault=True, argstr="-%sstd", position=4, desc="dimension to standard deviate across") From 6b16b364f679d2325a122f3d210f67afcc2b9c42 Mon Sep 17 00:00:00 2001 From: Leonie Lampe Date: Thu, 16 Jun 2016 10:53:00 +0200 Subject: [PATCH 3/6] Update maths.py --- nipype/interfaces/fsl/maths.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nipype/interfaces/fsl/maths.py b/nipype/interfaces/fsl/maths.py index c5afb95ccc..27c143e51d 100644 --- a/nipype/interfaces/fsl/maths.py +++ b/nipype/interfaces/fsl/maths.py @@ -113,7 +113,7 @@ class StdImage(MathsCommand): """Use fslmaths to generate a standard deviation in an image across a given dimension. """ input_spec = StdImageInput -_suffix = "_std" + _suffix = "_std" class MeanImageInput(MathsInput): From 4a62f9c8137da95e5f4e775da27d7b5614c24ce5 Mon Sep 17 00:00:00 2001 From: Leonie Lampe Date: Fri, 17 Jun 2016 20:35:01 +0200 Subject: [PATCH 4/6] Update test_maths.py --- nipype/interfaces/fsl/tests/test_maths.py | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/nipype/interfaces/fsl/tests/test_maths.py b/nipype/interfaces/fsl/tests/test_maths.py index 045f0ef1d2..429633b907 100644 --- a/nipype/interfaces/fsl/tests/test_maths.py +++ b/nipype/interfaces/fsl/tests/test_maths.py @@ -168,6 +168,32 @@ def test_meanimage(): # Clean up our mess clean_directory(testdir, origdir, ftype) + + @skipif(no_fsl) +def test_stdimage(): + files, testdir, origdir, ftype = 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, ftype) @skipif(no_fsl) def test_maximage(): From e2a60834dafa79015bdaf739f061f09b918f461a Mon Sep 17 00:00:00 2001 From: Satrajit Ghosh Date: Sat, 18 Jun 2016 01:04:01 -0400 Subject: [PATCH 5/6] fix: add auto-test --- .../fsl/tests/test_auto_StdImage.py | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 nipype/interfaces/fsl/tests/test_auto_StdImage.py diff --git a/nipype/interfaces/fsl/tests/test_auto_StdImage.py b/nipype/interfaces/fsl/tests/test_auto_StdImage.py new file mode 100644 index 0000000000..aeafb64667 --- /dev/null +++ b/nipype/interfaces/fsl/tests/test_auto_StdImage.py @@ -0,0 +1,54 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from nipype.testing import assert_equal +from nipype.interfaces.fsl.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 input_map.items(): + for metakey, value in 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 output_map.items(): + for metakey, value in metadata.items(): + yield assert_equal, getattr(outputs.traits()[key], metakey), value + From 09082af6351a44f2d94915c5774495550af7bc0c Mon Sep 17 00:00:00 2001 From: Satrajit Ghosh Date: Sat, 18 Jun 2016 01:30:06 -0400 Subject: [PATCH 6/6] added tests --- nipype/interfaces/fsl/tests/test_auto_StdImage.py | 15 ++++++++------- nipype/interfaces/fsl/tests/test_maths.py | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/nipype/interfaces/fsl/tests/test_auto_StdImage.py b/nipype/interfaces/fsl/tests/test_auto_StdImage.py index aeafb64667..32ede13cd5 100644 --- a/nipype/interfaces/fsl/tests/test_auto_StdImage.py +++ b/nipype/interfaces/fsl/tests/test_auto_StdImage.py @@ -1,6 +1,7 @@ # AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT -from nipype.testing import assert_equal -from nipype.interfaces.fsl.maths import StdImage +from ....testing import assert_equal +from ..maths import StdImage + def test_StdImage_inputs(): input_map = dict(args=dict(argstr='%s', @@ -39,16 +40,16 @@ def test_StdImage_inputs(): ) inputs = StdImage.input_spec() - for key, metadata in input_map.items(): - for metakey, value in metadata.items(): + 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 output_map.items(): - for metakey, value in metadata.items(): + for key, metadata in list(output_map.items()): + for metakey, value in list(metadata.items()): yield assert_equal, getattr(outputs.traits()[key], metakey), value - diff --git a/nipype/interfaces/fsl/tests/test_maths.py b/nipype/interfaces/fsl/tests/test_maths.py index 79d89cda78..74189e2c10 100644 --- a/nipype/interfaces/fsl/tests/test_maths.py +++ b/nipype/interfaces/fsl/tests/test_maths.py @@ -191,11 +191,11 @@ def test_meanimage(fsl_output_type=None): yield assert_equal, meaner.cmdline, "fslmaths a.nii -Tmean %s" % os.path.join(testdir, "a_mean%s" % out_ext) # Clean up our mess - clean_directory(testdir, origdir, ftype) + clean_directory(testdir, origdir) set_output_type(prev_type) @skipif(no_fsl) -def test_stdimage(): +def test_stdimage(fsl_output_type=None): prev_type = set_output_type(fsl_output_type) files, testdir, origdir, out_ext = create_files_in_directory()