Skip to content

Commit 3b1c7b3

Browse files
committed
Merge tag '5.3.0'
5.3.0 (Tuesday 8 October 2024) This release primarily adds support for Python 3.13 and Numpy 2.0. NiBabel 6.0 will drop support for Numpy 1.x. New features ------------ * Update NIfTI extension protocol to include ``.content : bytes``, ``.text : str`` and ``.json : dict`` properties for accessing extension contents. Exceptions will be raised on ``.text`` and ``.json`` if conversion fails. (pr/1336) (CM) Enhancements ------------ * Ability to read data from many multiframe DICOM files that previously generated errors (pr/1340) (Brendan Moloney, reviewed by CM) * ``nib-nifti-dx`` now supports NIfTI-2 files with a ``--nifti2`` flag (pr/1323) (CM) * Update :mod:`nibabel.streamlines.tractogram` to support ragged arrays. (pr/1291) (Serge Koudoro, reviewed by CM) * Filter numpy ``UserWarning`` on ``np.finfo(np.longdouble)``. This can occur on Windows systems, but it's done in the context of checking for the problem that is being warned against, so there's no need to be noisy. (pr/1310) (Joshua Newton, reviewed by CM) * Improve error message for for dicomwrapper errors in shape calculation (pr/1302) (YOH, reviewed by CM) * Support "flat" ASCII-encoded GIFTI DataArrays (pr/1298) (PM, reviewed by CM) Bug fixes --------- * Fix location initialization/update in OrthoSlicer3D for permuted axes (pr/1319, pr/1350) (Guillaume Becq, reviewed by CM) * Fix DICOM scaling, making frame filtering explicit (pr/1342) (Brendan Moloney, reviewed by CM) * Fixed multiframe DICOM issue where data could be flipped along slice dimension relative to the affine (pr/1340) (Brendan Moloney, reviewed by CM) * Fixed multiframe DICOM issue where ``image_position`` and the translation component in the ``affine`` could be incorrect (pr/1340) (Brendan Moloney, reviewed by CM) Maintenance ----------- * Numpy 2.0 compatibility and addressing deprecations in numpy API (pr/1304, pr/1330, pr/1331, pr/1334, pr/1337) (Jon Haitz Legarreta Gorroño, CM) * Python 3.13 compatibility (pr/1315) (Sandro from the Fedora Project, reviewed by CM) * Testing on Python 3.13 with free-threading (pr/1339) (CM) * Testing on ARM64 Mac OS runners (pr/1320) (CM) * Proactively address deprecations in coming Python versions (pr/1329, pr/1332, pr/1333) (Jon Haitz Legarreta Gorroño, reviewed by CM) * Replace nose-era ``setup()`` and ``teardown()`` functions with pytest equivalents (pr/1325) (Sandro from the Fedora Project, reviewed by Étienne Mollier and CM) * Transitioned from blue/isort/flake8 to `ruff <https://docs.astral.sh/ruff/>`__. (pr/1289) (Dimitri Papadopoulos, reviewed by CM) * Vetted and added various rules to the ruff configuration for auto-formatting and style guide enforcement. (pr/1321, pr/1351, pr/1352, pr/1353, pr/1354, pr/1355, pr/1357, pr/1358, pr/1359, pr/1360, pr/1361, pr/1362, pr/1363, pr/1364, pr/1368, pr/1369) (Dimitri Papadopoulos, reviewed by CM) * Fixing typos when found. (pr/1313, pr/1370) (MB, Dimitri Papadopoulos) * Applied Repo-Review suggestions (Dimitri Papadopoulos, reviewed by CM) API changes and deprecations ---------------------------- * Raise :class:`~nibabel.spatialimages.HeaderDataError` from :func:`~nibabel.nifti1.Nifti1Header.set_qform` if the affine fails to decompose. This would previously result in :class:`numpy.linalg.LinAlgError`. (pr/1227) (CM) * The :func:`nibabel.onetime.auto_attr` module can be replaced by :func:`functools.cached_property` in all supported versions of Python. This alias may be removed in future versions. (pr/1341) (CM) * Removed the deprecated ``nisext`` (setuptools extensions) package. (pr/1290) (CM, reviewed by MB) * tag '5.3.0': MNT: Update release notes translator STY: ruff check --fix MNT: Remove workarounds used for Python 3.8 support MNT: Update support matrix for Python and numpy DOC: Remove end year from copyright DOC: Update mailmap and contributor list DOC: Update Zenodo contributors DOC: Update changelog
2 parents c18f542 + 249986b commit 3b1c7b3

