code: def _read_header(filename):
      
      header = _read_header_text(filename)
      first_row = header[0]
      EXTRA_ROWS = 3  # drop DefaultValue1 LowRange1 HighRange1
  
      hdr = {}
      for group in finditer('(\w*)= ([\w.]*)', first_row):
          hdr[group.group(1)] = group.group(2)
  
      if first_row.startswith('BCI2000V'):
          VERSION = hdr['BCI2000V']
  
      else:
          VERSION = '1'
          hdr['DataFormat'] = 'int16'
  
      for row in header[1:]:
          if row.startswith('['):  # remove '[ ... Definition ]'
              section = row[2:-14].replace(' ', '')
  
              if section == 'StateVector':
                  hdr[section] = []
              else:
                  hdr[section] = {} # defaultdict(dict)
              continue
  
          if row == '':
              continue
  
          elif section == 'StateVector':
              statevector = {key: value for key, value in list(zip(STATEVECTOR, row.split(' ')))}
              hdr[section].append(statevector)
  
          else:
              group = match('(?P<subsection>[\w:%]*) (?P<format>\w*) (?P<key>\w*)= (?P<value>.*) // ', row)
              onerow = group.groupdict()
  
              values = onerow['value'].split(' ')
              if len(values) > EXTRA_ROWS:
                  value = ' '.join(onerow['value'].split(' ')[:-EXTRA_ROWS])
              else:
                  value = ' '.join(values)
  
              hdr[section][onerow['key']] = value  # similar to matlab's output
  
      return hdr
docs: It's a pain to parse the header. It might be better to use the cpp code
      but I would need to include it here.