Skip to content
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

[FIX] Fix doc load_data #134

Merged
merged 4 commits into from
Dec 18, 2023
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
17 changes: 10 additions & 7 deletions neuromaps/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ def load_nifti(img):
try:
img = nib.load(img)
except (TypeError) as err:
msg = ('stat: path should be string, bytes, os.PathLike or integer, '
'not Nifti1Image')
if not str(err) == msg:
if not ("os.PathLike" in str(err) and "not Nifti1Image" in str(err)):
raise err
return img

Expand Down Expand Up @@ -165,8 +163,10 @@ def load_gifti(img):
img = nib.GiftiImage.from_bytes(gz.read())
# it's not a pre-loaded GiftiImage so error out
elif (isinstance(err, TypeError)
and not str(err) == 'stat: path should be string, bytes, os.'
'PathLike or integer, not GiftiImage'):
and not (
"os.PathLike" in str(err) and "not GiftiImage" in str(err)
)
):
raise err

return img
Expand Down Expand Up @@ -202,8 +202,11 @@ def load_data(data):
except (AttributeError, TypeError, ValueError, OSError) as err:
# niimg_like or path_like (nifti)
if (isinstance(err, AttributeError)
or str(err) == 'stat: path should be string, bytes, os.'
'PathLike or integer, not Nifti1Image'):
or (
"os.PathLike" in str(err)
and "not Nifti1Image" in str(err)
)
):
out = np.stack([load_nifti(img).get_fdata() for img in data],
axis=3)
# array_like (parcellated)
Expand Down