@@ -1394,23 +1394,23 @@ def merge_rois(in_files, in_idxs, in_ref,
1394
1394
if ndirs < 300 :
1395
1395
data = np .zeros ((npix , ndirs ))
1396
1396
for cname , iname in zip (in_files , in_idxs ):
1397
- with np .load (iname ) as f :
1398
- idxs = np .squeeze (f ['arr_0' ])
1397
+ f = np .load (iname )
1398
+ idxs = np .squeeze (f ['arr_0' ])
1399
1399
cdata = nb .load (cname ).get_data ().reshape (- 1 , ndirs )
1400
1400
nels = len (idxs )
1401
1401
idata = (idxs , )
1402
1402
try :
1403
1403
data [idata , ...] = cdata [0 :nels , ...]
1404
1404
except :
1405
- print (data .shape , cdata .shape )
1405
+ print (('Consistency between indexes and chunks was '
1406
+ 'lost: data=%s, chunk=%s' ) % (str (data .shape ),
1407
+ str (cdata .shape )))
1406
1408
raise
1407
1409
1408
1410
hdr .set_data_shape (newshape )
1409
-
1410
1411
nb .Nifti1Image (data .reshape (newshape ).astype (dtype ),
1411
1412
aff , hdr ).to_filename (out_file )
1412
1413
1413
-
1414
1414
else :
1415
1415
hdr .set_data_shape (rsh [:3 ])
1416
1416
nii = []
@@ -1420,16 +1420,17 @@ def merge_rois(in_files, in_idxs, in_ref,
1420
1420
nii .append (fname )
1421
1421
1422
1422
for cname , iname in zip (in_files , in_idxs ):
1423
- with np .load (iname ) as f :
1424
- idxs = np .squeeze (f ['arr_0' ])
1423
+ f = np .load (iname )
1424
+ idxs = np .squeeze (f ['arr_0' ])
1425
1425
1426
1426
for d , fname in enumerate (nii ):
1427
1427
data = nb .load (fname ).get_data ().reshape (- 1 )
1428
1428
cdata = nb .load (cname ).get_data ().reshape (- 1 , ndirs )[:, d ]
1429
1429
nels = len (idxs )
1430
1430
idata = (idxs , )
1431
1431
data [idata ] = cdata [0 :nels ]
1432
- nb .Nifti1Image (data .reshape (rsh [:3 ]), aff , hdr ).to_filename (fname )
1432
+ nb .Nifti1Image (data .reshape (rsh [:3 ]),
1433
+ aff , hdr ).to_filename (fname )
1433
1434
1434
1435
imgs = [nb .load (im ) for im in nii ]
1435
1436
allim = nb .concat_images (imgs )
0 commit comments