Skip to content

Enh/newvistainterfaces #760

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

Merged
merged 5 commits into from
Jan 31, 2014
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
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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)
============
Expand Down
3 changes: 3 additions & 0 deletions nipype/interfaces/vista/__init__.py
Original file line number Diff line number Diff line change
@@ -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)
44 changes: 44 additions & 0 deletions nipype/interfaces/vista/tests/test_auto_Vnifti2Image.py
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions nipype/interfaces/vista/tests/test_auto_VtoMat.py
Original file line number Diff line number Diff line change
@@ -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
70 changes: 70 additions & 0 deletions nipype/interfaces/vista/vista.py
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we display the command line here? and for the next interface?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added them :)

"""

_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

Empty file added nipype/testing/data/image.nii
Empty file.
Empty file added nipype/testing/data/image.v
Empty file.