Skip to content

Commit 1d91b72

Browse files
committed
Merge branch 'maint/2.5.x'
2 parents b46efa3 + 38342e3 commit 1d91b72

File tree

7 files changed

+81
-23
lines changed

7 files changed

+81
-23
lines changed

Diff for: .zenodo.json

+10-5
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@
8787
{
8888
"name": "Moloney, Brendan"
8989
},
90+
{
91+
"affiliation": "MIT",
92+
"name": "Goncalves, Mathias",
93+
"orcid": "0000-0002-7252-7771"
94+
},
9095
{
9196
"name": "Burns, Christopher"
9297
},
@@ -130,11 +135,6 @@
130135
{
131136
"name": "Baker, Eric M."
132137
},
133-
{
134-
"affiliation": "MIT",
135-
"name": "Goncalves, Mathias",
136-
"orcid": "0000-0002-7252-7771"
137-
},
138138
{
139139
"name": "Hayashi, Soichi"
140140
},
@@ -244,6 +244,11 @@
244244
"name": "P\u00e9rez-Garc\u00eda, Fernando",
245245
"orcid": "0000-0001-9090-3024"
246246
},
247+
{
248+
"affiliation": "Center for Magnetic Resonance Research, University of Minnesota",
249+
"name": "Braun, Henry",
250+
"orcid": "0000-0001-7003-9822"
251+
},
247252
{
248253
"name": "Solovey, Igor"
249254
},

Diff for: Changelog

+27
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,33 @@ Eric Larson (EL), Demian Wassermann, and Stephan Gerhard.
2525

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

28+
2.5.1 (Monday 23 September 2019)
29+
================================
30+
31+
Enhancements
32+
------------
33+
* Ignore endianness in ``nib-diff`` if values match (pr/799) (YOH, reviewed
34+
by CM)
35+
36+
Bug fixes
37+
---------
38+
* Correctly handle Philips DICOMs w/ derived volume (pr/795) (Mathias
39+
Goncalves, reviewed by CM)
40+
* Raise CSA tag limit to 1000, parametrize for future relaxing (pr/798,
41+
backported to 2.5.x in pr/800) (Henry Braun, reviewed by CM, MB)
42+
* Coerce data types to match NIfTI intent codes when writing GIFTI data
43+
arrays (pr/806) (CM, reported by Tom Holroyd)
44+
45+
Maintenance
46+
-----------
47+
* Require h5py 2.10 for Windows + Python < 3.6 to resolve unexpected dtypes
48+
in Minc2 data (pr/804) (CM, reviewed by YOH)
49+
50+
API changes and deprecations
51+
----------------------------
52+
* Deprecate ``nicom.dicomwrappers.Wrapper.get_affine()`` in favor of ``affine``
53+
property; final removal in nibabel 4.0 (pr/796) (YOH, reviewed by CM)
54+
2855
2.5.0 (Sunday 4 August 2019)
2956
============================
3057

Diff for: doc/source/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ contributed code and discussion (in rough order of appearance):
9898
* Matt Cieslak
9999
* Egor Pafilov
100100
* Jath Palasubramaniam
101+
* Henry Braun
101102

102103
License reprise
103104
===============

Diff for: nibabel/gifti/gifti.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,21 @@ def _to_xml_element(self):
264264
return DataTag(dataarray, encoding, datatype, ordering).to_xml()
265265

266266

267-
def _data_tag_element(dataarray, encoding, datatype, ordering):
267+
def _data_tag_element(dataarray, encoding, dtype, ordering):
268268
""" Creates data tag with given `encoding`, returns as XML element
269269
"""
270270
import zlib
271-
ord = array_index_order_codes.npcode[ordering]
271+
order = array_index_order_codes.npcode[ordering]
272272
enclabel = gifti_encoding_codes.label[encoding]
273273
if enclabel == 'ASCII':
274-
da = _arr2txt(dataarray, datatype)
274+
# XXX Accommodating data_tag API
275+
# On removal (nibabel 4.0) drop str case
276+
da = _arr2txt(dataarray, dtype if isinstance(dtype, str) else KIND2FMT[dtype.kind])
275277
elif enclabel in ('B64BIN', 'B64GZ'):
276-
out = dataarray.tostring(ord)
278+
# XXX Accommodating data_tag API - don't try to fix dtype
279+
if isinstance(dtype, str):
280+
dtype = dataarray.dtype
281+
out = np.asanyarray(dataarray, dtype).tostring(order)
277282
if enclabel == 'B64GZ':
278283
out = zlib.compress(out)
279284
da = base64.b64encode(out).decode()
@@ -456,11 +461,10 @@ def _to_xml_element(self):
456461
if self.coordsys is not None:
457462
data_array.append(self.coordsys._to_xml_element())
458463
# write data array depending on the encoding
459-
dt_kind = data_type_codes.dtype[self.datatype].kind
460464
data_array.append(
461465
_data_tag_element(self.data,
462466
gifti_encoding_codes.specs[self.encoding],
463-
KIND2FMT[dt_kind],
467+
data_type_codes.dtype[self.datatype],
464468
self.ind_ord))
465469

