Skip to content

Commit 13228e8

Browse files
authored
Merge pull request #3713 from man-shu/fix/merge_rois_zero_d_array
[FIX] Set length to 1 when np.squeeze returns a 0D array
2 parents a9af62d + d5dbb3a commit 13228e8

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Diff for: nipype/algorithms/misc.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -1490,14 +1490,13 @@ def merge_rois(in_files, in_idxs, in_ref, dtype=None, out_file=None):
14901490

14911491
for cname, iname in zip(in_files, in_idxs):
14921492
f = np.load(iname)
1493-
idxs = np.squeeze(f["arr_0"])
1493+
idxs = np.atleast_1d(np.squeeze(f["arr_0"]))
1494+
nels = len(idxs)
14941495

14951496
for d, fname in enumerate(nii):
14961497
data = np.asanyarray(nb.load(fname).dataobj).reshape(-1)
14971498
cdata = nb.load(cname).dataobj[..., d].reshape(-1)
1498-
nels = len(idxs)
1499-
idata = (idxs,)
1500-
data[idata] = cdata[0:nels]
1499+
data[idxs] = cdata[:nels]
15011500
nb.Nifti1Image(data.reshape(rsh[:3]), aff, hdr).to_filename(fname)
15021501

15031502
imgs = [nb.load(im) for im in nii]

0 commit comments

Comments
 (0)