6
6
import os
7
7
import warnings
8
8
9
- from ...utils .filemanip import fname_presuffix , split_filename
9
+ from ...utils .filemanip import split_filename
10
10
from ..base import (
11
11
CommandLine , traits , CommandLineInputSpec , isdefined , File , TraitedSpec )
12
12
@@ -98,25 +98,26 @@ def standard_image(img_name):
98
98
return os .path .join (basedir , img_name )
99
99
100
100
101
- class AFNIBaseCommandInputSpec (CommandLineInputSpec ):
101
+ class AFNICommandInputSpec (CommandLineInputSpec ):
102
102
outputtype = traits .Enum ('AFNI' , Info .ftypes .keys (),
103
103
desc = 'AFNI output filetype' )
104
+ out_file = File (name_template = "%s_afni" , desc = 'output image file name' ,
105
+ argstr = '-prefix %s' ,
106
+ name_source = ["in_file" ])
107
+
108
+ class AFNICommandOutputSpec (TraitedSpec ):
109
+ out_file = File (desc = 'output file' ,
110
+ exists = True )
104
111
105
- class AFNITraitedSpec (AFNIBaseCommandInputSpec ):
106
- pass
107
-
108
-
109
- class AFNIBaseCommand (CommandLine ):
110
- """General support for AFNI commands. Every AFNI command accepts 'outputtype' input. For example:
111
- afni.Threedsetup(outputtype='NIFTI_GZ')
112
- """
113
112
114
- input_spec = AFNIBaseCommandInputSpec
113
+ class AFNICommand (CommandLine ):
114
+
115
+ input_spec = AFNICommandInputSpec
115
116
_outputtype = None
116
117
117
118
118
119
def __init__ (self , ** inputs ):
119
- super (AFNIBaseCommand , self ).__init__ (** inputs )
120
+ super (CommandLine , self ).__init__ (** inputs )
120
121
self .inputs .on_trait_change (self ._output_update , 'outputtype' )
121
122
122
123
if self ._outputtype is None :
@@ -148,58 +149,8 @@ def set_default_output_type(cls, outputtype):
148
149
cls ._outputtype = outputtype
149
150
else :
150
151
raise AttributeError ('Invalid AFNI outputtype: %s' % outputtype )
152
+
151
153
152
- # def _gen_fname(self, basename, cwd=None, suffix='_afni', change_ext=True, prefix=''):
153
- # """Generate a filename based on the given parameters.
154
- #
155
- # The filename will take the form: cwd/basename<suffix><ext>.
156
- # If change_ext is True, it will use the extensions specified in
157
- # <instance>inputs.outputtype.
158
- #
159
- # Parameters
160
- # ----------
161
- # basename : str
162
- # Filename to base the new filename on.
163
- # cwd : str
164
- # Path to prefix to the new filename. (default is os.getcwd())
165
- # suffix : str
166
- # Suffix to add to the `basename`. (default is '_fsl')
167
- # change_ext : bool
168
- # Flag to change the filename extension to the FSL output type.
169
- # (default True)
170
- #
171
- # Returns
172
- # -------
173
- # fname : str
174
- # New filename based on given parameters.
175
- #
176
- # """
177
- #
178
- # if basename == '':
179
- # msg = 'Unable to generate filename for command %s. ' % self.cmd
180
- # msg += 'basename is not set!'
181
- # raise ValueError(msg)
182
- # if cwd is None:
183
- # cwd = os.getcwd()
184
- # ext = Info.outputtype_to_ext(self.inputs.outputtype)
185
- # if change_ext:
186
- # if suffix:
187
- # suffix = ''.join((suffix, ext))
188
- # else:
189
- # suffix = ext
190
- # fname = fname_presuffix(basename, suffix=suffix,
191
- # use_ext=False, newpath=cwd, prefix=prefix)
192
- # return fname
193
-
194
-
195
- class AFNICommandInputSpec (AFNIBaseCommandInputSpec ):
196
- out_file = File (name_template = "%s_afni" , desc = 'output image file name' ,
197
- argstr = '-prefix %s' ,
198
- name_source = ["in_file" ])
199
-
200
-
201
- class AFNICommand (AFNIBaseCommand ):
202
- input_spec = AFNICommandInputSpec
203
154
204
155
def _overload_extension (self , value ):
205
156
path , base , _ = split_filename (value )
@@ -216,7 +167,3 @@ def _list_outputs(self):
216
167
if ext == "" :
217
168
outputs [name ] = outputs [name ] + "+orig.BRIK"
218
169
return outputs
219
-
220
- class AFNICommandOutputSpec (TraitedSpec ):
221
- out_file = File (desc = 'output file' ,
222
- exists = True )
0 commit comments