-
Notifications
You must be signed in to change notification settings - Fork 264
MRG: check for MINC using processing routines #464
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
""" Testing imageclasses module | ||
""" | ||
|
||
from os.path import dirname, join as pjoin | ||
|
||
import numpy as np | ||
|
||
from nibabel.optpkg import optional_package | ||
|
||
import nibabel as nib | ||
from nibabel.analyze import AnalyzeImage | ||
from nibabel.nifti1 import Nifti1Image | ||
from nibabel.nifti2 import Nifti2Image | ||
|
||
from nibabel.imageclasses import spatial_axes_first | ||
|
||
from nose.tools import (assert_true, assert_false) | ||
|
||
DATA_DIR = pjoin(dirname(__file__), 'data') | ||
|
||
have_h5py = optional_package('h5py')[1] | ||
|
||
MINC_3DS = ('minc1_1_scale.mnc',) | ||
MINC_4DS = ('minc1_4d.mnc',) | ||
if have_h5py: | ||
MINC_3DS = MINC_3DS + ('minc2_1_scale.mnc',) | ||
MINC_4DS = MINC_4DS + ('minc2_4d.mnc',) | ||
|
||
|
||
def test_spatial_axes_first(): | ||
# Function tests is spatial axes are first three axes in image | ||
# Always True for Nifti and friends | ||
affine = np.eye(4) | ||
for shape in ((2, 3), (4, 3, 2), (5, 4, 1, 2), (2, 3, 5, 2, 1)): | ||
for img_class in (AnalyzeImage, Nifti1Image, Nifti2Image): | ||
data = np.zeros(shape) | ||
img = img_class(data, affine) | ||
assert_true(spatial_axes_first(img)) | ||
# True for MINC images < 4D | ||
for fname in MINC_3DS: | ||
img = nib.load(pjoin(DATA_DIR, fname)) | ||
assert_true(len(img.shape) == 3) | ||
assert_true(spatial_axes_first(img)) | ||
# False for MINC images < 4D | ||
for fname in MINC_4DS: | ||
img = nib.load(pjoin(DATA_DIR, fname)) | ||
assert_true(len(img.shape) == 4) | ||
assert_false(spatial_axes_first(img)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be sure, this is meant to require exact classes and exclude subclasses?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was what I intended, on the basis that it is possible to imagine a sub-class that doesn't have the same behavior, but maybe that is a bit obscure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, that's fine. Just wanted to be sure that was the intended behavior. It makes sense to me to insist on explicit inclusion in the list.