def _read_header(fid):
 version = np.fromfile(fid, np.int32, 1)[0]
 if (version > (6 & (~ np.bitwise_and(version, 6)))):
  version = version.byteswap().astype(np.uint32)
 else:
  ValueError('Watchout. This does not seem to be a simple binary EGI file.')
 def my_fread(*x, **y):
  return np.fromfile(*x, **y)[0]
 info = dict(version=version, year=my_fread(fid, '>i2', 1), month=my_fread(fid, '>i2', 1), day=my_fread(fid, '>i2', 1), hour=my_fread(fid, '>i2', 1), minute=my_fread(fid, '>i2', 1), second=my_fread(fid, '>i2', 1), millisecond=my_fread(fid, '>i4', 1), samp_rate=my_fread(fid, '>i2', 1), n_channels=my_fread(fid, '>i2', 1), gain=my_fread(fid, '>i2', 1), bits=my_fread(fid, '>i2', 1), value_range=my_fread(fid, '>i2', 1))
 unsegmented = (1 if (np.bitwise_and(version, 1) == 0) else 0)
 precision = np.bitwise_and(version, 6)
 if (precision == 0):
  RuntimeError('Floating point precision is undefined.')
 if unsegmented:
  info.update(dict(n_categories=0, n_segments=1, n_samples=np.fromfile(fid, '>i4', 1)[0], n_events=np.fromfile(fid, '>i2', 1)[0], event_codes=[], category_names=[], category_lengths=[], pre_baseline=0))
  for event in range(info['n_events']):
   event_codes = ''.join(np.fromfile(fid, 'S1', 4).astype('U1'))
   info['event_codes'].append(event_codes)
  info['event_codes'] = np.array(info['event_codes'])
 else:
  raise NotImplementedError('Only continuous files are supported')
 info['unsegmented'] = unsegmented
 (info['dtype'], info['orig_format']) = {2: ('>i2', 'short'), 4: ('>f4', 'float'), 6: ('>f8', 'double')}[precision]
 info['dtype'] = np.dtype(info['dtype'])
 return info

def _read_header ( fid ) : version = np . fromfile ( fid , np . int32 , 1 ) [ 0 ] if ( version > ( 6 & ( ~ np . bitwise_and ( version , 6 ) ) ) ) : version = version . byteswap ( ) . astype ( np . uint32 ) else : ValueError ( 'Watchout. This does not seem to be a simple binary EGI file.' ) def my_fread ( * x , ** y ) : return np . fromfile ( * x , ** y ) [ 0 ] info = dict ( version = version , year = my_fread ( fid , '>i2' , 1 ) , month = my_fread ( fid , '>i2' , 1 ) , day = my_fread ( fid , '>i2' , 1 ) , hour = my_fread ( fid , '>i2' , 1 ) , minute = my_fread ( fid , '>i2' , 1 ) , second = my_fread ( fid , '>i2' , 1 ) , millisecond = my_fread ( fid , '>i4' , 1 ) , samp_rate = my_fread ( fid , '>i2' , 1 ) , n_channels = my_fread ( fid , '>i2' , 1 ) , gain = my_fread ( fid , '>i2' , 1 ) , bits = my_fread ( fid , '>i2' , 1 ) , value_range = my_fread ( fid , '>i2' , 1 ) ) unsegmented = ( 1 if ( np . bitwise_and ( version , 1 ) == 0 ) else 0 ) precision = np . bitwise_and ( version , 6 ) if ( precision == 0 ) : RuntimeError ( 'Floating point precision is undefined.' ) if unsegmented : info . update ( dict ( n_categories = 0 , n_segments = 1 , n_samples = np . fromfile ( fid , '>i4' , 1 ) [ 0 ] , n_events = np . fromfile ( fid , '>i2' , 1 ) [ 0 ] , event_codes = [ ] , category_names = [ ] , category_lengths = [ ] , pre_baseline = 0 ) ) for event in range ( info [ 'n_events' ] ) : event_codes = '' . join ( np . fromfile ( fid , 'S1' , 4 ) . astype ( 'U1' ) ) info [ 'event_codes' ] . append ( event_codes ) info [ 'event_codes' ] = np . array ( info [ 'event_codes' ] ) else : raise NotImplementedError ( 'Only continuous files are supported' ) info [ 'unsegmented' ] = unsegmented ( info [ 'dtype' ] , info [ 'orig_format' ] ) = { 2 : ( '>i2' , 'short' ) , 4 : ( '>f4' , 'float' ) , 6 : ( '>f8' , 'double' ) } [ precision ] info [ 'dtype' ] = np . dtype ( info [ 'dtype' ] ) return info
read amf l{message} header from the stream .