code: def _parse_nedf_header(header):
      """Read header information from the first 10kB of an .nedf file.
  
      Parameters
      ----------
      header : bytes
          Null-terminated header data, mostly the file's first 10240 bytes.
  
      Returns
      -------
      info : dict
          A dictionary with header information.
      dt : numpy.dtype
          Structure of the binary EEG/accelerometer/trigger data in the file.
      n_samples : int
          The number of data samples.
      """
      defusedxml = _soft_import("defusedxml", "reading NEDF data")
      info = {}
      # nedf files have three accelerometer channels sampled at 100Hz followed
      # by five EEG samples + TTL trigger sampled at 500Hz
      # For 32 EEG channels and no stim channels, the data layout may look like
      # [ ('acc', '>u2', (3,)),
      #   ('data', dtype([
      #       ('eeg', 'u1', (32, 3)),
      #       ('trig', '>i4', (1,))
      #   ]), (5,))
      # ]
  
      dt = []  # dtype for the binary data block
      datadt = []  # dtype for a single EEG sample
  
      headerend = header.find(b"\0")
      if headerend == -1:
          raise RuntimeError("End of header null not found")
      headerxml = defusedxml.ElementTree.fromstring(header[:headerend])
      nedfversion = headerxml.findtext("NEDFversion", "")
      if nedfversion not in ["1.3", "1.4"]:
          warn("NEDFversion unsupported, use with caution")
  
      if (
          headerxml.findtext("stepDetails/DeviceClass", "")
          == "STARSTIM"
      ):
          warn("Found Starstim, this hasn't been tested extensively!")
  
      if headerxml.findtext("AdditionalChannelStatus", "OFF") != "OFF":
          raise RuntimeError("Unknown additional channel, aborting.")
  
      n_acc = int(
          headerxml.findtext("NumberOfChannelsOfAccelerometer", 0)
      )
      if n_acc:
          # expect one sample of u16 accelerometer data per block
          dt.append(("acc", ">u2", (n_acc,)))
  
      eegset = headerxml.find("EEGSettings")
      if eegset is None:
          raise RuntimeError("No EEG channels found")
      nchantotal = int(_getsubnodetext(eegset, "TotalNumberOfChannels"))
      info["nchan"] = nchantotal
  
      info["sfreq"] = int(_getsubnodetext(eegset, "EEGSamplingRate"))
      info["ch_names"] = [e.text for e in eegset.find("EEGMontage")]
      if nchantotal != len(info["ch_names"]):
          raise RuntimeError(
              f"TotalNumberOfChannels ({nchantotal}) != "
              f"channel count ({len(info['ch_names'])})"
          )
      # expect nchantotal uint24s
      datadt.append(("eeg", "B", (nchantotal, 3)))
  
      if headerxml.find("STIMSettings") is not None:
          # 2* -> two stim samples per eeg sample
          datadt.append(("stim", "B", (2, nchantotal, 3)))
          warn("stim channels are currently ignored")
  
      # Trigger data: 4 bytes in newer versions, 1 byte in older versions
      trigger_type = ">i4" if headerxml.findtext("NEDFversion") else "B"
      datadt.append(("trig", trigger_type))
      # 5 data samples per block
      dt.append(("data", np.dtype(datadt), (5,)))
  
      date = headerxml.findtext(
          "StepDetails/StartDate_firstEEGTimestamp", 0
      )
      info["meas_date"] = datetime.fromtimestamp(
          int(date) / 1000, timezone.utc
      )
  
      n_samples = int(_getsubnodetext(eegset, "NumberOfRecordsOfEEG"))
      n_full, n_last = divmod(n_samples, 5)
      dt_last = deepcopy(dt)
      assert dt_last[-1][-1] == (5,)
      dt_last[-1] = list(dt_last[-1])
      dt_last[-1][-1] = (n_last,)
      dt_last[-1] = tuple(dt_last[-1])
      return info, np.dtype(dt), np.dtype(dt_last), n_samples, n_full
  
file_path: mne-python/mne/io/nedf/nedf.py
imports: from copy import deepcopy
  from datetime import datetime, timezone
  import numpy
  from ..._fiff.meas_info import create_info
  from ..._fiff.utils import _mult_cal_one
  from ...utils import _check_fname, _soft_import, verbose, warn
  from ..base import BaseRaw
label_desc: Use image node_id 2 for calling a global function with example usage: _parse_nedf_header(header) and returns: info,  np,  np,  n_samples,  n_full