23 files changed

+194
-116
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,17 @@ jobs:
113113
fail-fast: false
114114
matrix:
115115
os: ['ubuntu-latest', 'windows-latest', 'macos-13', 'macos-latest']
116-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
116+
python-version: ["3.9", "3.10", "3.11", "3.12"]
117117
architecture: ['x64', 'x86', 'arm64']
118118
dependencies: ['full', 'pre']
119119
include:
120120
# Basic dependencies only
121121
- os: ubuntu-latest
122-
python-version: 3.8
122+
python-version: 3.9
123123
dependencies: 'none'
124124
# Absolute minimum dependencies
125125
- os: ubuntu-latest
126-
python-version: 3.8
126+
python-version: 3.9
127127
dependencies: 'min'
128128
# NoGIL
129129
- os: ubuntu-latest
@@ -153,10 +153,10 @@ jobs:
153153
- os: macos-13
154154
dependencies: pre
155155
# Drop pre tests for SPEC-0-unsupported Python versions
156-
- python-version: '3.8'
157-
dependencies: pre
158156
- python-version: '3.9'
159157
dependencies: pre
158+
- python-version: '3.10'
159+
dependencies: pre
160160

161161
env:
162162
DEPENDS: ${{ matrix.dependencies }}

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Oliver P. Hinds <[email protected]>
7575
7676
Oscar Esteban <[email protected]>
7777
78+
7879
Reinder Vos de Wael <[email protected]> <[email protected]>
7980
Roberto Guidotti <[email protected]>
8081

