Skip to content

Commit

Permalink
Merge pull request #134 from netneurolab/fix-doc-load-data
Browse files Browse the repository at this point in the history
[FIX] Fix doc load_data
  • Loading branch information
VinceBaz authored Dec 18, 2023
2 parents 899aae1 + 14fab8a commit 50a33f9
Showing 1 changed file with 10 additions and 7 deletions.
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

0 comments on commit 50a33f9

Please sign in to comment.