Skip to content

Commit 7ee4aa6

Browse files
authored
Merge pull request #777 from effigies/fix/ecat_py3
FIX: Python 3 compatibility issue while loading multiframe ECAT files
2 parents 65c7ff6 + 8b00fd0 commit 7ee4aa6

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
url = git://github.com/matthew-brett/nitest-minc2.git
77
[submodule "nipy-ecattest"]
88
path = nibabel-data/nipy-ecattest
9-
url = https://github.com/freec84/nipy-ecattest
9+
url = https://github.com/effigies/nipy-ecattest
1010
[submodule "nibabel-data/nitest-freesurfer"]
1111
path = nibabel-data/nitest-freesurfer
1212
url = https://bitbucket.org/nipy/nitest-freesurfer.git

nibabel/ecat.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,9 @@ def _check_affines(self):
559559
affs = [self.get_frame_affine(i) for i in range(nframes)]
560560
if affs:
561561
i = iter(affs)
562-
first = i.next()
562+
first = next(i)
563563
for item in i:
564-
if not np.all(first == item):
564+
if not np.allclose(first, item):
565565
return False
566566
return True
567567

@@ -760,7 +760,7 @@ def __init__(self, dataobj, affine, header,
760760
761761
Parameters
762762
----------
763-
dataabj : array-like
763+
dataobj : array-like
764764
image data
765765
affine : None or (4,4) array-like
766766
homogeneous affine giving relationship between voxel coords and
@@ -811,6 +811,7 @@ def __init__(self, dataobj, affine, header,
811811
file_map = self.__class__.make_file_map()
812812
self.file_map = file_map
813813
self._data_cache = None
814+
self._fdata_cache = None
814815

815816
@property
816817
def affine(self):

nibabel/tests/test_ecat_data.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TestNegatives(object):
3737
# unit: 1/cm
3838
)
3939

40-
@needs_nibabel_data('nitest-minc2')
40+
@needs_nibabel_data('nipy-ecattest')
4141
def test_load(self):
4242
# Check highest level load of minc works
4343
img = self.opener(self.example_params['fname'])
@@ -50,3 +50,15 @@ def test_load(self):
5050
assert_almost_equal(data.min(), self.example_params['min'], 4)
5151
assert_almost_equal(data.max(), self.example_params['max'], 4)
5252
assert_almost_equal(data.mean(), self.example_params['mean'], 4)
53+
54+
55+
class TestMultiframe(TestNegatives):
56+
example_params = dict(
57+
fname=os.path.join(ECAT_TEST_PATH, 'ECAT7_testcase_multiframe.v'),
58+
shape=(256, 256, 207, 3),
59+
type=np.int16,
60+
# Zeroed out image
61+
min=0.0,
62+
max=29170.67905,
63+
mean=121.454,
64+
)

0 commit comments

Comments
 (0)