@@ -1932,5 +1932,64 @@ def _overload_extension(self, value):
1932
1932
1933
1933
def _gen_filename (self , name ):
1934
1934
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
1935
1958
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'
1936
1973
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