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

Error when running with nibabel 4.0.1 #7

Open
pvelasco opened this issue Aug 8, 2022 · 5 comments
Open

Error when running with nibabel 4.0.1 #7

pvelasco opened this issue Aug 8, 2022 · 5 comments

Comments

@pvelasco
Copy link

pvelasco commented Aug 8, 2022

It looks like get_affine is deprecated:

Parsing /flywheel/v0/input/gdcoeffs/coeff.grad for harmonics coeffs
Traceback (most recent call last):
  File "/usr/local/bin/gradient_unwarp.py", line 127, in <module>
    grad_unwarp.run()
  File "/usr/local/bin/gradient_unwarp.py", line 101, in run
    self.vol, self.m_rcs2ras = utils.get_vol_affine(self.args.infile)
  File "/usr/local/lib/python3.8/dist-packages/gradunwarp/core/utils.py", line 65, in get_vol_affine
    return nibimage.get_data(), nibimage.get_affine()
  File "/usr/local/lib/python3.8/dist-packages/nibabel/deprecator.py", line 181, in deprecated_func
    raise error_class(message)
nibabel.deprecator.ExpiredDeprecationError: get_affine method is deprecated.
Please use the ``img.affine`` property instead.

* deprecated from version: 2.1
* Raises <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 4.0
@luisa-sophia
Copy link

Hi,
I am running the scripts with nibabel 5.1.0, and it seems like get_data() has finally been replaced in favor of get_fdata(). Was an easy fix for me to change the line in utils.py, but maybe you want to consider adding this to the repo, so it's fixed for everyone with newer nibabel versions :)

  File "/mnt/work/software/fsl/lib/python3.11/site-packages/gradunwarp/core/utils.py", line 65, in get_vol_affine
    return nibimage.get_data(), nibimage.affine
           ^^^^^^^^^^^^^^^^^^^
  File "/mnt/work/software/fsl/lib/python3.11/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

@coalsont
Copy link
Member

I really don't like whoever thought that deprecation should be a time-bomb. Deliberate backward incompatibility is not a useful feature, it just adds pain for the library's users.

I don't edit this code much, I would welcome a PR to fix this.

@effigies
Copy link

It is fixed, it just needs a release.

Outlined the release process that I set up here:

#15 (comment)

@coalsont
Copy link
Member

I just released a 1.2.2 (after taking a bit of time to get bumpver working on an old python...), so hopefully that will resolve this.

@effigies
Copy link

Sorry, I hoped bumpver would be the easy option, since there were three or four places to keep in sync...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants