2424from .volumeutils import Recoder , array_from_file
2525
2626_attr_dic = {
27- 'string' : str ,
28- 'integer' : int ,
29- 'float' : float
27+ 'string' : str ,
28+ 'integer' : int ,
29+ 'float' : float
3030}
3131
3232_endian_dict = {
33- 'LSB_FIRST' : '<' ,
34- 'MSB_FIRST' : '>' ,
33+ 'LSB_FIRST' : '<' ,
34+ 'MSB_FIRST' : '>' ,
3535}
3636
3737_dtype_dict = {
38- 0 : 'B' ,
39- 1 : 'h' ,
40- 3 : 'f' ,
41- 5 : 'D' ,
38+ 0 : 'B' ,
39+ 1 : 'h' ,
40+ 3 : 'f' ,
41+ 5 : 'D' ,
4242}
4343
4444_orient_dict = {
45- 0 : 'R' ,
46- 1 : 'L' ,
47- 2 : 'P' ,
48- 3 : 'A' ,
49- 4 : 'I' ,
50- 5 : 'S'
45+ 0 : 'R' ,
46+ 1 : 'L' ,
47+ 2 : 'P' ,
48+ 3 : 'A' ,
49+ 4 : 'I' ,
50+ 5 : 'S'
5151}
5252
5353space_codes = Recoder ((
5454 (0 , 'unknown' , '' ),
5555 (1 , 'scanner' , 'ORIG' ),
5656 (3 , 'talairach' , 'TLRC' ),
57- (4 , 'mni' , 'MNI' )), fields = ('code' ,'label' ,'space' ))
57+ (4 , 'mni' , 'MNI' )), fields = ('code' , 'label' , 'space' ))
5858
5959
6060class AFNIError (Exception ):
@@ -85,7 +85,7 @@ def _unpack_var(var):
8585 aname = NAME_RE .findall (var )[0 ]
8686
8787 atype = _attr_dic .get (atype , str )
88- attr = ' ' .join (var .strip ().split ('\n ' )[3 :])
88+ attr = ' ' .join (var .strip ().split ('\n ' )[3 :])
8989
9090 if atype is not str :
9191 attr = [atype (f ) for f in attr .split ()]
@@ -116,7 +116,7 @@ def _get_datatype(info):
116116 if bt is None :
117117 raise AFNIError ('Can\' t deduce image data type.' )
118118
119- return np .dtype (bo + bt )
119+ return np .dtype (bo + bt )
120120
121121
122122def parse_AFNI_header (fobj ):
@@ -135,7 +135,7 @@ def parse_AFNI_header(fobj):
135135
136136 head = fobj .read ().split ('\n \n ' )
137137
138- all_info = {key : value for key , value in map (_unpack_var , head )}
138+ all_info = {key : value for key , value in map (_unpack_var , head )}
139139
140140 return all_info
141141
@@ -292,7 +292,7 @@ def _calc_zooms(self):
292292 zooms : tuple
293293 """
294294 xyz_step = tuple (np .abs (self .info ['DELTA' ]))
295- t_step = self .info .get ('TAXIS_FLOATS' ,())
295+ t_step = self .info .get ('TAXIS_FLOATS' , ())
296296
297297 if len (t_step ) > 0 :
298298 t_step = (t_step [1 ],)
@@ -329,14 +329,14 @@ def get_space(self):
329329 def get_affine (self ):
330330 # AFNI default is RAI/DICOM order (i.e., RAI are - axis)
331331 # need to flip RA sign to align with nibabel RAS+ system
332- affine = np .asarray (self .info ['IJK_TO_DICOM_REAL' ]).reshape (3 ,4 )
333- affine = np .row_stack ((affine * [[- 1 ],[- 1 ],[1 ]],
334- [0 ,0 , 0 , 1 ]))
332+ affine = np .asarray (self .info ['IJK_TO_DICOM_REAL' ]).reshape (3 , 4 )
333+ affine = np .row_stack ((affine * [[- 1 ], [- 1 ], [1 ]],
334+ [0 , 0 , 0 , 1 ]))
335335
336336 return affine
337337
338338 def get_data_scaling (self ):
339- floatfacs = self .info .get ('BRICK_FLOAT_FACS' ,None )
339+ floatfacs = self .info .get ('BRICK_FLOAT_FACS' , None )
340340
341341 if floatfacs is None or not np .any (floatfacs ):
342342 return None
@@ -367,9 +367,9 @@ class AFNIImage(SpatialImage):
367367 """
368368
369369 header_class = AFNIHeader
370- valid_exts = ('.brik' ,'.head' )
371- files_types = (('image' , '.brik' ),('header' , '.head' ))
372- _compressed_suffixes = ('.gz' ,'.bz2' )
370+ valid_exts = ('.brik' , '.head' )
371+ files_types = (('image' , '.brik' ), ('header' , '.head' ))
372+ _compressed_suffixes = ('.gz' , '.bz2' )
373373
374374 makeable = False
375375 rw = False
0 commit comments