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

ENH: Fix NiBabel deprecation warnings #83

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

jhlegarreta
Copy link
Contributor

Fix NiBabel deprecation warnings:

  • Call get_fdata() instead of get_data(): get_data() is deprecated since version 3.0 and raises an error since version 5.0.
  • Call affine instead of get_affine(): get_affine() is deprecated since version 2.1 and raises an error since version 4.0.

The required minimum NiBabel version is 3.0 as of the current HEAD: commit 221b068.

Fixes:

tract_querier/scripts/query_tracts.py:138: DeprecationWarning: 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
* Will raise <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 5.0
  img = labels_nii.get_data()

and

tract_querier/scripts/query_tracts.py:173: DeprecationWarning: get_affine method is deprecated.
Please use the ``img.affine`` property instead.

* deprecated from version: 2.1
* Will raise <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 4.0
  affine_ijk_2_ras = labels_nii.get_affine()

raised locally when running the tract_querier script.

Fix `NiBabel` deprecation warnings:
- Call `get_fdata()` instead of `get_data()`: `get_data()` is deprecated
  since version 3.0 and raises an error since version 5.0.
- Call `affine` instead of `get_affine()`: `get_affine()` is deprecated
  since version 2.1 and raises an error since version 4.0.

The required minimum `NiBabel` version is 3.0 as of the current `HEAD`:
commit 221b068.

Fixes:
```
tract_querier/scripts/query_tracts.py:138: DeprecationWarning: 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
* Will raise <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 5.0
  img = labels_nii.get_data()
```

and
```
tract_querier/scripts/query_tracts.py:173: DeprecationWarning: get_affine method is deprecated.
Please use the ``img.affine`` property instead.

* deprecated from version: 2.1
* Will raise <class 'nibabel.deprecator.ExpiredDeprecationError'> as of version: 4.0
  affine_ijk_2_ras = labels_nii.get_affine()
```

raised locally when running the `tract_querier` script.
@demianw demianw merged commit a174788 into demianw:master Jan 10, 2025
7 checks passed
@jhlegarreta jhlegarreta deleted the FixNiBabelDeprecationWarnings branch January 10, 2025 14:47
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

Successfully merging this pull request may close these issues.

2 participants