Skip to content

[FIX] Set length to 1 when np.squeeze returns a 0D array #3713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions nipype/algorithms/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1490,14 +1490,13 @@ def merge_rois(in_files, in_idxs, in_ref, dtype=None, out_file=None):

for cname, iname in zip(in_files, in_idxs):
f = np.load(iname)
idxs = np.squeeze(f["arr_0"])
idxs = np.atleast_1d(np.squeeze(f["arr_0"]))
nels = len(idxs)

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

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