<div dir="ltr"><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Hi Ariel, </div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Thanks a lot for helping me to figure this out. In fact, I used nii2mnc to convert the image to MINC before viewing the final image. </div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">You are correct. The problem is with that conversion, not from nibabel. I viewed the image with fslview and the image looks as expected. </div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Thanks a lot, sorry to bother you with this. </div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Best regards, </div><div class="gmail_default" style="font-family:trebuchet ms,sans-serif">Sulantha. </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 3, 2016 at 11:38 AM, Ariel Rokem <span dir="ltr"><<a href="mailto:arokem@gmail.com" target="_blank">arokem@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Sulantha,<div class="gmail_extra"><br></div><div class="gmail_extra">Thanks for getting in touch. Let's see if I can be helpful. </div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_quote"><div><div class="h5">On Fri, Jun 3, 2016 at 7:11 AM, Sulantha Sanjeewa <span dir="ltr"><<a href="mailto:sulantha.s@gmail.com" target="_blank">sulantha.s@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:'trebuchet ms',sans-serif">Dear all, </div><div style="font-family:'trebuchet ms',sans-serif">I am having trouble saving nifti files using nibabel. This is a simple load - mask - save situation. However, when I save, the resultant image is only two values [min and max] of the original image (almost like a mask). Can you help me on this. I have added the code here. and a link to the three files as well. </div><div style="font-family:'trebuchet ms',sans-serif">Thanks a lot for the help. </div><div style="font-family:'trebuchet ms',sans-serif">Best regards, </div><div style="font-family:'trebuchet ms',sans-serif">Sulantha. </div><div style="font-family:'trebuchet ms',sans-serif"><br></div><div style="font-family:'trebuchet ms',sans-serif">Files Link: <a href="https://drive.google.com/open?id=0B-TWCTRv7UM1a0hxaWotbjRSSUE" target="_blank">https://drive.google.com/open?id=0B-TWCTRv7UM1a0hxaWotbjRSSUE</a></div><div style="font-family:'trebuchet ms',sans-serif">Code:</div><div style="font-family:'trebuchet ms',sans-serif"><br></div><div><font face="trebuchet ms, sans-serif">img = nibabel.load('I300779.nii')</font><br></div><div><font face="trebuchet ms, sans-serif"><div>imgData = img.get_data()</div><div>mask = nibabel.load('FullBrain.nii')</div><div>maskData = mask.get_data()</div><div>maskedImgData = imgData[maskData>0.9]<br></div><div><div>new_image = numpy.zeros(maskData.shape)</div><div>new_image[maskData>0.9] = maskedImgData</div><div>aff = mask.affine</div><div>nibabel.save(nibabel.Nifti1Image(new_image, aff), 'I300779_m.nii')</div></div></font></div></div>
<br></blockquote><div><br></div></div></div><div>I am not seeing this when I run your code (<a href="https://gist.github.com/arokem/7f996b56d8f7e17ae8377677314a25ad" target="_blank">https://gist.github.com/arokem/7f996b56d8f7e17ae8377677314a25ad</a>). I also find that whole range of values in the file you processed and provided (try running those two last cells on your file). What are you doing to check the values in "I300779_m.nii"? Maybe the software reading this file downstream is doing something funny? <br></div><div><br></div><div>Cheers, </div><div><br></div><div>Ariel</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">_______________________________________________<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>
<br></blockquote></div><br></div></div>
<br>_______________________________________________<br>
Neuroimaging mailing list<br>
<a href="mailto:Neuroimaging@python.org">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>
<br></blockquote></div><br></div>