.zenodo.json

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
"name": "Cipollini, Ben",
2626
"orcid": "0000-0002-7782-0790"
2727
},
28+
{
29+
"affiliation": "CEA",
30+
"name": "Papadopoulos Orfanos, Dimitri",
31+
"orcid": "0000-0002-1242-8990"
32+
},
2833
{
2934
"name": "McCarthy, Paul"
3035
},
@@ -78,13 +83,11 @@
7883
"orcid": "0000-0001-7159-1387"
7984
},
8085
{
81-
"name": "Wang, Hao-Ting",
82-
"orcid": "0000-0003-4078-2038"
86+
"name": "Moloney, Brendan"
8387
},
8488
{
85-
"affiliation": "CEA",
86-
"name": "Papadopoulos Orfanos, Dimitri",
87-
"orcid": "0000-0002-1242-8990"
89+
"name": "Wang, Hao-Ting",
90+
"orcid": "0000-0003-4078-2038"
8891
},
8992
{
9093
"affiliation": "Harvard University - Psychology",
@@ -123,9 +126,6 @@
123126
{
124127
"name": "S\u00f3lon, Anibal"
125128
},
126-
{
127-
"name": "Moloney, Brendan"
128-
},
129129
{
130130
"name": "Morency, F\u00e9lix C."
131131
},
@@ -177,6 +177,11 @@
177177
{
178178
"name": "Van, Andrew"
179179
},
180+
{
181+
"affiliation": "Brigham and Women's Hospital, Mass General Brigham/Harvard Medical School",
182+
"name": "Legarreta, Jon Haitz",
183+
"orcid": "0000-0002-9661-1396"
184+
},
180185
{
181186
"affiliation": "Google",
182187
"name": "Gorgolewski, Krzysztof J.",
@@ -203,6 +208,9 @@
203208
{
204209
"name": "Baker, Eric M."
205210
},
211+
{
212+
"name": "Koudoro, Serge"
213+
},
206214
{
207215
"name": "Hayashi, Soichi"
208216
},
@@ -220,14 +228,14 @@
220228
"name": "Esteban, Oscar",
221229
"orcid": "0000-0001-8435-6191"
222230
},
223-
{
224-
"name": "Koudoro, Serge"
225-
},
226231
{
227232
"affiliation": "University College London",
228233
"name": "P\u00e9rez-Garc\u00eda, Fernando",
229234
"orcid": "0000-0001-9090-3024"
230235
},
236+
{
237+
"name": "Becq, Guillaume"
238+
},
231239
{
232240
"name": "Dock\u00e8s, J\u00e9r\u00f4me"
233241
},
@@ -270,9 +278,9 @@
270278
"orcid": "0000-0003-1076-5122"
271279
},
272280
{
273-
"affiliation": "Brigham and Women's Hospital, Mass General Brigham/Harvard Medical School",
274-
"name": "Legarreta, Jon Haitz",
275-
"orcid": "0000-0002-9661-1396"
281+
"affiliation": "Polytechnique Montr\u00e9al, Montr\u00e9al, CA",
282+
"name": "Newton, Joshua",
283+
"orcid": "0009-0005-6963-3812"
276284
},
277285
{
278286
"name": "Hahn, Kevin S."
@@ -285,6 +293,9 @@
285293
{
286294
"name": "Hinds, Oliver P."
287295
},
296+
{
297+
"name": "Sandro"
298+
},
288299
{
289300
"name": "Fauber, Bennet"
290301
},
@@ -391,11 +402,6 @@
391402
},
392403
{
393404
"name": "freec84"
394-
},
395-
{
396-
"affiliation": "Polytechnique Montréal, Montréal, CA",
397-
"name": "Newton, Joshua",
398-
"orcid": "0009-0005-6963-3812"
399405
}
400406
],
401407
"keywords": [

Changelog

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,72 @@ Eric Larson (EL), Demian Wassermann, Stephan Gerhard and Ross Markello (RM).
2525

2626
References like "pr/298" refer to github pull request numbers.
2727

28-
Upcoming release (To be determined)
29-
===================================
28+
5.3.0 (Tuesday 8 October 2024)
29+
==============================
30+
31+
This release primarily adds support for Python 3.13 and Numpy 2.0.
32+
33+
NiBabel 6.0 will drop support for Numpy 1.x.
3034

3135
New features
3236
------------
37+
* Update NIfTI extension protocol to include ``.content : bytes``, ``.text : str`` and ``.json : dict``
38+
properties for accessing extension contents. Exceptions will be raised on ``.text`` and ``.json`` if
39+
conversion fails. (pr/1336) (CM)
3340

3441
Enhancements
3542
------------
36-
* Ability to read data from many multiframe DICOM files that previously generated errors
43+
* Ability to read data from many multiframe DICOM files that previously generated errors (pr/1340)
44+
(Brendan Moloney, reviewed by CM)
45+
* ``nib-nifti-dx`` now supports NIfTI-2 files with a ``--nifti2`` flag (pr/1323) (CM)
46+
* Update :mod:`nibabel.streamlines.tractogram` to support ragged arrays. (pr/1291)
47+
(Serge Koudoro, reviewed by CM)
48+
* Filter numpy ``UserWarning`` on ``np.finfo(np.longdouble)``. This can occur on
49+
Windows systems, but it's done in the context of checking for the problem that
50+
is being warned against, so there's no need to be noisy. (pr/1310)
51+
(Joshua Newton, reviewed by CM)
52+
* Improve error message for for dicomwrapper errors in shape calculation (pr/1302)
53+
(YOH, reviewed by CM)
54+
* Support "flat" ASCII-encoded GIFTI DataArrays (pr/1298) (PM, reviewed by CM)
3755

3856
Bug fixes
3957
---------
40-
* Fixed multiframe DICOM issue where data could be flipped along slice dimension relative to the
41-
affine
42-
* Fixed multiframe DICOM issue where ``image_position`` and the translation component in the
43-
``affine`` could be incorrect
44-
45-
Documentation
46-
-------------
58+
* Fix location initialization/update in OrthoSlicer3D for permuted axes (pr/1319, pr/1350)
59+
(Guillaume Becq, reviewed by CM)
60+
* Fix DICOM scaling, making frame filtering explicit (pr/1342) (Brendan Moloney, reviewed by CM)
61+
* Fixed multiframe DICOM issue where data could be flipped along slice dimension relative to the
62+
affine (pr/1340) (Brendan Moloney, reviewed by CM)
63+
* Fixed multiframe DICOM issue where ``image_position`` and the translation component in the
64+
``affine`` could be incorrect (pr/1340) (Brendan Moloney, reviewed by CM)
4765

4866
Maintenance
4967
-----------
68+
* Numpy 2.0 compatibility and addressing deprecations in numpy API
69+
(pr/1304, pr/1330, pr/1331, pr/1334, pr/1337) (Jon Haitz Legarreta Gorroño, CM)
70+
* Python 3.13 compatibility (pr/1315) (Sandro from the Fedora Project, reviewed by CM)
71+
* Testing on Python 3.13 with free-threading (pr/1339) (CM)
72+
* Testing on ARM64 Mac OS runners (pr/1320) (CM)
73+
* Proactively address deprecations in coming Python versions (pr/1329, pr/1332, pr/1333)
74+
(Jon Haitz Legarreta Gorroño, reviewed by CM)
75+
* Replace nose-era ``setup()`` and ``teardown()`` functions with pytest equivalents
76+
(pr/1325) (Sandro from the Fedora Project, reviewed by Étienne Mollier and CM)
77+
* Transitioned from blue/isort/flake8 to `ruff <https://docs.astral.sh/ruff/>`__. (pr/1289)
78+
(Dimitri Papadopoulos, reviewed by CM)
79+
* Vetted and added various rules to the ruff configuration for auto-formatting and style
80+
guide enforcement. (pr/1321, pr/1351, pr/1352, pr/1353, pr/1354, pr/1355, pr/1357, pr/1358,
81+
pr/1359, pr/1360, pr/1361, pr/1362, pr/1363, pr/1364, pr/1368, pr/1369)
82+
(Dimitri Papadopoulos, reviewed by CM)
83+
* Fixing typos when found. (pr/1313, pr/1370) (MB, Dimitri Papadopoulos)
84+
* Applied Repo-Review suggestions (Dimitri Papadopoulos, reviewed by CM)
5085

5186
API changes and deprecations
5287
----------------------------
88+
* Raise :class:`~nibabel.spatialimages.HeaderDataError` from
89+
:func:`~nibabel.nifti1.Nifti1Header.set_qform` if the affine fails to decompose.
90+
This would previously result in :class:`numpy.linalg.LinAlgError`. (pr/1227) (CM)
91+
* The :func:`nibabel.onetime.auto_attr` module can be replaced by :func:`functools.cached_property`
92+
in all supported versions of Python. This alias may be removed in future versions. (pr/1341) (CM)
93+
* Removed the deprecated ``nisext`` (setuptools extensions) package. (pr/1290) (CM, reviewed by MB)
5394

5495

5596
5.2.1 (Monday 26 February 2024)

doc/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102

103103
# General information about the project.
104104
project = 'NiBabel'
105-
copyright = f"2006-2023, {authors['name']} <{authors['email']}>"
105+
copyright = f"2006, {authors['name']} <{authors['email']}>"
106106

107107
# The version info for the project you're documenting, acts as replacement for
108108
# |version| and |release|, also used in various other places throughout the

doc/source/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ contributed code and discussion (in rough order of appearance):
130130
* Reinder Vos de Wael
131131
* Peter Suter
132132
* Blake Dewey
133+
* Guillaume Becq
134+
* Joshua Newton
135+
* Sandro from the Fedora Project
133136

134137
License reprise
135138
===============

doc/source/installation.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,16 @@ is for you.
8181
Requirements
8282
------------
8383

84-
.. check these against pyproject.toml
85-
86-
* Python_ 3.8 or greater
87-
* NumPy_ 1.20 or greater
88-
* Packaging_ 17.0 or greater
89-
* importlib-resources_ 1.3 or greater (or Python 3.9+)
90-
* SciPy_ (optional, for full SPM-ANALYZE support)
91-
* h5py_ (optional, for MINC2 support)
92-
* PyDICOM_ 1.0.0 or greater (optional, for DICOM support)
93-
* `Python Imaging Library`_ (optional, for PNG conversion in DICOMFS)
84+
.. check these against pyproject.toml / tox.ini
85+
86+
* Python_ 3.9 or greater
87+
* NumPy_ 1.22 or greater
88+
* Packaging_ 20.0 or greater
89+
* importlib-resources_ 5.12 or greater (or Python 3.12+)
90+
* SciPy_ 1.8 or greater (optional, for full SPM-ANALYZE support)
91+
* h5py_ 3.5 or greater (optional, for MINC2 support)
92+
* PyDICOM_ 2.3.0 or greater (optional, for DICOM support)
93+
* `Python Imaging Library`_ 8.4 or greater (optional, for PNG conversion in DICOMFS)
9494
* pytest_ (optional, to run the tests)
9595
* sphinx_ (optional, to build the documentation)
9696

nibabel/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,7 @@ def bench(label=None, verbose=1, extra_argv=None):
170170
code : ExitCode
171171
Returns the result of running the tests as a ``pytest.ExitCode`` enum
172172
"""
173-
try:
174-
from importlib.resources import as_file, files
175-
except ImportError:
176-
from importlib_resources import as_file, files
173+
from importlib.resources import as_file, files
177174

178175
args = []
179176
if extra_argv is not None:

nibabel/conftest.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010

1111
@pytest.fixture(scope='session', autouse=True)
1212
def legacy_printoptions():
13-
from packaging.version import Version
14-
15-
if Version(np.__version__) >= Version('1.22'):
16-
np.set_printoptions(legacy='1.21')
13+
np.set_printoptions(legacy='1.21')
1714

1815

1916
@pytest.fixture
@@ -24,7 +21,7 @@ def max_digits():
2421
orig_max_str_digits = sys.get_int_max_str_digits()
2522
yield sys.set_int_max_str_digits
2623
sys.set_int_max_str_digits(orig_max_str_digits)
27-
except AttributeError: # pragma: no cover
24+
except AttributeError: # PY310 # pragma: no cover
2825
# Nothing to do for versions of Python that lack these methods
2926
# They were added as DoS protection in Python 3.11 and backported to
3027
# some other versions.

nibabel/filebasedimages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
if ty.TYPE_CHECKING:
2424
from .filename_parser import ExtensionSpec, FileSpec
2525

26-
FileSniff = ty.Tuple[bytes, str]
26+
FileSniff = tuple[bytes, str]
2727

2828
ImgT = ty.TypeVar('ImgT', bound='FileBasedImage')
2929
HdrT = ty.TypeVar('HdrT', bound='FileBasedHeader')

nibabel/nicom/ascconv.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ def assign2atoms(assign_ast, default_class=int):
9090
target = target.value
9191
prev_target_type = OrderedDict
9292
elif isinstance(target, ast.Subscript):
93-
if isinstance(target.slice, ast.Constant): # PY39
94-
index = target.slice.value
95-
else: # PY38
96-
index = target.slice.value.n
93+
index = target.slice.value
9794
atoms.append(Atom(target, prev_target_type, index))
9895
target = target.value
9996
prev_target_type = list

nibabel/nifti1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ def _mangle(self, dataset: DicomDataset) -> bytes:
671671
(38, 'eval', NiftiExtension),
672672
(40, 'matlab', NiftiExtension),
673673
(42, 'quantiphyse', NiftiExtension),
674-
(44, 'mrs', NiftiExtension[ty.Dict[str, ty.Any]]),
674+
(44, 'mrs', NiftiExtension[dict[str, ty.Any]]),
675675
),
676676
fields=('code', 'label', 'handler'),
677677
)

nibabel/spatialimages.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
from __future__ import annotations
134134

135135
import typing as ty
136+
from functools import cache
136137
from typing import Literal
137138

138139
import numpy as np
@@ -145,11 +146,6 @@
145146
from .viewers import OrthoSlicer3D
146147
from .volumeutils import shape_zoom_affine
147148

148-
try:
149-
from functools import cache
150-
except ImportError: # PY38
151-
from functools import lru_cache as cache
152-
153149
if ty.TYPE_CHECKING:
154150
import io
155151
from collections.abc import Sequence

nibabel/testing/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import unittest
1818
import warnings
1919
from contextlib import nullcontext
20+
from importlib.resources import as_file, files
2021
from itertools import zip_longest
2122

2223
import numpy as np
@@ -29,11 +30,6 @@
2930
if ty.TYPE_CHECKING:
3031
from importlib.resources.abc import Traversable
3132

32-
try:
33-
from importlib.resources import as_file, files
34-
except ImportError: # PY38
35-
from importlib_resources import as_file, files
36-
3733

3834
def get_test_data(
3935
subdir: ty.Literal['gifti', 'nicom', 'externals'] | None = None,

0 commit comments

Comments
 (0)