code: def _get_cnt_info(
      input_fname, eog, ecg, emg, misc, data_format, date_format, header
  ):
      """Read the cnt header."""
      data_offset = 900  # Size of the 'SETUP' header.
      cnt_info = dict()
      # Reading only the fields of interest. Structure of the whole header at
      # http://paulbourke.net/dataformats/eeg/
      with open(input_fname, "rb", buffering=0) as fid:
          fid.seek(21)
          patient_id = read_str(fid, 20)
          patient_id = int(patient_id) if patient_id.isdigit() else 0
          fid.seek(121)
          patient_name = read_str(fid, 20).split()
          last_name = patient_name[0] if len(patient_name) > 0 else ""
          first_name = patient_name[-1] if len(patient_name) > 0 else ""
          fid.seek(2, 1)
          sex = read_str(fid, 1)
          if sex == "M":
              sex = FIFF.FIFFV_SUBJ_SEX_MALE
          elif sex == "F":
              sex = FIFF.FIFFV_SUBJ_SEX_FEMALE
          else:  # can be 'U'
              sex = FIFF.FIFFV_SUBJ_SEX_UNKNOWN
          hand = read_str(fid, 1)
          if hand == "R":
              hand = FIFF.FIFFV_SUBJ_HAND_RIGHT
          elif hand == "L":
              hand = FIFF.FIFFV_SUBJ_HAND_LEFT
          else:  # can be 'M' for mixed or 'U'
              hand = None
          fid.seek(205)
          session_label = read_str(fid, 20)
  
          session_date = "%s %s" % (
              read_str(fid, 10),
              read_str(fid, 12),
          )
          meas_date = _session_date_2_meas_date(
              session_date, date_format
          )
  
          fid.seek(370)
          n_channels = np.fromfile(fid, dtype="<u2", count=1).item()
          fid.seek(376)
          sfreq = np.fromfile(fid, dtype="<u2", count=1).item()
          if eog == "header":
              fid.seek(402)
              eog = [
                  idx
                  for idx in np.fromfile(fid, dtype="i2", count=2)
                  if idx >= 0
              ]
          fid.seek(438)
          lowpass_toggle = np.fromfile(fid, "i1", count=1).item()
          highpass_toggle = np.fromfile(fid, "i1", count=1).item()
  
          # Header has a field for number of samples, but it does not seem to be
          # too reliable. That's why we have option for setting n_bytes manually.
          fid.seek(864)
          n_samples = np.fromfile(fid, dtype="<i4", count=1).item()
          fid.seek(869)
          lowcutoff = np.fromfile(fid, dtype="f4", count=1).item()
          fid.seek(2, 1)
          highcutoff = np.fromfile(fid, dtype="f4", count=1).item()
  
          event_offset = _compute_robust_event_table_position(
              fid=fid, data_format=data_format
          )
          fid.seek(890)
          cnt_info["continuous_seconds"] = np.fromfile(
              fid, dtype="<f4", count=1
          ).item()
  
          if event_offset < data_offset:  # no events
              data_size = n_samples * n_channels
          else:
              data_size = event_offset - (data_offset + 75 * n_channels)
  
          _check_option(
              "data_format", data_format, ["auto", "int16", "int32"]
          )
          if data_format == "auto":
              if n_samples == 0 or data_size // (
                  n_samples * n_channels
              ) not in [2, 4]:
                  warn(
                      "Could not define the number of bytes automatically. "
                      "Defaulting to 2."
                  )
                  n_bytes = 2
                  n_samples = data_size // (n_bytes * n_channels)
              else:
                  n_bytes = data_size // (n_samples * n_channels)
          else:
              n_bytes = 2 if data_format == "int16" else 4
              n_samples = data_size // (n_bytes * n_channels)
  
          # Channel offset refers to the size of blocks per channel in the file.
          cnt_info["channel_offset"] = np.fromfile(
              fid, dtype="<i4", count=1
          ).item()
          if cnt_info["channel_offset"] > 1:
              cnt_info["channel_offset"] //= n_bytes
          else:
              cnt_info["channel_offset"] = 1
  
          ch_names, cals, baselines, chs, pos = (
              list(),
              list(),
              list(),
              list(),
              list(),
          )
  
          bads = list()
          _validate_type(header, str, "header")
          _check_option("header", header, ("auto", "new", "old"))
          for ch_idx in range(n_channels):  # ELECTLOC fields
              fid.seek(data_offset + 75 * ch_idx)
              ch_name = read_str(fid, 10)
              ch_names.append(ch_name)
  
              # Some files have bad channels marked differently in the header.
              if header in ("new", "auto"):
                  fid.seek(data_offset + 75 * ch_idx + 14)
                  if np.fromfile(fid, dtype="u1", count=1).item():
                      bads.append(ch_name)
              if header in ("old", "auto"):
                  fid.seek(data_offset + 75 * ch_idx + 4)
                  if np.fromfile(fid, dtype="u1", count=1).item():
                      bads.append(ch_name)
  
              fid.seek(data_offset + 75 * ch_idx + 19)
              xy = np.fromfile(fid, dtype="f4", count=2)
              xy[1] *= -1  # invert y-axis
              pos.append(xy)
              fid.seek(data_offset + 75 * ch_idx + 47)
              # Baselines are subtracted before scaling the data.
              baselines.append(
                  np.fromfile(fid, dtype="i2", count=1).item()
              )
              fid.seek(data_offset + 75 * ch_idx + 59)
              sensitivity = np.fromfile(fid, dtype="f4", count=1).item()
              fid.seek(data_offset + 75 * ch_idx + 71)
              cal = np.fromfile(fid, dtype="f4", count=1).item()
              cals.append(cal * sensitivity * 1e-6 / 204.8)
  
      info = _empty_info(sfreq)
      if lowpass_toggle == 1:
          info["lowpass"] = highcutoff
      if highpass_toggle == 1:
          info["highpass"] = lowcutoff
      subject_info = {
          "hand": hand,
          "id": patient_id,
          "sex": sex,
          "first_name": first_name,
          "last_name": last_name,
      }
  
      if eog == "auto":
          eog = _find_channels(ch_names, "EOG")
      if ecg == "auto":
          ecg = _find_channels(ch_names, "ECG")
      if emg == "auto":
          emg = _find_channels(ch_names, "EMG")
  
      chs = _create_chs(
          ch_names,
          cals,
          FIFF.FIFFV_COIL_EEG,
          FIFF.FIFFV_EEG_CH,
          eog,
          ecg,
          emg,
          misc,
      )
      eegs = [
          idx
          for idx, ch in enumerate(chs)
          if ch["coil_type"] == FIFF.FIFFV_COIL_EEG
      ]
      coords = _topo_to_sphere(pos, eegs)
      locs = np.full((len(chs), 12), np.nan)
      locs[:, :3] = coords
      dig = _make_dig_points(
          dig_ch_pos=dict(zip(ch_names, coords)),
          coord_frame="head",
          add_missing_fiducials=True,
      )
      for ch, loc in zip(chs, locs):
          ch.update(loc=loc)
  
      cnt_info.update(
          baselines=np.array(baselines),
          n_samples=n_samples,
          n_bytes=n_bytes,
      )
  
      session_label = (
          None if str(session_label) == "" else str(session_label)
      )
      info.update(
          meas_date=meas_date,
          dig=dig,
          description=session_label,
          subject_info=subject_info,
          chs=chs,
      )
      info._unlocked = False
      info._update_redundant()
      info["bads"] = bads
      return info, cnt_info
  
file_path: mne-python/mne/io/cnt/cnt.py
imports: from os import path
  import numpy
  from ..._fiff._digitization import _make_dig_points
  from ..._fiff.constants import FIFF
  from ..._fiff.meas_info import _empty_info
  from ..._fiff.utils import _create_chs, _find_channels, _mult_cal_one, read_str
  from ...annotations import Annotations
  from ...channels.layout import _topo_to_sphere
  from ...utils import _check_option, _validate_type, fill_doc, warn
  from ..base import BaseRaw
  from ._utils import CNTEventType3, _compute_robust_event_table_position, _get_event_parser, _read_teeg, _session_date_2_meas_date
label_desc: Use image node_id 3 for calling a global function with example usage: _get_cnt_info(input_fname, eog, ecg, emg, misc, data_format, date_format, header) and returns: info,  cnt_info