Skip to content

Commit b90c82e

Browse files
committed
Merge pull request #971 from oesteban/bug/fix969
A bugfix for #969
2 parents 25bcc88 + e4c5ba8 commit b90c82e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

nipype/algorithms/misc.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,23 +1394,23 @@ def merge_rois(in_files, in_idxs, in_ref,
13941394
if ndirs < 300:
13951395
data = np.zeros((npix, ndirs))
13961396
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'])
13991399
cdata = nb.load(cname).get_data().reshape(-1, ndirs)
14001400
nels = len(idxs)
14011401
idata = (idxs, )
14021402
try:
14031403
data[idata, ...] = cdata[0:nels, ...]
14041404
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)))
14061408
raise
14071409

14081410
hdr.set_data_shape(newshape)
1409-
14101411
nb.Nifti1Image(data.reshape(newshape).astype(dtype),
14111412
aff, hdr).to_filename(out_file)
14121413

1413-
14141414
else:
14151415
hdr.set_data_shape(rsh[:3])
14161416
nii = []
@@ -1420,16 +1420,17 @@ def merge_rois(in_files, in_idxs, in_ref,
14201420
nii.append(fname)
14211421

14221422
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'])
14251425

14261426
for d, fname in enumerate(nii):
14271427
data = nb.load(fname).get_data().reshape(-1)
14281428
cdata = nb.load(cname).get_data().reshape(-1, ndirs)[:, d]
14291429
nels = len(idxs)
14301430
idata = (idxs, )
14311431
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)
14331434

14341435
imgs = [nb.load(im) for im in nii]
14351436
allim = nb.concat_images(imgs)

0 commit comments

Comments
 (0)