Skip to content

Commit

Permalink
ENH: Fix NiBabel deprecation warnings (#83)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jhlegarreta authored Jan 10, 2025
1 parent fa984c6 commit a174788
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit a174788

Please sign in to comment.