NIfTI-Image-Converter
NIfTI-Image-Converter copied to clipboard
scipy.misc.imsave is deprecated
According to the scipy documentation, the scipy.misc.imsave function is deprecated. More so, it has been completely removed in newer scipy 1.3+ versions, so that nii2png now fails:
$ python nii2png.py -i in.png -o foo/
Reading NIfTI file...
Saving image...
Traceback (most recent call last):
File "nii2png.py", line 158, in <module>
main(sys.argv[1:])
File "nii2png.py", line 142, in main
scipy.misc.imsave(image_name, data)
AttributeError: module 'scipy.misc' has no attribute 'imsave'
However, the documentation linked above does recommend another way to save images.
Thanks for this, this is something I have been trying to overcome. Any contributions are welcome on this issue... for the time being, I recommend downgrading scipy for nii2png
What about just doing what the documentation says, and introducing a new dependency to save images? I think that's what I did to fix this, and it worked just fine from what I can remember.
What about just doing what the documentation says, and introducing a new dependency to save images? I think that's what I did to fix this, and it worked just fine from what I can remember.
Can confirm. I installed the imageio library and changed all scypi.misc.imsave instances to imageio.imwrite and it worked like a charm.
imageio.imwrite seems the way to go, I've submitted a PR.
imageio.imwrite seems the way to go, I've submitted a PR.
Hi, I've been trying to get the code to run with imageio.imwrite, but get the following error:
OSError: cannot write mode F as PNG
Does anyone know the fix for this?
Thanks. Best, Vicent
I've added a PR that fixes this - it's because nibabel deprecated get_data so you have to pass it to numpy.asanyarray
I've added a PR that fixes this - it's because nibabel deprecated get_data so you have to pass it to numpy.asanyarray
Hi,
Thanks for your reply. Wouldn't it be better using nibabel's .get_fdata()? I think that's the recommended way.