加载大小为 14.4 MB 的大型 NIFTI 文件时出现以下错误。
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"
这是代码:
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)
当我尝试打开此类较小大小的文件(以 KB 为单位)时,不会发生这种情况。我可以在 FreeSurfer FreeView 中毫无错误地打开此文件,并且看起来不错。NiBabel 3.2.1 版本正在发生这种情况。