Skip to content

Commit 0f1d095

Browse files
committed
Merge pull request #760 from dmordom/enh/newvistainterfaces
Enh/newvistainterfaces
2 parents a281843 + ae34805 commit 0f1d095

File tree

7 files changed

+158
-0
lines changed

7 files changed

+158
-0
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Future Release
33

44
* FIX: DataFinder was broken due to a typo
55
* FIX: Order of DataFinder outputs was not guaranteed, it's human sorted now
6+
* ENH: New interfaces: Vnifti2Image, VtoMat
67

78
Release 0.9.1 (December 25, 2013)
89
============

nipype/interfaces/vista/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
2+
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
from .vista import (Vnifti2Image, VtoMat)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from nipype.testing import assert_equal
3+
from nipype.interfaces.vista.vista import Vnifti2Image
4+
def test_Vnifti2Image_inputs():
5+
input_map = dict(ignore_exception=dict(nohash=True,
6+
usedefault=True,
7+
),
8+
out_file=dict(hash_files=False,
9+
name_template='%s.v',
10+
name_source=['in_file'],
11+
keep_extension=False,
12+
position=-1,
13+
argstr='-out %s',
14+
),
15+
args=dict(argstr='%s',
16+
),
17+
terminal_output=dict(nohash=True,
18+
mandatory=True,
19+
),
20+
environ=dict(nohash=True,
21+
usedefault=True,
22+
),
23+
in_file=dict(position=1,
24+
mandatory=True,
25+
argstr='-in %s',
26+
),
27+
attributes=dict(position=2,
28+
mandatory=False,
29+
argstr='-attr %s',
30+
),
31+
)
32+
inputs = Vnifti2Image.input_spec()
33+
34+
for key, metadata in input_map.items():
35+
for metakey, value in metadata.items():
36+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
37+
def test_Vnifti2Image_outputs():
38+
output_map = dict(out_file=dict(),
39+
)
40+
outputs = Vnifti2Image.output_spec()
41+
42+
for key, metadata in output_map.items():
43+
for metakey, value in metadata.items():
44+
yield assert_equal, getattr(outputs.traits()[key], metakey), value
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from nipype.testing import assert_equal
3+
from nipype.interfaces.vista.vista import VtoMat
4+
def test_VtoMat_inputs():
5+
input_map = dict(ignore_exception=dict(nohash=True,
6+
usedefault=True,
7+
),
8+
out_file=dict(hash_files=False,
9+
name_template='%s.mat',
10+
name_source=['in_file'],
11+
keep_extension=False,
12+
position=-1,
13+
argstr='-out %s',
14+
),
15+
args=dict(argstr='%s',
16+
),
17+
terminal_output=dict(nohash=True,
18+
mandatory=True,
19+
),
20+
environ=dict(nohash=True,
21+
usedefault=True,
22+
),
23+
in_file=dict(position=1,
24+
mandatory=True,
25+
argstr='-in %s',
26+
),
27+
)
28+
inputs = VtoMat.input_spec()
29+
30+
for key, metadata in input_map.items():
31+
for metakey, value in metadata.items():
32+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
33+
def test_VtoMat_outputs():
34+
output_map = dict(out_file=dict(),
35+
)
36+
outputs = VtoMat.output_spec()
37+
38+
for key, metadata in output_map.items():
39+
for metakey, value in metadata.items():
40+
yield assert_equal, getattr(outputs.traits()[key], metakey), value

nipype/interfaces/vista/vista.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
2+
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
"""
4+
Change directory to provide relative paths for doctests
5+
>>> import os
6+
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
7+
>>> datadir = os.path.realpath(os.path.join(filepath, '../../testing/data'))
8+
>>> os.chdir(datadir)
9+
10+
"""
11+
12+
from nipype.interfaces.base import CommandLineInputSpec, CommandLine, traits, TraitedSpec, File
13+
from nipype.utils.filemanip import split_filename
14+
import os, os.path as op
15+
from nipype.interfaces.traits_extension import isdefined
16+
17+
class Vnifti2ImageInputSpec(CommandLineInputSpec):
18+
in_file = File(exists=True, argstr='-in %s', mandatory=True, position=1, desc='in file')
19+
attributes = File(exists=True, argstr='-attr %s', mandatory=False, position=2, desc='attribute file')
20+
out_file = File(name_template="%s.v", keep_extension=False, argstr='-out %s', hash_files=False,
21+
position= -1, desc='output data file', name_source=["in_file"])
22+
23+
class Vnifti2ImageOutputSpec(TraitedSpec):
24+
out_file = File(exists=True, desc='Output vista file')
25+
26+
class Vnifti2Image(CommandLine):
27+
"""
28+
Convert a nifti file into a vista file.
29+
30+
Example
31+
-------
32+
33+
>>> vimage = Vnifti2Image()
34+
>>> vimage.inputs.in_file = 'image.nii'
35+
>>> vimage.cmdline
36+
'vnifti2image -in image.nii -out image.v'
37+
>>> vimage.run() # doctest: +SKIP
38+
"""
39+
40+
_cmd = 'vnifti2image'
41+
input_spec=Vnifti2ImageInputSpec
42+
output_spec=Vnifti2ImageOutputSpec
43+
44+
45+
class VtoMatInputSpec(CommandLineInputSpec):
46+
in_file = File(exists=True, argstr='-in %s', mandatory=True, position=1, desc='in file')
47+
out_file = File(name_template="%s.mat", keep_extension=False, argstr='-out %s', hash_files=False,
48+
position= -1, desc='output mat file', name_source=["in_file"])
49+
50+
class VtoMatOutputSpec(TraitedSpec):
51+
out_file = File(exists=True, desc='Output mat file')
52+
53+
class VtoMat(CommandLine):
54+
"""
55+
Convert a nifti file into a vista file.
56+
57+
Example
58+
-------
59+
60+
>>> vimage = VtoMat()
61+
>>> vimage.inputs.in_file = 'image.v'
62+
>>> vimage.cmdline
63+
'vtomat -in image.v -out image.mat'
64+
>>> vimage.run() # doctest: +SKIP
65+
"""
66+
67+
_cmd = 'vtomat'
68+
input_spec=VtoMatInputSpec
69+
output_spec=VtoMatOutputSpec
70+

nipype/testing/data/image.nii

Whitespace-only changes.

nipype/testing/data/image.v

Whitespace-only changes.

0 commit comments

Comments
 (0)