|
7 | 7 | #
|
8 | 8 | ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
|
9 | 9 | import os
|
10 |
| -from StringIO import StringIO |
11 |
| -import numpy as np |
12 | 10 |
|
13 |
| -import nibabel |
| 11 | +import numpy as np |
14 | 12 |
|
15 |
| -from ..ecat import EcatHeader, EcatMlist, EcatSubHeader, EcatImage, native_code |
| 13 | +from ..volumeutils import native_code, swapped_code |
| 14 | +from ..ecat import EcatHeader, EcatMlist, EcatSubHeader, EcatImage |
16 | 15 |
|
17 | 16 | from unittest import TestCase
|
18 | 17 |
|
|
21 | 20 |
|
22 | 21 | from numpy.testing import assert_array_equal, assert_array_almost_equal
|
23 | 22 |
|
24 |
| -data_path = os.path.dirname(nibabel.__file__) |
25 |
| -ecat_file = os.path.join(data_path, 'tests','data','tinypet.v') |
| 23 | +from ..testing import data_path |
| 24 | + |
| 25 | +ecat_file = os.path.join(data_path, 'tinypet.v') |
26 | 26 |
|
27 | 27 | class TestEcatHeader(TestCase):
|
28 | 28 | header_class = EcatHeader
|
@@ -67,15 +67,21 @@ def test_update(self):
|
67 | 67 | assert_true(hdr['num_frames'] == 0)
|
68 | 68 | hdr['num_frames'] = 2
|
69 | 69 | assert_true(hdr['num_frames'] == 2)
|
70 |
| - |
| 70 | + |
71 | 71 | def test_endianness(self):
|
72 |
| - fid = open(ecat_file) |
| 72 | + # Default constructed header should be native |
73 | 73 | native_hdr = self.header_class()
|
| 74 | + assert_true(native_hdr.endianness == native_code) |
| 75 | + # Swapped constructed header should be swapped |
| 76 | + swapped_hdr = self.header_class(endianness=swapped_code) |
| 77 | + assert_true(swapped_hdr.endianness == swapped_code) |
| 78 | + # Example header is big-endian |
| 79 | + fid = open(ecat_file) |
74 | 80 | file_hdr = native_hdr.from_fileobj(fid)
|
75 | 81 | fid.close()
|
76 |
| - assert_true(native_hdr.endianness == native_code) |
77 | 82 | assert_true(file_hdr.endianness == '>')
|
78 |
| - |
| 83 | + |
| 84 | + |
79 | 85 | class TestEcatMlist(TestCase):
|
80 | 86 | header_class = EcatHeader
|
81 | 87 | mlist_class = EcatMlist
|
|
0 commit comments