[Neuroimaging] NILEARN - WHY THIS CODE THROWS AN ERROR?????
נתי שטרן
nsh531 at gmail.com
Fri Jul 8 09:38:57 EDT 2022
it's a fullpath to nifti image
בתאריך יום ו׳, 8 ביולי 2022 ב-16:27 מאת Matthew Brett <
matthew.brett at gmail.com>:
> Hi,
>
> On Fri, Jul 8, 2022 at 2:05 PM נתי שטרן <nsh531 at gmail.com> 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
>
> Honestly - I wouldn't email python-list - this is a neuroimaging question.
>
> The obvious debugging step here is to see what "path+"/"+i" is. Is it
> in fact a filename of a nifti image? Try loading it in some other
> Nifti reader. If you get stuck, put the file up somewhere where we
> can get it and try loading it.
>
> Cheers,
>
> Matthew
> _______________________________________________
> Neuroimaging mailing list
> Neuroimaging at python.org
> https://mail.python.org/mailman/listinfo/neuroimaging
>
--
<https://netanel.ml>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/neuroimaging/attachments/20220708/9a4cfe71/attachment.html>
More information about the Neuroimaging
mailing list