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

Already on GitHub? Sign in to your account

MRG: refactor for current and future nibabel #307

Merged
merged 6 commits into from Apr 29, 2014

Conversation

Projects
None yet
2 participants
Owner

matthew-brett commented Feb 12, 2014

Nipy was breaking against the current nibabel master because of some
changes in the way that nibabel keeps headers in memory.

New nibabel has attributes for affine, header, dataobj that old
nibabel didn't. At least for affine and header, the old methods
get_affine, get_header will stay without warning for a while, but
get ready for the time when those warnings will start by using a
compatibility wrapper around nibabel to fetch this stuff.

matthew-brett added some commits Feb 9, 2014

NF: compatiblity routines for older nibabel
Deal with change in nibabel API for getting data object, header and
affine.
NF: add get_unscaled compatibility routine
This allow us to get the unscaled data from an image avoiding the rather
awful read_img_data function that I want to deprecate.
BF: get image slope using raw header
I was using the header slope to calculate expected error.  The current
version of nibabel doesn't return the read slope from `get_slope_inter`
as I was assuming here.  Directly read the written header to get the
slope.
RF: remove yields from test_mask
The test generator makes it more difficult to debug; remove.
RF: use nibcompat module to get unscaled data
mask computation preferred unscaled data, but the routine in nibabel was
broken from recent commits I had done on nibabel, and in any case was
not well designed.  Use a compatibility routine to use the new method in
nibabel if available.
RF: use nibcompat routines for affines, headers
Use nibabel compatibility routines for getting affines and headers from
nibabel images. This avoids running into future warnings when we
deprecate the get_affine, get_header methods.
Contributor

bthirion commented Feb 18, 2014

Hi matthew,

Thanks for taking care of this. When using nibabel master, this triggers a couple of failures on my box, related to mask computation. this works fine with nibabel 1.3.0.

@matthew-brett matthew-brett commented on the diff Feb 18, 2014

nipy/io/tests/test_nibcompat.py
+ def get_header(self):
+ return 1
+ def get_affine(self):
+ return np.eye(4)
+ _data = 3
+ class NewNib:
+ header = 1
+ affine = np.eye(4)
+ dataobj = 3
+ for img in OldNib(), NewNib():
+ assert_equal(get_header(img), 1)
+ assert_array_equal(get_affine(img), np.eye(4))
+ assert_equal(get_dataobj(img), 3)
+
+
+def test_unscaled_data():
@matthew-brett

matthew-brett Feb 18, 2014

Owner

Michael - did you see this test?

Owner

matthew-brett commented Mar 26, 2014

Michael - OK to merge this one?

Owner

matthew-brett commented Apr 10, 2014

Any comments here? I propose to merge in the next few days otherwise.

Owner

matthew-brett commented Apr 10, 2014

Last call for comments

matthew-brett added a commit that referenced this pull request Apr 29, 2014

Merge pull request #307 from matthew-brett/nibabel-compatibility
MRG: refactor for current and future nibabel

Nipy was breaking against the current nibabel master because of some
changes in the way that nibabel keeps headers in memory.

New nibabel has attributes for affine, header, dataobj that old
nibabel didn't. At least for affine and header, the old methods
get_affine, get_header will stay without warning for a while, but
get ready for the time when those warnings will start by using a
compatibility wrapper around nibabel to fetch this stuff.

@matthew-brett matthew-brett merged commit 741b5d2 into nipy:master Apr 29, 2014

1 check passed

default The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment