From c1c42d97f74ff2230b50df019d033a010f797918 Mon Sep 17 00:00:00 2001 From: Isaiah Norton Date: Fri, 18 Jan 2019 15:24:35 -0500 Subject: [PATCH] Update 'measurement frame' field to be a double matrix (#77) Fixes #76 --- nrrd/reader.py | 2 +- nrrd/tests/data/test_simple4d_raw.nrrd | 4 ++-- nrrd/tests/test_reading.py | 9 +++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/nrrd/reader.py b/nrrd/reader.py index c474a88..682be60 100644 --- a/nrrd/reader.py +++ b/nrrd/reader.py @@ -101,7 +101,7 @@ def _get_field_type(field, custom_field_map): elif field in ['space origin']: return 'double vector' elif field in ['measurement frame']: - return 'int matrix' + return 'double matrix' elif field in ['space directions']: return 'double matrix' else: diff --git a/nrrd/tests/data/test_simple4d_raw.nrrd b/nrrd/tests/data/test_simple4d_raw.nrrd index 2c67a62..bfd45b0 100644 --- a/nrrd/tests/data/test_simple4d_raw.nrrd +++ b/nrrd/tests/data/test_simple4d_raw.nrrd @@ -8,6 +8,6 @@ sizes: 1 1 1 1 space directions: (1.5,0,0) (0,1.5,0) (0,0,1) none endian: little encoding: raw -measurement frame: (1,0,0) (0,1,0) (0,0,1) +measurement frame: (1.0001,0,0) (0,1.0000000006,0) (0,0,1.000000000000009) -������? \ No newline at end of file +������? diff --git a/nrrd/tests/test_reading.py b/nrrd/tests/test_reading.py index e30b9f0..7644929 100644 --- a/nrrd/tests/test_reading.py +++ b/nrrd/tests/test_reading.py @@ -7,7 +7,6 @@ from nrrd.tests.util import * import nrrd - class TestReadingFunctions(unittest.TestCase): def setUp(self): self.expected_header = {u'dimension': 3, @@ -231,14 +230,16 @@ def test_read_simple_4d_nrrd(self): [np.NaN, np.NaN, np.NaN]]), 'endian': 'little', 'encoding': 'raw', - 'measurement frame': np.array([[1., 0., 0.], - [0., 1., 0.], - [0., 0., 1.]])} + 'measurement frame': np.array([[1.0001, 0., 0.], + [0., 1.0000000006, 0.], + [0., 0., 1.000000000000009]])} + data, header = nrrd.read(RAW_4D_NRRD_FILE_PATH) np.testing.assert_equal(header, expected_header) np.testing.assert_equal(data.dtype, np.float64) + np.testing.assert_equal(header['measurement frame'].dtype, np.float64) np.testing.assert_equal(data, np.array([[[[0.76903426]]]])) # Test that the data read is able to be edited