[Neuroimaging] nibabel.filebasedimages.ImageFileError for large label files
Paul Reiners
reine097 at umn.edu
Tue Sep 28 13:23:16 EDT 2021
Hi Chris,
Yes, that was the problem. Thanks!
Paul
On Tue, Sep 28, 2021 at 11:12 AM Christopher Markiewicz <
markiewicz at stanford.edu> wrote:
> Hi Paul,
>
> Is it possible that the file is not actually gzipped? This is the most
> common cause of this error that I've seen.
>
> Best,
> Chris
>
> ________________________________________
> From: Neuroimaging <neuroimaging-bounces+markiewicz=
> stanford.edu at python.org> on behalf of Paul Reiners via Neuroimaging <
> neuroimaging at python.org>
> Sent: Tuesday, September 28, 2021 10:07
> To: neuroimaging at python.org
> Cc: Paul Reiners
> Subject: [Neuroimaging] nibabel.filebasedimages.ImageFileError for large
> label files
>
> I am getting the following error when loading a large labeled NIFTI file
> of size 14.4 MB.
>
> Traceback (most recent call last):
> File
> "/home/miran045/reine097/projects2/lab2im/lab2im/dcan/reproduce_load_error.py",
> line 7, in <module>
> img = nib.load(file_path)
> File
> "/home/miran045/reine097/.local/lib/python3.7/site-packages/nibabel/loadsave.py",
> line 55, in load
> raise ImageFileError(f'Cannot work out file type of "{filename}"')
> nibabel.filebasedimages.ImageFileError: Cannot work out file type of
> "/home/feczk001/shared/data/nnUNet/nnUNet_raw_data_base/nnUNet_raw_data/Task509_Paper/labelsTr1/1mo_sub-375518.nii.gz"
>
> Here is the code:
>
> import nibabel as nib
>
> print(nib.__version__)
>
> file_path =
> '/home/feczk001/shared/data/nnUNet/nnUNet_raw_data_base/nnUNet_raw_data/Task509_Paper/labelsTr1/1mo_sub'
> \
> '-375518.nii.gz'
> img = nib.load(file_path)
> print(img.shape)
>
> This does not happen when I try to open such files of smaller size (on the
> order of KB). I can open this file in FreeSurfer FreeView without error
> and it looks fine. This is happening with version 3.2.1 of NiBabel.
>
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/neuroimaging/attachments/20210928/ddd91680/attachment.html>
More information about the Neuroimaging
mailing list