diff --git a/tests/test_mghimage.py b/tests/test_mghimage.py new file mode 100644 index 0000000000000000000000000000000000000000..d42078c11402591a685f82dfd64c5f0d4e3afbc1 --- /dev/null +++ b/tests/test_mghimage.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# +# test_mghimage.py - +# +# Author: Paul McCarthy <pauldmccarthy@gmail.com> +# + + +import os.path as op + +import numpy as np +import nibabel as nib + +from . import testdir + +import fsl.data.mghimage as fslmgh + + +def test_looksLikeMGHImage(): + + lookLike = ['test.mgz', 'test.mgh'] + noLookLike = ['test.nii', 'test', 'testmgh.mga', 'test.mgza', 'test.mgha'] + + + for l in lookLike: assert fslmgh.looksLikeMGHImage(l) + for nl in noLookLike: assert not fslmgh.looksLikeMGHImage(nl) + + +def test_MGHImage(): + + datadir = op.join(op.dirname(__file__), 'testdata') + testfile = op.join(datadir, 'example.mgz') + + img = fslmgh.MGHImage(testfile) + nbimg = nib.load(testfile) + + assert np.all(np.isclose(img[:], nbimg.get_data())) + assert np.all(np.isclose(img.voxToWorldMat, nbimg.affine)) diff --git a/tests/testdata/example.mgz b/tests/testdata/example.mgz new file mode 100644 index 0000000000000000000000000000000000000000..f54f3c80b8f32ad73b836125a17d2bfbee7eedf2 Binary files /dev/null and b/tests/testdata/example.mgz differ