code: def test_io_egi():
      """Test importing EGI simple binary files."""
      # test default
      with open(egi_txt_fname) as fid:
          data = np.loadtxt(fid)
      t = data[0]
      data = data[1:]
      data *= 1e-6  # µV
  
      with pytest.warns(
          RuntimeWarning, match="Did not find any event code"
      ):
          raw = read_raw_egi(egi_fname, include=None)
  
      # The reader should accept a Path, too.
      with pytest.warns(
          RuntimeWarning, match="Did not find any event code"
      ):
          raw = read_raw_egi(Path(egi_fname), include=None)
  
      assert "RawEGI" in repr(raw)
      data_read, t_read = raw[:256]
      assert_allclose(t_read, t)
      assert_allclose(data_read, data, atol=1e-10)
  
      include = ["TRSP", "XXX1"]
      raw = _test_raw_reader(
          read_raw_egi,
          input_fname=egi_fname,
          include=include,
          test_rank="less",
          test_scaling=False,  # XXX probably some bug
      )
  
      assert "eeg" in raw
      assert raw.orig_format == "single"
      eeg_chan = [c for c in raw.ch_names if c.startswith("E")]
      assert len(eeg_chan) == 256
      picks = pick_types(raw.info, eeg=True)
      assert len(picks) == 256
      assert "STI 014" in raw.ch_names
  
      events = find_events(raw, stim_channel="STI 014")
      assert len(events) == 2  # ground truth
      assert np.unique(events[:, 1])[0] == 0
      assert np.unique(events[:, 0])[0] != 0
      assert np.unique(events[:, 2])[0] != 0
      triggers = np.array([[0, 1, 1, 0], [0, 0, 1, 0]])
  
      # test trigger functionality
      triggers = np.array([[0, 1, 0, 0], [0, 0, 1, 0]])
      events_ids = [12, 24]
      new_trigger = _combine_triggers(triggers, events_ids)
      assert_array_equal(np.unique(new_trigger), np.unique([0, 12, 24]))
  
      pytest.raises(
          ValueError,
          read_raw_egi,
          egi_fname,
          include=["Foo"],
          preload=False,
      )
      pytest.raises(
          ValueError,
          read_raw_egi,
          egi_fname,
          exclude=["Bar"],
          preload=False,
      )
      for ii, k in enumerate(include, 1):
          assert k in raw.event_id
          assert raw.event_id[k] == ii
  
imports: import os
  import shutil
  from copy import deepcopy
  from datetime import datetime, timezone
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from scipy import io
  from mne import find_events, pick_types
  from mne._fiff.constants import FIFF
  from mne.datasets.testing import data_path, requires_testing_data
  from mne.io import read_evokeds_mff, read_raw_egi, read_raw_fif
  from mne.io.egi.egi import _combine_triggers
  from mne.io.tests.test_raw import _test_raw_reader
  from mne.utils import object_diff
label_desc: Use image node_id 4 for calling a global function with example usage: test_io_egi() without return types