466470
return data_array

Diff for: nibabel/gifti/tests/test_gifti.py

+18
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from nibabel.testing import clear_and_catch_warnings
2121
from .test_parse_gifti_fast import (DATA_FILE1, DATA_FILE2, DATA_FILE3,
2222
DATA_FILE4, DATA_FILE5, DATA_FILE6)
23+
import itertools
2324

2425

2526
def test_gifti_image():
@@ -399,3 +400,20 @@ def test_data_array_round_trip():
399400
gio = GiftiImage.from_file_map(fmap)
400401
vertices = gio.darrays[0].data
401402
assert_array_equal(vertices, verts)
403+
404+
405+
def test_darray_dtype_coercion_failures():
406+
dtypes = (np.uint8, np.int32, np.int64, np.float32, np.float64)
407+
encodings = ('ASCII', 'B64BIN', 'B64GZ')
408+
for data_dtype, darray_dtype, encoding in itertools.product(dtypes,
409+
dtypes,
410+
encodings):
411+
da = GiftiDataArray(np.arange(10).astype(data_dtype),
412+
encoding=encoding,
413+
intent='NIFTI_INTENT_NODE_INDEX',
414+
datatype=darray_dtype)
415+
gii = GiftiImage(darrays=[da])
416+
gii_copy = GiftiImage.from_bytes(gii.to_bytes())
417+
da_copy = gii_copy.darrays[0]
418+
assert_equal(np.dtype(da_copy.data.dtype), np.dtype(darray_dtype))
419+
assert_array_equal(da_copy.data, da.data)

Diff for: nibabel/nicom/dicomwrappers.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from ..openers import ImageOpener
2323
from ..onetime import setattr_on_read as one_time
2424
from ..pydicom_compat import tag_for_keyword, Sequence
25+
from ..deprecated import deprecate_with_version
2526

2627

2728
class WrapperError(Exception):
@@ -94,7 +95,7 @@ class Wrapper(object):
9495
9596
Methods:
9697
97-
* get_affine()
98+
* get_affine() (deprecated, use affine property instead)
9899
* get_data()
99100
* get_pixel_array()
100101
* is_same_series(other)
@@ -103,6 +104,7 @@ class Wrapper(object):
103104
104105
Attributes and things that look like attributes:
105106
107+
* affine : (4, 4) array
106108
* dcm_data : object
107109
* image_shape : tuple
108110
* image_orient_patient : (3,2) array
@@ -285,18 +287,19 @@ def get(self, key, default=None):
285287
""" Get values from underlying dicom data """
286288
return self.dcm_data.get(key, default)
287289

290+
@deprecate_with_version('get_affine method is deprecated.\n'
291+
'Please use the ``img.affine`` property '
292+
'instead.',
293+
'2.5.1', '4.0')
288294
def get_affine(self):
289-
""" Return mapping between voxel and DICOM coordinate system
295+
return self.affine
290296

291-
Parameters
292-
----------
293-
None
297+
@property
298+
def affine(self):
299+
""" Mapping between voxel and DICOM coordinate system
294300
295-
Returns
296-
-------
297-
aff : (4,4) affine
298-
Affine giving transformation between voxels in data array and
299-
mm in the DICOM patient coordinate system.
301+
(4, 4) affine matrix giving transformation between voxels in data array
302+
and mm in the DICOM patient coordinate system.
300303
"""
301304
# rotation matrix already accounts for the ij transpose in the
302305
# DICOM image orientation patient transform. So. column 0 is

Diff for: setup.cfg

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ python_requires = >=3.5.1
3131
install_requires =
3232
numpy >=1.12
3333
tests_require =
34-
nose >=0.10.1
34+
nose >=0.11
3535
mock
3636
test_suite = nose.collector
3737
zip_safe = False
@@ -52,7 +52,7 @@ style =
5252
test =
5353
coverage
5454
mock
55-
nose >=0.10.1
55+
nose >=0.11
5656
all =
5757
%(dicom)s
5858
%(doc)s

0 commit comments

Comments
 (0)