File tree Expand file tree Collapse file tree 1 file changed +4
-21
lines changed Expand file tree Collapse file tree 1 file changed +4
-21
lines changed Original file line number Diff line number Diff line change @@ -94,15 +94,8 @@ def get_data_shape(self):
9494
9595 def get_zooms (self ):
9696 """ Get real-world sizes of voxels """
97- result = []
9897 # zooms must be positive; but steps in MINC can be negative
99- for dim in self ._dims :
100- try :
101- x = abs (float (dim .step ))
102- except AttributeError :
103- x = 1.0
104- result .append (x )
105- return tuple (result )
98+ return tuple ([abs (float (dim .step )) if hasattr (dim , 'step' ) else 1.0 for dim in self ._dims ])
10699
107100 def get_affine (self ):
108101 nspatial = len (self ._spatial_dims )
@@ -112,19 +105,9 @@ def get_affine(self):
112105 dim_names = list (self ._dim_names ) # for indexing in loop
113106 for i , name in enumerate (self ._spatial_dims ):
114107 dim = self ._dims [dim_names .index (name )]
115- try :
116- dir_cos = dim .direction_cosines
117- except AttributeError :
118- dir_cos = _default_dir_cos [name ]
119- rot_mat [:, i ] = dir_cos
120- try :
121- steps [i ] = dim .step
122- except AttributeError :
123- steps [i ] = 1.0
124- try :
125- starts [i ] = dim .start
126- except AttributeError :
127- starts [i ] = 0.0
108+ rot_mat [:, i ] = dim .direction_cosines if hasattr (dim , 'direction_cosines' ) else _default_dir_cos [name ]
109+ steps [i ] = dim .step if hasattr (dim , 'step' ) else 1.0
110+ starts [i ] = dim .start if hasattr (dim , 'start' ) else 0.0
128111 origin = np .dot (rot_mat , starts )
129112 aff = np .eye (nspatial + 1 )
130113 aff [:nspatial , :nspatial ] = rot_mat * steps
You can’t perform that action at this time.
0 commit comments