|
40 | 40 | ]
|
41 | 41 | # Optional footer. Also has more stuff after this, optionally
|
42 | 42 | footer_dtd = [
|
43 |
| - ('mrparms', '>f4', (4,)) |
| 43 | + ('tr', '>f4'), # 0; repetition time |
| 44 | + ('flip_angle', '>f4'), # 4; flip angle |
| 45 | + ('te', '>f4'), # 8; echo time |
| 46 | + ('ti', '>f4'), # 12; inversion time |
| 47 | + ('fov', '>f4'), # 16; field of view (unused) |
44 | 48 | ]
|
45 | 49 |
|
46 | 50 | header_dtype = np.dtype(header_dtd)
|
@@ -104,6 +108,14 @@ def __init__(self,
|
104 | 108 | if endianness != '>':
|
105 | 109 | raise ValueError("MGHHeader is big-endian")
|
106 | 110 |
|
| 111 | + min_size = self._hdrdtype.itemsize |
| 112 | + full_size = self.template_dtype.itemsize |
| 113 | + if binaryblock is not None and len(binaryblock) >= min_size: |
| 114 | + # Right zero-pad or truncate binaryblock to appropriate size |
| 115 | + # Footer is optional and may contain variable-length text fields, |
| 116 | + # so limit to fixed fields |
| 117 | + binaryblock = (binaryblock[:full_size] + |
| 118 | + b'\x00' * (full_size - len(binaryblock))) |
107 | 119 | super(MGHHeader, self).__init__(binaryblock=binaryblock,
|
108 | 120 | endianness=endianness,
|
109 | 121 | check=False)
|
|
0 commit comments