Skip to content

FIX: Python 3 compatibility issue while loading multiframe ECAT files #777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion nibabel-data/nipy-ecattest
7 changes: 4 additions & 3 deletions nibabel/ecat.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,9 +559,9 @@ 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.all(first == item):
if not np.allclose(first, item):
return False
return True

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
14 changes: 13 additions & 1 deletion nibabel/tests/test_ecat_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand All @@ -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,
)