7
7
import warnings
8
8
9
9
from ...utils .filemanip import fname_presuffix , split_filename
10
- from ..base import (CommandLine , traits , CommandLineInputSpec , isdefined , File , TraitedSpec )
10
+ from ..base import (
11
+ CommandLine , traits , CommandLineInputSpec , isdefined , File , TraitedSpec )
11
12
12
13
warn = warnings .warn
13
14
warnings .filterwarnings ('always' , category = UserWarning )
18
19
#
19
20
###################################
20
21
22
+
21
23
class Info (object ):
22
24
"""Handle afni output type and version information.
23
25
"""
@@ -80,7 +82,6 @@ def outputtype(cls):
80
82
# 'Nipype uses NIFTI_GZ as default'))
81
83
return 'AFNI'
82
84
83
-
84
85
@staticmethod
85
86
def standard_image (img_name ):
86
87
'''Grab an image from the standard location.
@@ -96,11 +97,8 @@ def standard_image(img_name):
96
97
97
98
98
99
class AFNITraitedSpec (CommandLineInputSpec ):
99
- outputtype = traits .Enum ('AFNI' , Info .ftypes .keys (),
100
- desc = 'AFNI output filetype' )
101
-
102
-
103
-
100
+ outputtype = traits .Enum ('AFNI' , Info .ftypes .keys (),
101
+ desc = 'AFNI output filetype' )
104
102
105
103
106
104
class AFNICommand (CommandLine ):
@@ -130,7 +128,6 @@ def _output_update(self):
130
128
"""
131
129
self ._outputtype = self .inputs .outputtype
132
130
133
-
134
131
@classmethod
135
132
def set_default_outputtype (cls , outputtype ):
136
133
"""Set the default output type for AFNI classes.
@@ -184,39 +181,44 @@ def _gen_fname(self, basename, cwd=None, suffix='_afni', change_ext=True, prefix
184
181
suffix = '' .join ((suffix , ext ))
185
182
else :
186
183
suffix = ext
187
- fname = fname_presuffix (basename , suffix = suffix ,
188
- use_ext = False , newpath = cwd , prefix = prefix )
184
+ fname = fname_presuffix (basename , suffix = suffix ,
185
+ use_ext = False , newpath = cwd , prefix = prefix )
189
186
return fname
190
187
188
+
191
189
class AFNIPrefixInputSpec (AFNITraitedSpec ):
192
190
out_file = File ("%s_afni" , desc = 'output image file name' ,
193
- argstr = '-prefix %s' , xor = ['out_file' , 'prefix' , 'suffix' ], name_source = "in_file" , usedefault = True )
194
- prefix = traits .Str (desc = 'output image prefix' , deprecated = 0.8 , new_name = "out_file" )
195
- suffix = traits .Str (desc = 'output image suffix' , deprecated = 0.8 , new_name = "out_file" )
196
-
191
+ argstr = '-prefix %s' , xor = ['out_file' , 'prefix' , 'suffix' ], name_source = "in_file" , usedefault = True )
192
+ prefix = traits .Str (
193
+ desc = 'output image prefix' , deprecated = 0.8 , new_name = "out_file" )
194
+ suffix = traits .Str (
195
+ desc = 'output image suffix' , deprecated = 0.8 , new_name = "out_file" )
196
+
197
+
197
198
class AFNIPrefixCommand (AFNICommand ):
198
199
input_spec = AFNIPrefixInputSpec
199
-
200
+
200
201
def _gen_filename (self , name ):
201
202
trait_spec = self .inputs .trait (name )
202
- value = getattr (self .inputs , name )
203
203
if name == "out_file" and (isdefined (self .inputs .prefix ) or isdefined (self .inputs .suffix )):
204
204
suffix = ''
205
205
prefix = ''
206
206
if isdefined (self .inputs .prefix ):
207
207
prefix = self .inputs .prefix
208
208
if isdefined (self .inputs .suffix ):
209
209
suffix = self .inputs .suffix
210
-
211
- _ , base , _ = split_filename (getattr (self .inputs ,trait_spec .name_source ))
210
+
211
+ _ , base , _ = split_filename (
212
+ getattr (self .inputs , trait_spec .name_source ))
212
213
return self ._gen_fname (basename = base , prefix = prefix , suffix = suffix , cwd = '' )
213
214
else :
214
215
return super (AFNIPrefixCommand , self )._gen_filename (name )
215
-
216
+
216
217
def _overload_extension (self , value ):
217
218
path , base , _ = split_filename (value )
218
219
return os .path .join (path , base + Info .outputtype_to_ext (self .inputs .outputtype ))
219
-
220
+
221
+
220
222
class AFNIPrefixOutputSpec (TraitedSpec ):
221
223
out_file = File (desc = 'output file' ,
222
- exists = True )
224
+ exists = True )
0 commit comments