diff --git a/CHANGES b/CHANGES index cbb66efb31..07f14fd23a 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,7 @@ Release 0.9.2 (January 8, 2014) * FIX: DataFinder was broken due to a typo * FIX: Order of DataFinder outputs was not guaranteed, it's human sorted now +* ENH: New interfaces: Vnifti2Image, VtoMat Release 0.9.1 (December 25, 2013) ============ diff --git a/nipype/interfaces/vista/__init__.py b/nipype/interfaces/vista/__init__.py new file mode 100644 index 0000000000..755a98ae4a --- /dev/null +++ b/nipype/interfaces/vista/__init__.py @@ -0,0 +1,3 @@ +# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- +# vi: set ft=python sts=4 ts=4 sw=4 et: +from .vista import (Vnifti2Image, VtoMat) \ No newline at end of file diff --git a/nipype/interfaces/vista/tests/test_auto_Vnifti2Image.py b/nipype/interfaces/vista/tests/test_auto_Vnifti2Image.py new file mode 100644 index 0000000000..41cc589002 --- /dev/null +++ b/nipype/interfaces/vista/tests/test_auto_Vnifti2Image.py @@ -0,0 +1,44 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from nipype.testing import assert_equal +from nipype.interfaces.vista.vista import Vnifti2Image +def test_Vnifti2Image_inputs(): + input_map = dict(ignore_exception=dict(nohash=True, + usedefault=True, + ), + out_file=dict(hash_files=False, + name_template='%s.v', + name_source=['in_file'], + keep_extension=False, + position=-1, + argstr='-out %s', + ), + args=dict(argstr='%s', + ), + terminal_output=dict(nohash=True, + mandatory=True, + ), + environ=dict(nohash=True, + usedefault=True, + ), + in_file=dict(position=1, + mandatory=True, + argstr='-in %s', + ), + attributes=dict(position=2, + mandatory=False, + argstr='-attr %s', + ), + ) + inputs = Vnifti2Image.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_Vnifti2Image_outputs(): + output_map = dict(out_file=dict(), + ) + outputs = Vnifti2Image.output_spec() + + for key, metadata in output_map.items(): + for metakey, value in metadata.items(): + yield assert_equal, getattr(outputs.traits()[key], metakey), value diff --git a/nipype/interfaces/vista/tests/test_auto_VtoMat.py b/nipype/interfaces/vista/tests/test_auto_VtoMat.py new file mode 100644 index 0000000000..3f6538c201 --- /dev/null +++ b/nipype/interfaces/vista/tests/test_auto_VtoMat.py @@ -0,0 +1,40 @@ +# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT +from nipype.testing import assert_equal +from nipype.interfaces.vista.vista import VtoMat +def test_VtoMat_inputs(): + input_map = dict(ignore_exception=dict(nohash=True, + usedefault=True, + ), + out_file=dict(hash_files=False, + name_template='%s.mat', + name_source=['in_file'], + keep_extension=False, + position=-1, + argstr='-out %s', + ), + args=dict(argstr='%s', + ), + terminal_output=dict(nohash=True, + mandatory=True, + ), + environ=dict(nohash=True, + usedefault=True, + ), + in_file=dict(position=1, + mandatory=True, + argstr='-in %s', + ), + ) + inputs = VtoMat.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_VtoMat_outputs(): + output_map = dict(out_file=dict(), + ) + outputs = VtoMat.output_spec() + + for key, metadata in output_map.items(): + for metakey, value in metadata.items(): + yield assert_equal, getattr(outputs.traits()[key], metakey), value diff --git a/nipype/interfaces/vista/vista.py b/nipype/interfaces/vista/vista.py new file mode 100644 index 0000000000..3afc044932 --- /dev/null +++ b/nipype/interfaces/vista/vista.py @@ -0,0 +1,70 @@ +# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- +# vi: set ft=python sts=4 ts=4 sw=4 et: +""" + Change directory to provide relative paths for doctests + >>> import os + >>> filepath = os.path.dirname( os.path.realpath( __file__ ) ) + >>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data')) + >>> os.chdir(datadir) + +""" + +from nipype.interfaces.base import CommandLineInputSpec, CommandLine, traits, TraitedSpec, File +from nipype.utils.filemanip import split_filename +import os, os.path as op +from nipype.interfaces.traits_extension import isdefined + +class Vnifti2ImageInputSpec(CommandLineInputSpec): + in_file = File(exists=True, argstr='-in %s', mandatory=True, position=1, desc='in file') + attributes = File(exists=True, argstr='-attr %s', mandatory=False, position=2, desc='attribute file') + out_file = File(name_template="%s.v", keep_extension=False, argstr='-out %s', hash_files=False, + position= -1, desc='output data file', name_source=["in_file"]) + +class Vnifti2ImageOutputSpec(TraitedSpec): + out_file = File(exists=True, desc='Output vista file') + +class Vnifti2Image(CommandLine): + """ + Convert a nifti file into a vista file. + + Example + ------- + + >>> vimage = Vnifti2Image() + >>> vimage.inputs.in_file = 'image.nii' + >>> vimage.cmdline + 'vnifti2image -in image.nii -out image.v' + >>> vimage.run() # doctest: +SKIP + """ + + _cmd = 'vnifti2image' + input_spec=Vnifti2ImageInputSpec + output_spec=Vnifti2ImageOutputSpec + + +class VtoMatInputSpec(CommandLineInputSpec): + in_file = File(exists=True, argstr='-in %s', mandatory=True, position=1, desc='in file') + out_file = File(name_template="%s.mat", keep_extension=False, argstr='-out %s', hash_files=False, + position= -1, desc='output mat file', name_source=["in_file"]) + +class VtoMatOutputSpec(TraitedSpec): + out_file = File(exists=True, desc='Output mat file') + +class VtoMat(CommandLine): + """ + Convert a nifti file into a vista file. + + Example + ------- + + >>> vimage = VtoMat() + >>> vimage.inputs.in_file = 'image.v' + >>> vimage.cmdline + 'vtomat -in image.v -out image.mat' + >>> vimage.run() # doctest: +SKIP + """ + + _cmd = 'vtomat' + input_spec=VtoMatInputSpec + output_spec=VtoMatOutputSpec + diff --git a/nipype/testing/data/image.nii b/nipype/testing/data/image.nii new file mode 100644 index 0000000000..e69de29bb2 diff --git a/nipype/testing/data/image.v b/nipype/testing/data/image.v new file mode 100644 index 0000000000..e69de29bb2