Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scipy.misc.imsave is deprecated #6

Open
rien333 opened this issue Dec 27, 2019 · 7 comments
Open

scipy.misc.imsave is deprecated #6

rien333 opened this issue Dec 27, 2019 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@rien333
Copy link

rien333 commented Dec 27, 2019

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.

@alexlaurence
Copy link
Owner

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

@alexlaurence alexlaurence added the help wanted Extra attention is needed label Feb 12, 2020
@rien333
Copy link
Author

rien333 commented Feb 12, 2020

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.

@petremihaivalentin
Copy link

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.

@aviogit
Copy link
Contributor

aviogit commented Mar 27, 2020

imageio.imwrite seems the way to go, I've submitted a PR.

@vcasellesb
Copy link

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

@OliJimbo
Copy link

I've added a PR that fixes this - it's because nibabel deprecated get_data so you have to pass it to numpy.asanyarray

@vcasellesb
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants