From 1a0d949aae7d140d1769bf8ab8d1de8d0eef86bd Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Sat, 27 Jul 2019 11:55:07 -0400 Subject: [PATCH 1/3] TEST: Add multiframe ECAT file for testing --- .gitmodules | 2 +- nibabel-data/nipy-ecattest | 2 +- nibabel/tests/test_ecat_data.py | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index 7ff8d61885..db0afa268e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,7 @@ url = git://github.com/matthew-brett/nitest-minc2.git [submodule "nipy-ecattest"] path = nibabel-data/nipy-ecattest - url = https://github.com/freec84/nipy-ecattest + url = https://github.com/effigies/nipy-ecattest [submodule "nibabel-data/nitest-freesurfer"] path = nibabel-data/nitest-freesurfer url = https://bitbucket.org/nipy/nitest-freesurfer.git diff --git a/nibabel-data/nipy-ecattest b/nibabel-data/nipy-ecattest index 12c9ee6d18..9a0a592057 160000 --- a/nibabel-data/nipy-ecattest +++ b/nibabel-data/nipy-ecattest @@ -1 +1 @@ -Subproject commit 12c9ee6d18d50235e3453897a4be60c19bf126c0 +Subproject commit 9a0a592057bc16894c20c77b03ea1ebb5f8ca8f9 diff --git a/nibabel/tests/test_ecat_data.py b/nibabel/tests/test_ecat_data.py index f0c9d70b3e..dce96646e8 100644 --- a/nibabel/tests/test_ecat_data.py +++ b/nibabel/tests/test_ecat_data.py @@ -37,7 +37,7 @@ class TestNegatives(object): # unit: 1/cm ) - @needs_nibabel_data('nitest-minc2') + @needs_nibabel_data('nipy-ecattest') def test_load(self): # Check highest level load of minc works img = self.opener(self.example_params['fname']) @@ -50,3 +50,15 @@ def test_load(self): assert_almost_equal(data.min(), self.example_params['min'], 4) assert_almost_equal(data.max(), self.example_params['max'], 4) assert_almost_equal(data.mean(), self.example_params['mean'], 4) + + +class TestMultiframe(TestNegatives): + example_params = dict( + fname=os.path.join(ECAT_TEST_PATH, 'ECAT7_testcase_multiframe.v'), + shape=(256, 256, 207, 3), + type=np.int16, + # Zeroed out image + min=0.0, + max=29170.67905, + mean=121.454, + ) From 244bc37a89f8c924656c21e22c1991513128c0a1 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Sun, 28 Jul 2019 08:12:03 -0400 Subject: [PATCH 2/3] FIX: Minor ECAT cleanups --- nibabel/ecat.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nibabel/ecat.py b/nibabel/ecat.py index e8b881bd66..ca9c20328a 100644 --- a/nibabel/ecat.py +++ b/nibabel/ecat.py @@ -561,7 +561,7 @@ def _check_affines(self): i = iter(affs) first = i.next() for item in i: - if not np.all(first == item): + if not np.allclose(first, item): return False return True @@ -760,7 +760,7 @@ def __init__(self, dataobj, affine, header, Parameters ---------- - dataabj : array-like + dataobj : array-like image data affine : None or (4,4) array-like homogeneous affine giving relationship between voxel coords and @@ -811,6 +811,7 @@ def __init__(self, dataobj, affine, header, file_map = self.__class__.make_file_map() self.file_map = file_map self._data_cache = None + self._fdata_cache = None @property def affine(self): From 8b00fd07485c24babd6d2454e0d96db25c085b59 Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Mon, 29 Jul 2019 23:19:52 -0400 Subject: [PATCH 3/3] PY3: Use next function on iterator while checking ECAT affines Fix suggested by Andrew Crabb (@idoimaging) in https://github.com/nipy/nibabel/issues/776#issue-473462718 --- nibabel/ecat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nibabel/ecat.py b/nibabel/ecat.py index ca9c20328a..fef2741ef8 100644 --- a/nibabel/ecat.py +++ b/nibabel/ecat.py @@ -559,7 +559,7 @@ def _check_affines(self): affs = [self.get_frame_affine(i) for i in range(nframes)] if affs: i = iter(affs) - first = i.next() + first = next(i) for item in i: if not np.allclose(first, item): return False