From 9cc5c1b844bf8ccc1391ffa89f19fd6fc1fbe9fd Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Wed, 17 Jan 2018 18:11:36 +0000
Subject: [PATCH] unit test for mghimage module

---
 tests/test_mghimage.py     |  38 +++++++++++++++++++++++++++++++++++++
 tests/testdata/example.mgz | Bin 0 -> 680 bytes
 2 files changed, 38 insertions(+)
 create mode 100644 tests/test_mghimage.py
 create mode 100644 tests/testdata/example.mgz

diff --git a/tests/test_mghimage.py b/tests/test_mghimage.py
new file mode 100644
index 000000000..d42078c11
--- /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
GIT binary patch
literal 680
zcmb2|=3oE==C{|Xb*?5#uz#4ZacgB{s@`T!(M^Weua?YtzC5{e+T^pkm)GbdIu&R3
zO0AVl-70lBW6fF#%WHE4&izi<d~wF99F5pBKE~IkMV-7NX}0$N>Z$M3tH0g(SAG9`
zfA}O7WzR`HyopI2XWMRUxh8EkMcvcBJxAiyr>eM_CtvUW&mH<ps{3F2_Q;FNmMO2_
zv-9QRrcHKVPn6ZojL9hNcAt{?#4=uQ-rGF~0*&oXHSP(V8oX$6)~OJEDIJrL%Br~e
z{=FgV&IxjxiOt!N;~5&8zGJI--|?x+kNOVv9(&ApxwKVhAB)w;1!gg(mNipv@0IIT
z^-9@1S?=HWM`w@B@U`K$jC<sJ&F#v{T(Qz`FXz}yS997Ix+yiY>C?njVIh*G7bdry
zU!)tWY;y4Kma|EntJyz$?%mxgdp<gNT{XM!l|5ml=DDispX)-s7M_crAL{4%Y+B6s
z1O4AuHoth}7+oj7^68tGeBb8Csovf!dL=kO`B_uUi43jgcTuHVUl$*m>6Mc8=DzAY
z`TmDZH>Zch+OOft*Lhf;w$Wz3;jxLg(<=<)4l1r(dT4LS#Pu=S;`&|lyNuf3PkB4n
z->&wMy^pw~+Sal+X3xDY?mYKqb?xcCbMh7W8+V<)_J2jz!Z%Yg<o4HOtf`9JlD*7w
zmq~m6l&vp*uemoN_Cd@2ob_QAa|1pF)JlYI+1A0h-s&2!`3vc9Dw9w5ZPOFJEArdp
zpvY&_Y46H^1qI$oNe?O#{QlhZ!WrLmyM$b||3&vdy-N5Wl`SP$r4u47nxzpNt{zxf
z|Ku*?0k=mRW^Fsc7&$YOQPcBz(A&3fZSUBI{Skh8-_{<K*nZf4@Mnc2JACAghB^lQ
M!~f;iM=>w}0JLdED*ylh

literal 0
HcmV?d00001

-- 
GitLab