netneurolab / neuromaps

A toolbox for comparing brain maps
https://netneurolab.github.io/neuromaps
Other
246 stars 55 forks source link

Problem with load_nifti in pip package [BUG] #142

Closed tommybotch closed 9 months ago

tommybotch commented 9 months ago

Issue summary

Due to a change in nibabel 5.2.0 load function, the load_nifti function of neuromaps 0.0.4 no longer catches loading a NiftiImage. Instead the function only works with a filename.

While this is fixed in the package itself (seen on github), the pip version is outdated. Would it be possible to increment the pip version to include this change?

Detailed issue description

File "/dartfs/rc/lab/F/FinnLab/tommy/isc_asynchrony_behavior/code/encoding_models/regression/../../utils/plotting_utils.py", line 347, in vol_to_surf data_lh, data_rh = mni152_to_fsaverage(ds) File "/dartfs/rc/lab/F/FinnLab/tommy/conda/envs/asynchrony/lib/python3.9/site-packages/neuromaps/transforms.py", line 208, in mni152_to_fsaverage return _vol_to_surf(img, 'fsaverage', fsavg_density, method) File "/dartfs/rc/lab/F/FinnLab/tommy/conda/envs/asynchrony/lib/python3.9/site-packages/neuromaps/transforms.py", line 152, in _vol_to_surf img = load_nifti(img) File "/dartfs/rc/lab/F/FinnLab/tommy/conda/envs/asynchrony/lib/python3.9/site-packages/neuromaps/images.py", line 142, in load_nifti raise err File "/dartfs/rc/lab/F/FinnLab/tommy/conda/envs/asynchrony/lib/python3.9/site-packages/neuromaps/images.py", line 137, in load_nifti img = nib.load(img) File "/dartfs-hpc/rc/home/w/f003rjw/.local/lib/python3.9/site-packages/nibabel/loadsave.py", line 96, in load filename = _stringify_path(filename) File "/dartfs-hpc/rc/home/w/f003rjw/.local/lib/python3.9/site-packages/nibabel/filename_parser.py", line 41, in _stringify_path return pathlib.Path(filepath_or_buffer).expanduser().as_posix() File "/dartfs/rc/lab/F/FinnLab/tommy/conda/envs/asynchrony/lib/python3.9/pathlib.py", line 1082, in new self = cls._from_parts(args, init=False) File "/dartfs/rc/lab/F/FinnLab/tommy/conda/envs/asynchrony/lib/python3.9/pathlib.py", line 707, in _from_parts drv, root, parts = self._parse_args(args) File "/dartfs/rc/lab/F/FinnLab/tommy/conda/envs/asynchrony/lib/python3.9/pathlib.py", line 691, in _parse_args a = os.fspath(a) TypeError: expected str, bytes or os.PathLike object, not Nifti1Image

Steps to reproduce issue

>>> import nibabel as nib
>>> from neuromaps.transforms import mni152_to_fsaverage
>>> img = SOMEPATH_NIFTIFILE
>>> ds = nib.load(img)
>>> data_lh, data_rh = mni152_to_fsaverage(ds)
>>>
...

Software version

0.0.4

Code of Conduct

liuzhenqi77 commented 9 months ago

Hi, we just released a new PyPI version. Could you please update the package and let us know if it works for you? Thanks!

tommybotch commented 9 months ago

All fixed -- thank you!