<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
A lack of traceback makes it difficult to see where the error is occurring, but I believe the issue is that you're passing a numpy array to a nilearn function that expects an image.
<div><br>
</div>
<div id="ms-outlook-mobile-signature" dir="auto">Get <a href="https://aka.ms/AAb9ysg">
Outlook for Android</a></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Neuroimaging <neuroimaging-bounces+markiewicz=stanford.edu@python.org> on behalf of נתי שטרן <nsh531@gmail.com><br>
<b>Sent:</b> Friday, July 8, 2022 9:38:57 AM<br>
<b>To:</b> Neuroimaging analysis in Python <neuroimaging@python.org><br>
<b>Subject:</b> Re: [Neuroimaging] NILEARN - WHY THIS CODE THROWS AN ERROR?????</font>
<div> </div>
</div>
<div>
<div dir="rtl">
<div dir="ltr">it's a fullpath to nifti image </div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="rtl" class="x_gmail_attr">‫בתאריך יום ו׳, 8 ביולי 2022 ב-16:27 מאת ‪Matthew Brett‬‏ <‪<a href="mailto:matthew.brett@gmail.com">matthew.brett@gmail.com</a>‬‏>:‬<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
Hi,<br>
<br>
‪On Fri, Jul 8, 2022 at 2:05 PM ‫נתי שטרן‬‎ <<a href="mailto:nsh531@gmail.com" target="_blank">nsh531@gmail.com</a>> wrote:‬<br>
><br>
> fullcode:<br>
><br>
><br>
><br>
> import nilearn.plotting as plot<br>
> import os,gzip,io<br>
> import nibabel as nib<br>
> path="C:/users/administrator/desktop/nii"<br>
> path2="C:/users/administrator/desktop/nii/out/"<br>
> for i in os.listdir(path):<br>
>     if(".nii.gz" in i):<br>
>         pass<br>
>     else:<br>
><br>
>         if(".nii" in i):<br>
>             img = nib.load(path+"/"+i)<br>
>             data = img.get_fdata()<br>
>             print(data)<br>
>             import imageio<br>
>             X=0<br>
>             for s in data:<br>
>                 import numpy<br>
>                 aleph=numpy.array(s,dtype=numpy.int8)<br>
>                 X=X+1<br>
>                 plot.plot_img(aleph)<br>
><br>
>                 imageio.imwrite("C:\\users\\administrator\\desktop\\nii\\"+i+str(X)+'.jpg', s)<br>
><br>
><br>
><br>
><br>
><br>
><br>
> error:<br>
> Data given cannot be loaded because it is not compatible with nibabel format<br>
<br>
Honestly - I wouldn't email python-list - this is a neuroimaging question.<br>
<br>
The obvious debugging step here is to see what "path+"/"+i" is.  Is it<br>
in fact a filename of a nifti image?  Try loading it in some other<br>
Nifti reader.   If you get stuck, put the file up somewhere where we<br>
can get it and try loading it.<br>
<br>
Cheers,<br>
<br>
Matthew<br>
_______________________________________________<br>
Neuroimaging mailing list<br>
<a href="mailto:Neuroimaging@python.org" target="_blank">Neuroimaging@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/neuroimaging" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/neuroimaging</a><br>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="rtl" class="x_gmail_signature">
<div dir="rtl"><a href="https://netanel.ml" target="_blank"><img width="200" height="51" src="https://ci3.googleusercontent.com/mail-sig/AIorK4ykFjL1iagUdlm0jcadJlaq1KyDf5c3YeE3nLFugFyn69aRMAcHd2OKO51XtKIvhzIdbuX81XE"></a></div>
</div>
</div>
</body>
</html>