Skip to content

Commit 1eb21d8

Browse files
committed
Merge branch 'maint/3.2.x'
2 parents 4703f4d + 14db79e commit 1eb21d8

18 files changed

+100
-70
lines changed

.mailmap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ Christopher J. Markiewicz <[email protected]> Christopher J. Markiewicz <e
2626
Cindee Madison <[email protected]> CindeeM <[email protected]>
2727
Cindee Madison <[email protected]> cindeem <[email protected]>
2828
Demian Wassermann <[email protected]> Demian Wassermann <[email protected]>
29-
Dimitri Papadopoulos Orfanos <[email protected]> Dimitri Papadopoulos <[email protected]>
29+
Dimitri Papadopoulos Orfanos <[email protected]> <[email protected]>
30+
Dimitri Papadopoulos Orfanos <[email protected]> <[email protected]>
3031
Eric Larson <[email protected]> Eric89GXL <[email protected]>
3132
Eric Larson <[email protected]> larsoner <[email protected]>
3233
Fernando Pérez-García <[email protected]> Fernando <[email protected]>

.zenodo.json

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@
141141
"orcid": "0000-0001-9791-4404"
142142
},
143143
{
144-
"name": "Lepp\u00e4kangas, Jaakko"
144+
"name": "S\u00f3lon, Anibal"
145145
},
146146
{
147-
"name": "S\u00f3lon, Anibal"
147+
"name": "Lepp\u00e4kangas, Jaakko"
148148
},
149149
{
150150
"name": "van den Bosch, Jasper J.F."
@@ -228,6 +228,11 @@
228228
{
229229
"name": "St-Jean, Samuel"
230230
},
231+
{
232+
"affiliation": "CEA",
233+
"name": "Papadopoulos Orfanos, Dimitri",
234+
"orcid": "0000-0002-1242-8990"
235+
},
231236
{
232237
"name": "Panfilov, Egor",
233238
"orcid": "0000-0002-2500-6375"
@@ -286,6 +291,9 @@
286291
{
287292
"name": "Baratz, Zvi"
288293
},
294+
{
295+
"name": "Van, Andrew"
296+
},
289297
{
290298
"affiliation": "Hospital for Sick Children",
291299
"name": "Darwin, Benjamin C"
@@ -298,11 +306,6 @@
298306
{
299307
"name": "Gauthier, Carl"
300308
},
301-
{
302-
"affiliation": "CEA",
303-
"name": "Papadopoulos Orfanos, Dimitri",
304-
"orcid": "0000-0002-1242-8990"
305-
},
306309
{
307310
"name": "Solovey, Igor"
308311
},
@@ -326,6 +329,11 @@
326329
"affiliation": "National Technical University of Athens, Greece",
327330
"name": "Raktivan, Konstantinos"
328331
},
332+
{
333+
"affiliation": "Charite Universitatsmedizin Berlin, Germany",
334+
"name": "Waller, Lea",
335+
"orcid": "0000-0002-3239-6957"
336+
},
329337
{
330338
"name": "Cal\u00e1bkov\u00e1, Mark\u00e9ta"
331339
},
@@ -346,6 +354,9 @@
346354
{
347355
"name": "Roos, Thomas"
348356
},
357+
{
358+
"name": "Hrn\u010diar, Tom\u00e1\u0161"
359+
},
349360
{
350361
"affiliation": "National Institute of Mental Health and Neuro-Sciences, India",
351362
"name": "Reddam, Venkateswara Reddy",

Changelog

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,36 @@ 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+
3.2.2 (Monday 7 February 2022)
29+
=================================
30+
31+
Bug fix release in the 3.2.x series.
32+
33+
Bug fixes
34+
---------
35+
* Reshape CIFTI-2 affines to 4x4 when encoded as row-major sequence (pr/1059)
36+
(Andrew Van, reviewed by CM)
37+
* Suggest nibabel.save() on calls to deprecated giftiio.write() (pr/1055)
38+
(Anibal Solon, reviewed by CM)
39+
* Various bugs and style issues detected by LGTM (pr/1043, pr/1048)
40+
(Dimitri Papadopoulos, reviewed by CM)
41+
* Resolve unclosed file warning in GiftiImage (pr/1038) (Lea Waller, reviewed by CM)
42+
* Fix typos preventing deprecation warnings from being raised (pr/991)
43+
(Jonathan Daniel, reviewed by MB)
44+
* Work around numpy SystemError to maintain expected error types (pr/1051) (CM)
45+
* Use more constrained mock when testing optpkg (pr/983) (CM, reviewed by YOH)
46+
47+
Maintenance
48+
-----------
49+
* Add setuptools requirement to match usage (pr/1009)
50+
(Tomáš Hrnčiar, reviewed by CM)
51+
* Fix grammar of headings in CoC (pr/996) (MB, reviewed by CM, Ariel Rokem)
52+
* Set minimum pydicom to 1.0.0 (pr/1050) (CM)
53+
* Submit coverage to codecov via pinned PyPI package (pr/1008) (CM)
54+
* Upgrade versioneer to 0.19 (pr/967) (CM)
55+
* Migrate to GitHub actions (pr/972) (CM, reviewed by Serge Koudoro)
56+
57+
2858
3.2.1 (Saturday 28 November 2020)
2959
=================================
3060

doc/source/conf.py

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

9393
# General information about the project.
9494
project = u'NiBabel'
95-
copyright = f"2006-2021, {metadata['maintainer']} <{metadata['author_email']}>"
95+
copyright = f"2006-2022, {metadata['maintainer']} <{metadata['author_email']}>"
9696

9797
# The version info for the project you're documenting, acts as replacement for
9898
# |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
@@ -114,6 +114,9 @@ contributed code and discussion (in rough order of appearance):
114114
* Markéta Calábková
115115
* Carl Gauthier
116116
* Julian Klug
117+
* Lea Waller
118+
* Tomáš Hrnčiar
119+
* Andrew Van
117120

118121
License reprise
119122
===============

nibabel/dft.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
from io import BytesIO
2525

2626
from .nifti1 import Nifti1Header
27+
from nibabel.optpkg import optional_package
2728

28-
from .pydicom_compat import pydicom, read_file
29+
pydicom = optional_package("pydicom")[0]
2930

3031
logger = logging.getLogger('nibabel.dft')
3132

@@ -241,7 +242,7 @@ def __getattribute__(self, name):
241242
return val
242243

243244
def dicom(self):
244-
return read_file(self.files[0])
245+
return pydicom.read_file(self.files[0])
245246

246247

247248
class _db_nochange:
@@ -386,7 +387,7 @@ def _update_dir(c, dir, files, studies, series, storage_instances):
386387

387388
def _update_file(c, path, fname, studies, series, storage_instances):
388389
try:
389-
do = read_file(f'{path}/{fname}')
390+
do = pydicom.read_file(f'{path}/{fname}')
390391
except pydicom.filereader.InvalidDicomError:
391392
logger.debug(' not a DICOM file')
392393
return None

nibabel/nicom/dicomwrappers.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717

1818
import numpy as np
1919

20+
from nibabel.optpkg import optional_package
2021
from . import csareader as csar
2122
from .dwiparams import B2q, nearest_pos_semi_def, q2bg
2223
from ..openers import ImageOpener
2324
from ..onetime import auto_attr as one_time
24-
from ..pydicom_compat import tag_for_keyword, Sequence
2525
from ..deprecated import deprecate_with_version
2626

27+
pydicom = optional_package("pydicom")[0]
28+
2729

2830
class WrapperError(Exception):
2931
pass
@@ -52,10 +54,8 @@ def wrapper_from_file(file_like, *args, **kwargs):
5254
dcm_w : ``dicomwrappers.Wrapper`` or subclass
5355
DICOM wrapper corresponding to DICOM data type
5456
"""
55-
from ..pydicom_compat import read_file
56-
5757
with ImageOpener(file_like) as fobj:
58-
dcm_data = read_file(fobj, *args, **kwargs)
58+
dcm_data = pydicom.read_file(fobj, *args, **kwargs)
5959
return wrapper_from_data(dcm_data)
6060

6161

@@ -520,7 +520,7 @@ def image_shape(self):
520520
if hasattr(first_frame, 'get') and first_frame.get([0x18, 0x9117]):
521521
# DWI image may include derived isotropic, ADC or trace volume
522522
try:
523-
self.frames = Sequence(
523+
self.frames = pydicom.Sequence(
524524
frame for frame in self.frames if
525525
frame.MRDiffusionSequence[0].DiffusionDirectionality
526526
!= 'ISOTROPIC'
@@ -550,15 +550,15 @@ def image_shape(self):
550550
# Determine if one of the dimension indices refers to the stack id
551551
dim_seq = [dim.DimensionIndexPointer
552552
for dim in self.get('DimensionIndexSequence')]
553-
stackid_tag = tag_for_keyword('StackID')
553+
stackid_tag = pydicom.datadict.tag_for_keyword('StackID')
554554
# remove the stack id axis if present
555555
if stackid_tag in dim_seq:
556556
stackid_dim_idx = dim_seq.index(stackid_tag)
557557
frame_indices = np.delete(frame_indices, stackid_dim_idx, axis=1)
558558
dim_seq.pop(stackid_dim_idx)
559559
if has_derived:
560560
# derived volume is included
561-
derived_tag = tag_for_keyword("DiffusionBValue")
561+
derived_tag = pydicom.datadict.tag_for_keyword("DiffusionBValue")
562562
if derived_tag not in dim_seq:
563563
raise WrapperError("Missing information, cannot remove indices "
564564
"with confidence.")

nibabel/nicom/tests/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from ...pydicom_compat import have_dicom
21
import unittest
2+
from nibabel.optpkg import optional_package
33

4-
dicom_test = unittest.skipUnless(have_dicom, "Could not import dicom or pydicom")
4+
pydicom, have_dicom, _ = optional_package("pydicom")
5+
6+
dicom_test = unittest.skipUnless(have_dicom, "Could not import pydicom")

nibabel/nicom/tests/test_csareader.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77

88
import numpy as np
99

10-
from ...pydicom_compat import pydicom
1110
from .. import csareader as csa
1211
from .. import dwiparams as dwp
1312

1413
import pytest
15-
from . import dicom_test
14+
from . import pydicom, dicom_test
1615
from .test_dicomwrappers import IO_DATA_PATH, DATA
1716

1817
CSA2_B0 = open(pjoin(IO_DATA_PATH, 'csa2_b0.bin'), 'rb').read()

nibabel/nicom/tests/test_dicomreaders.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,23 @@
66

77
import numpy as np
88

9+
from nibabel.optpkg import optional_package
910
from .. import dicomreaders as didr
10-
from ...pydicom_compat import pydicom
11-
12-
import pytest
13-
from . import dicom_test
14-
1511
from .test_dicomwrappers import EXPECTED_AFFINE, EXPECTED_PARAMS, IO_DATA_PATH, DATA
1612

13+
import pytest
1714
from numpy.testing import assert_array_equal, assert_array_almost_equal
1815

16+
pydicom, _, setup_module = optional_package("pydicom")
17+
1918

20-
@dicom_test
2119
def test_read_dwi():
2220
img = didr.mosaic_to_nii(DATA)
2321
arr = img.get_fdata()
2422
assert arr.shape == (128, 128, 48)
2523
assert_array_almost_equal(img.affine, EXPECTED_AFFINE)
2624

2725

28-
@dicom_test
2926
def test_read_dwis():
3027
data, aff, bs, gs = didr.read_mosaic_dwi_dir(IO_DATA_PATH,
3128
'siemens_dwi_*.dcm.gz')
@@ -37,7 +34,6 @@ def test_read_dwis():
3734
didr.read_mosaic_dwi_dir('improbable')
3835

3936

40-
@dicom_test
4137
def test_passing_kwds():
4238
# Check that we correctly pass keywords to dicom
4339
dwi_glob = 'siemens_dwi_*.dcm.gz'
@@ -61,7 +57,7 @@ def test_passing_kwds():
6157
with pytest.raises(didr.DicomReadError):
6258
func(IO_DATA_PATH, csa_glob, dicom_kwargs=dict(force=True))
6359

64-
@dicom_test
60+
6561
def test_slices_to_series():
6662
dicom_files = (pjoin(IO_DATA_PATH, "%d.dcm" % i) for i in range(2))
6763
wrappers = [didr.wrapper_from_file(f) for f in dicom_files]

nibabel/nicom/tests/test_dicomwrappers.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99

1010
import numpy as np
1111

12-
from nibabel.pydicom_compat import have_dicom, pydicom, read_file, tag_for_keyword
13-
12+
from . import pydicom, have_dicom, dicom_test
1413
from .. import dicomwrappers as didw
1514
from .. import dicomreaders as didr
1615
from ...volumeutils import endian_codes
1716

1817
import pytest
1918
from unittest import TestCase
20-
from . import dicom_test
2119

2220
from numpy.testing import assert_array_equal, assert_array_almost_equal
2321
from ...tests.nibabel_data import get_nibabel_data, needs_nibabel_data
@@ -26,8 +24,8 @@
2624
DATA_FILE = pjoin(IO_DATA_PATH, 'siemens_dwi_1000.dcm.gz')
2725
DATA_FILE_PHILIPS = pjoin(IO_DATA_PATH, 'philips_mprage.dcm.gz')
2826
if have_dicom:
29-
DATA = read_file(gzip.open(DATA_FILE))
30-
DATA_PHILIPS = read_file(gzip.open(DATA_FILE_PHILIPS))
27+
DATA = pydicom.read_file(gzip.open(DATA_FILE))
28+
DATA_PHILIPS = pydicom.read_file(gzip.open(DATA_FILE_PHILIPS))
3129
else:
3230
DATA = None
3331
DATA_PHILIPS = None
@@ -434,8 +432,8 @@ def __init__(self, div, sid):
434432
dim_idx_seq = [DimIdxSeqElem()] * num_of_frames
435433
# add an entry for StackID into the DimensionIndexSequence
436434
if sid_dim is not None:
437-
sid_tag = tag_for_keyword('StackID')
438-
fcs_tag = tag_for_keyword('FrameContentSequence')
435+
sid_tag = pydicom.datadict.tag_for_keyword('StackID')
436+
fcs_tag = pydicom.datadict.tag_for_keyword('FrameContentSequence')
439437
dim_idx_seq[sid_dim] = DimIdxSeqElem(sid_tag, fcs_tag)
440438
# create the PerFrameFunctionalGroupsSequence
441439
frames = [PerFrmFuncGrpSeqElem(div, sid)

nibabel/nicom/tests/test_utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
"""
33
import re
44

5+
from nibabel.optpkg import optional_package
6+
from .test_dicomwrappers import DATA, DATA_PHILIPS
57
from ..utils import find_private_section
68

7-
from . import dicom_test
8-
from ...pydicom_compat import pydicom
9-
from .test_dicomwrappers import DATA, DATA_PHILIPS
9+
pydicom, _, setup_module = optional_package("pydicom")
1010

1111

12-
@dicom_test
1312
def test_find_private_section_real():
1413
# Find section containing named private creator information
1514
# On real data first

nibabel/nifti1.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import numpy.linalg as npl
1818
from numpy.compat.py3k import asstr
1919

20+
from .optpkg import optional_package
2021
from .filebasedimages import SerializableImage
2122
from .volumeutils import Recoder, make_dt_codes, endian_codes
2223
from .spatialimages import HeaderDataError, ImageFileError
@@ -25,7 +26,8 @@
2526
from . import analyze # module import
2627
from .spm99analyze import SpmAnalyzeHeader
2728
from .casting import have_binary128
28-
from .pydicom_compat import have_dicom, pydicom as pdcm
29+
30+
pdcm, have_dicom, _ = optional_package("pydicom")
2931

3032
# nifti1 flat header definition for Analyze-like first 348 bytes
3133
# first number in comments indicates offset in file header in bytes

0 commit comments

Comments
 (0)