Skip to content

Commit 2f898cc

Browse files
author
stymy
committed
afni with 1dcalc
1 parent 4d14512 commit 2f898cc

File tree

2 files changed

+61
-1
lines changed

2 files changed

+61
-1
lines changed

nipype/interfaces/afni/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
Fourier, Allineate, Maskave, SkullStrip, TCat, Fim,
1313
BlurInMask, Autobox, TCorrMap, Bandpass, Retroicor,
1414
TCorrelate, TCorr1D, BrickStat, ROIStats, AutoTcorrelate,
15-
AFNItoNIFTI)
15+
AFNItoNIFTI, Eval)
16+
from .svm import (SVMTest, SVMTrain)

nipype/interfaces/afni/preprocess.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,5 +1932,64 @@ def _overload_extension(self, value):
19321932

19331933
def _gen_filename(self, name):
19341934
return os.path.abspath(super(AFNItoNIFTI, self)._gen_filename(name))
1935+
1936+
class EvalInputSpec(AFNICommandInputSpec):
1937+
in_file_a = File(desc='input file to 1deval',
1938+
argstr='-a %s', position=0, mandatory=True, exists=True)
1939+
in_file_b = File(desc='operand file to 1deval',
1940+
argstr=' -b %s', position=1, exists=True)
1941+
in_file_c = File(desc='operand file to 1deval',
1942+
argstr=' -c %s', position=2, exists=True)
1943+
out_file = File(name_template="%s_calc", desc='output image file name',
1944+
argstr='-prefix %s', name_source="in_file_a")
1945+
out1D = traits.Bool(desc="output in 1D",
1946+
argstr='-1D')
1947+
expr = traits.Str(desc='expr', argstr='-expr "%s"', position=3,
1948+
mandatory=True)
1949+
start_idx = traits.Int(desc='start index for in_file_a',
1950+
requires=['stop_idx'])
1951+
stop_idx = traits.Int(desc='stop index for in_file_a',
1952+
requires=['start_idx'])
1953+
single_idx = traits.Int(desc='volume index for in_file_a')
1954+
other = File(desc='other options', argstr='')
1955+
1956+
class Eval(AFNICommand):
1957+
"""Evaluates an expression that may include columns of data from one or more text files
19351958
1959+
see AFNI Documentation: <http://afni.nimh.nih.gov/pub/dist/doc/program_help/1deval.html>
1960+
1961+
Examples
1962+
========
1963+
1964+
>>> from nipype.interfaces import afni as afni
1965+
>>> eval = afni.Eval()
1966+
>>> eval.inputs.in_file_a = 'data1.1D'
1967+
>>> eval.inputs.in_file_b = 'data2.1D'
1968+
>>> eval.inputs.expr='a*b'
1969+
>>> eval.inputs.out1D = True
1970+
>>> eval.inputs.out_file = 'data_calc.1D'
1971+
>>> calc.cmdline #doctest: +SKIP
1972+
'3deval -a timeseries1.1D -b timeseries2.1D -expr "a*b" -1D -prefix data_calc.1D'
19361973
1974+
"""
1975+
1976+
_cmd = '1deval'
1977+
input_spec = EvalInputSpec
1978+
output_spec = AFNICommandOutputSpec
1979+
1980+
def _format_arg(self, name, trait_spec, value):
1981+
if name == 'in_file_a':
1982+
arg = trait_spec.argstr % value
1983+
if isdefined(self.inputs.start_idx):
1984+
arg += '[%d..%d]' % (self.inputs.start_idx,
1985+
self.inputs.stop_idx)
1986+
if isdefined(self.inputs.single_idx):
1987+
arg += '[%d]' % (self.inputs.single_idx)
1988+
return arg
1989+
return super(Eval, self)._format_arg(name, trait_spec, value)
1990+
1991+
def _parse_inputs(self, skip=None):
1992+
"""Skip the arguments without argstr metadata
1993+
"""
1994+
return super(Eval, self)._parse_inputs(
1995+
skip=('start_idx', 'stop_idx', 'out1D', 'other'))

0 commit comments

Comments
 (0)