NILEARN - WHY THIS CODE THROWS AN ERROR?????
MRAB
python at mrabarnett.plus.com
Fri Jul 8 16:47:38 EDT 2022
On 08/07/2022 14:06, נתי שטרן wrote:
> fullcode:
>
>
>
> import nilearn.plotting as plot
> import os,gzip,io
> import nibabel as nib
> path="C:/users/administrator/desktop/nii"
> path2="C:/users/administrator/desktop/nii/out/"
> for i in os.listdir(path):
> if(".nii.gz" in i):
> pass
> else:
>
> if(".nii" in i):
> img = nib.load(path+"/"+i)
> data = img.get_fdata()
> print(data)
> import imageio
> X=0
> for s in data:
> import numpy
> aleph=numpy.array(s,dtype=numpy.int8)
> X=X+1
> plot.plot_img(aleph)
>
> imageio.imwrite("C:\\users\\administrator\\desktop\\nii\\"+i
> +str(X)+'.jpg', s)
>
>
>
>
>
>
> error:
> Data given cannot be loaded because it is not compatible with nibabel
> format
> <https://netanel.ml>
What's the complete traceback?
It might help you to identify the problem if you add messages to tell
you what it's doing, e.g. what file it's about to load.
Apparently, one of the files is not compatible with nibabel.
More information about the Python-list
mailing list