In [1]: from brainglobe_utils.IO.image import load_any, load_nii
In [2]: from pathlib import Path
In [3]: path = Path("/home/alessandro/brainglobe_workingdir/whs_sd_rat/downloads/whs_sd_rat/MBAT_WHS_SD_rat_atlas_v4_pack/Data/WHS_SD_rat_atlas_v4.nii.gz")
In [4]: path.exists()
Out[4]: True
In [5]: load_any(path)
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
Cell In[5], line 1
----> 1 load_any(path)
File ~/mambaforge/lib/python3.10/site-packages/brainglobe_utils/IO/image/load.py:146, in load_any(src_path, x_scaling_factor, y_scaling_factor, z_scaling_factor, anti_aliasing, load_parallel, sort_input_file, as_numpy, n_free_cpus)
144 img = load_nii(src_path, as_array=True, as_numpy=as_numpy)
145 else:
--> 146 raise NotImplementedError(
147 "Could not guess data type for path {}".format(src_path)
148 )
150 return img
NotImplementedError: Could not guess data type for path /home/alessandro/brainglobe_workingdir/whs_sd_rat/downloads/whs_sd_rat/MBAT_WHS_SD_rat_atlas_v4_pack/Data/WHS_SD_rat_atlas_v4.nii.gz
In [6]: load_nii(path)
Out[6]: <nibabel.nifti1.Nifti1Image at 0x7ddb2cbff5b0>
In [7]: path.suffix
Out[7]: '.gz'
To Reproduce
Call load_any on a nii.gz file. load_nii on the same file works fine.
Expected behaviourload_nii should be called by load_any under the hood, for these files.
Log file
\
Screenshots
\
Computer used (please complete the following information):
brainglobe-utils=0.5.0 on Ubuntu 22.04, on a Dell Desktop.
Additional context
The culprit is that pathlib.Path function suffix returns .gz and not .nii.gz for this type of file.
Describe the bug Example ipython script outputs:
To Reproduce Call
load_any
on anii.gz
file.load_nii
on the same file works fine.Expected behaviour
load_nii
should be called byload_any
under the hood, for these files.Log file
\
Screenshots
\
Computer used (please complete the following information):
brainglobe-utils=0.5.0
on Ubuntu 22.04, on a Dell Desktop.Additional context The culprit is that
pathlib.Path
functionsuffix
returns.gz
and not.nii.gz
for this type of file.