gradunwarp
gradunwarp copied to clipboard
Error when running with nibabel 4.0.1
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
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
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.
It is fixed, it just needs a release.
Outlined the release process that I set up here:
https://github.com/Washington-University/gradunwarp/pull/15#issuecomment-1707463611
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.
Sorry, I hoped bumpver would be the easy option, since there were three or four places to keep in sync...