Skip to content

Commit f47f80e

Browse files
authored
Merge pull request #796 from yarikoptic/rf-no_get_affine
ENH: deprecate Wrapper.get_affine - use affine property
2 parents 457c860 + 0932c6d commit f47f80e

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

nibabel/nicom/dicomwrappers.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from ..openers import ImageOpener
2424
from ..onetime import setattr_on_read as one_time
2525
from ..pydicom_compat import tag_for_keyword, Sequence
26+
from ..deprecated import deprecate_with_version
2627

2728

2829
class WrapperError(Exception):
@@ -95,7 +96,7 @@ class Wrapper(object):
9596
9697
Methods:
9798
98-
* get_affine()
99+
* get_affine() (deprecated, use affine property instead)
99100
* get_data()
100101
* get_pixel_array()
101102
* is_same_series(other)
@@ -104,6 +105,7 @@ class Wrapper(object):
104105
105106
Attributes and things that look like attributes:
106107
108+
* affine : (4, 4) array
107109
* dcm_data : object
108110
* image_shape : tuple
109111
* image_orient_patient : (3,2) array
@@ -286,18 +288,19 @@ def get(self, key, default=None):
286288
""" Get values from underlying dicom data """
287289
return self.dcm_data.get(key, default)
288290

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

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

0 commit comments

Comments
 (0)