@@ -188,10 +188,14 @@ def get_trt(in_meta, in_file=None):
188
188
raise ValueError (f"'{ trt } '" )
189
189
190
190
return trt
191
+ elif in_file is None :
192
+ msg = "Unable to find TotalReadoutTime in metadata and in_file \
193
+ not defined."
194
+ raise AssertionError (msg )
191
195
192
196
# npe = N voxels PE direction
193
197
pe_index = "ijk" .index (in_meta ["PhaseEncodingDirection" ][0 ])
194
- npe = nb .load (in_file ).shape [pe_index ]
198
+ npe = nb .loadsave . load (in_file ).shape [pe_index ]
195
199
196
200
# Use case 2: EES is defined
197
201
ees = in_meta .get ("EffectiveEchoSpacing" )
@@ -252,7 +256,9 @@ def epi_mask(in_file, out_file=None):
252
256
maxnorm = np .percentile (closed [closed > 0 ], 90 )
253
257
closed = np .clip (closed , a_min = 0.0 , a_max = maxnorm )
254
258
# Calculate index of center of masses
255
- cm = tuple (np .round (ndimage .measurements .center_of_mass (closed )).astype (int ))
259
+ cm = tuple (
260
+ np .round (ndimage .measurements .center_of_mass (closed )).astype (int )
261
+ )
256
262
# Erode the picture of the brain by a lot
257
263
eroded = ndimage .grey_erosion (closed , structure = ball (5 ))
258
264
# Calculate the residual
@@ -268,6 +274,8 @@ def epi_mask(in_file, out_file=None):
268
274
hdr = img .header .copy ()
269
275
hdr .set_data_dtype ("uint8" )
270
276
nb .Nifti1Image (
271
- ndimage .binary_dilation (labels == 2 , ball (2 )).astype ("uint8" ), img .affine , hdr
277
+ ndimage .binary_dilation (labels == 2 , ball (2 )).astype ("uint8" ),
278
+ img .affine ,
279
+ hdr ,
272
280
).to_filename (out_file )
273
281
return out_file
0 commit comments