@@ -164,20 +164,17 @@ class EcatHeader(object):
164
164
subheaders specific to each frame
165
165
with possibly-variable sized data blocks
166
166
167
- This just reads the main Ecat Header, and matrixlist
167
+ This just reads the main Ecat Header,
168
168
it does not load the data
169
- or read any sub headers
169
+ or read the mlist or any sub headers
170
170
171
171
"""
172
172
173
173
_dtype = hdr_dtype
174
- _subhdrdtype = subhdr_dtype
175
-
176
-
174
+
177
175
def __init__ (self ,
178
176
fileobj = None ,
179
- endianness = None ,
180
- check = False ):
177
+ endianness = None ):
181
178
"""Initialize Ecat header from file object
182
179
183
180
Parameters
@@ -188,9 +185,7 @@ def __init__(self,
188
185
endianness : {None, '<', '>', other endian code}, optional
189
186
endian code of binary block, If None, guess endianness
190
187
from the data
191
- check : bool optional
192
- Whether to check content of header in intialization.
193
- Default is False """
188
+ """
194
189
if fileobj is None :
195
190
self ._header_data = self ._empty_headerdata (endianness )
196
191
return
@@ -274,13 +269,23 @@ def _empty_headerdata(self,endianness=None):
274
269
275
270
def get_data_dtype (self ):
276
271
""" Get numpy dtype for data from header"""
277
- pass
272
+ raise NotImplementedError ("dtype is only valid from subheaders" )
273
+
278
274
279
275
def copy (self ):
280
276
return self .__class__ (
281
277
self .binaryblock ,
282
278
self .endianness ,
283
279
check = False )
280
+
281
+ def __eq__ (self , other ):
282
+ """ checks for equality between two headers"""
283
+ self_end = self .endianness
284
+ self_bb = self .binaryblock
285
+ if self_end == other .endianness :
286
+ return self_bb == other .binaryblock
287
+ other_bb = other ._header_data .byteswap ().tostring ()
288
+ return self_bb == other_bb
284
289
285
290
def __ne__ (self , other ):
286
291
''' equality between two headers defined by ``header_data``
@@ -294,8 +299,8 @@ def __getitem__(self, item):
294
299
295
300
Examples
296
301
--------
297
- >>> hdr = AnalyzeHeader ()
298
- >>> hdr['sizeof_hdr '] == 348
302
+ >>> hdr = EcatHeader ()
303
+ >>> hdr['magic_number '] == 'MATRIX72'
299
304
True
300
305
'''
301
306
return self ._header_data [item ]
@@ -305,10 +310,10 @@ def __setitem__(self, item, value):
305
310
306
311
Examples
307
312
--------
308
- >>> hdr = AnalyzeHeader ()
309
- >>> hdr['descrip '] = 'description'
310
- >>> str( hdr['descrip'])
311
- 'description'
313
+ >>> hdr = EcatHeader ()
314
+ >>> hdr['num_frames '] = 2
315
+ >>> hdr['num_frames']
316
+ 2
312
317
'''
313
318
self ._header_data [item ] = value
314
319
@@ -364,7 +369,7 @@ def get_mlist(self, fileobj):
364
369
done = False
365
370
while not done : #mats['matlist'][0,1] == 2:
366
371
367
- mats = np .recarray (shape = (32 ,4 ), dtype = dt . newbyteorder () , buf = dat )
372
+ mats = np .recarray (shape = (32 ,4 ), dtype = dt , buf = dat )
368
373
if not (mats ['matlist' ][0 ,0 ] + mats ['matlist' ][0 ,3 ]) == 31 :
369
374
mlist = []
370
375
return mlist
@@ -422,7 +427,7 @@ def __init__(self, hdr, mlist, fileobj):
422
427
self .subheaders = self .get_subheaders ()
423
428
424
429
def get_subheaders (self ):
425
- """retreive all subheaders and return list of subheader dictionaries
430
+ """retreive all subheaders and return list of subheader recarrays
426
431
"""
427
432
subheaders = []
428
433
header = self ._header
0 commit comments