FNNDSC / med2image

Converts medical images to more displayable formats, e.g. NIfTI to jpg.
MIT License
190 stars 56 forks source link

Nibabel error #42

Open vikashg opened 1 year ago

vikashg commented 1 year ago

I think the latest version of Nibabel is not supported as it yields the following error

 File "/home/gupta/miniconda3/envs/game/bin/med2image", line 363, in <module>
    imgConverter    = med2image.object_factoryCreate(args).C_convert
  File "/home/gupta/miniconda3/envs/game/lib/python3.8/site-packages/med2image/med2image.py", line 799, in __init__
    self.C_convert = med2image_nii(
  File "/home/gupta/miniconda3/envs/game/lib/python3.8/site-packages/med2image/med2image.py", line 675, in __init__
    data = nimg.get_data()
  File "/home/gupta/miniconda3/envs/game/lib/python3.8/site-packages/nibabel/deprecator.py", line 208, in deprecated_func
    raise exception(message)
nibabel.deprecator.ExpiredDeprecationError: get_data() is deprecated in favor of get_fdata(), which has a more predictable return type. To obtain get_data() behavior going forward, use numpy.asanyarray(img.dataobj).

* deprecated from version: 3.0
* Raises <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 5.0

If I roll back to nibabel 5.0.0 the error disappears. I think appropriate versions of dependencies should be mentioned in the setup.py file.

hidenari-pixel commented 1 year ago

I think the latest version of Nibabel is not supported as it yields the following error

 File "/home/gupta/miniconda3/envs/game/bin/med2image", line 363, in <module>
    imgConverter    = med2image.object_factoryCreate(args).C_convert
  File "/home/gupta/miniconda3/envs/game/lib/python3.8/site-packages/med2image/med2image.py", line 799, in __init__
    self.C_convert = med2image_nii(
  File "/home/gupta/miniconda3/envs/game/lib/python3.8/site-packages/med2image/med2image.py", line 675, in __init__
    data = nimg.get_data()
  File "/home/gupta/miniconda3/envs/game/lib/python3.8/site-packages/nibabel/deprecator.py", line 208, in deprecated_func
    raise exception(message)
nibabel.deprecator.ExpiredDeprecationError: get_data() is deprecated in favor of get_fdata(), which has a more predictable return type. To obtain get_data() behavior going forward, use numpy.asanyarray(img.dataobj).

* deprecated from version: 3.0
* Raises <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 5.0

If I roll back to nibabel 5.0.0 the error disappears. I think appropriate versions of dependencies should be mentioned in the setup.py file.

You can also fix the issue by modifying the 675th line in med2image.py as follows:

data = np.asanyarray(nimg.dataobj)
42elenz commented 10 months ago

This are the packages with version that made it work for me: numpy==1.20.0 (had to downgrade) nibabel==3.0.0 (had to downgrade) pfmisc==2.2.14 pydicom==2.4.4 matplotlib==3.7.4 Pillow==10.1.0 scipy==1.10.1

Best way for me was to make a new env for that. When i was trying to downgrade from an existing env I had some problems downgrading numpy.