Skip to content

Commit 52fe0a7

Browse files
committed
ENH: Check for expected byte order
1 parent 342116c commit 52fe0a7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

nibabel/freesurfer/mghformat.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ def from_fileobj(klass, fileobj, check=True):
161161

162162
def get_affine(self):
163163
''' Get the affine transform from the header information.
164+
164165
MGH format doesn't store the transform directly. Instead it's gleaned
165166
from the zooms ( delta ), direction cosines ( Mdc ), RAS centers (
166167
c_ras ) and the dimensions.
@@ -349,6 +350,9 @@ def default_structarr(klass, endianness=None):
349350
Ignores byte order; always big endian
350351
'''
351352
structarr = super(MGHHeader, klass).default_structarr()
353+
# This should not be reachable even to test
354+
if structarr.newbyteorder('>') != structarr:
355+
raise ValueError("Default structarr is not big-endian")
352356
structarr['version'] = 1
353357
structarr['dims'] = 1
354358
structarr['type'] = 3

0 commit comments

Comments
 (0)