@@ -25,7 +25,7 @@ class Info(object):
25
25
"""
26
26
__outputtype = 'AFNI'
27
27
ftypes = {'NIFTI' : '.nii' ,
28
- 'AFNI' : '+orig.BRIK ' ,
28
+ 'AFNI' : '' ,
29
29
'NIFTI_GZ' : '.nii.gz' }
30
30
31
31
@staticmethod
@@ -149,62 +149,73 @@ def set_default_output_type(cls, outputtype):
149
149
else :
150
150
raise AttributeError ('Invalid AFNI outputtype: %s' % outputtype )
151
151
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
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
193
194
194
195
195
class AFNICommandInputSpec (AFNIBaseCommandInputSpec ):
196
- out_file = File ("%s_afni" , desc = 'output image file name' ,
197
- argstr = '-prefix %s' , xor = [ 'out_file' , 'prefix' , 'suffix' ],
198
- name_source = "in_file" , usedefault = True )
196
+ out_file = File (name_template = "%s_afni" , desc = 'output image file name' ,
197
+ argstr = '-prefix %s' ,
198
+ name_source = [ "in_file" ] )
199
199
200
200
201
201
class AFNICommand (AFNIBaseCommand ):
202
202
input_spec = AFNICommandInputSpec
203
-
203
+
204
204
def _overload_extension (self , value ):
205
205
path , base , _ = split_filename (value )
206
206
return os .path .join (path , base + Info .outputtype_to_ext (self .inputs .outputtype ))
207
207
208
+ def _list_outputs (self ):
209
+ outputs = super (AFNICommand , self )._list_outputs ()
210
+ metadata = dict (name_source = lambda t : t is not None )
211
+ out_names = self .inputs .traits (** metadata ).keys ()
212
+ if out_names :
213
+ for name in out_names :
214
+ if outputs [name ]:
215
+ _ ,_ ,ext = split_filename (outputs [name ])
216
+ if ext == "" :
217
+ outputs [name ] = outputs [name ] + "+orig.BRIK"
218
+ return outputs
208
219
209
220
class AFNICommandOutputSpec (TraitedSpec ):
210
221
out_file = File (desc = 'output file' ,
0 commit comments