code: def test_plot_ica_overlay():
      """Test plotting of ICA cleaning."""
      raw = _get_raw(preload=True)
      with raw.info._unlock():
          raw.info["highpass"] = 1.0  # fake high-pass filtering
      picks = _get_picks(raw)
      ica = ICA(
          noise_cov=read_cov(cov_fname), n_components=2, random_state=0
      )
      # overlay plotting requires a fitted ICA
      with pytest.raises(RuntimeError, match="need to fit"):
          ica.plot_overlay(inst=raw)
      # can't use info.normalize_proj here because of how and when ICA and Epochs
      # objects do picking of Raw data
      with pytest.warns(RuntimeWarning, match="projection"):
          ica.fit(raw, picks=picks)
      # don't test raw, needs preload ...
      with pytest.warns(RuntimeWarning, match="projection"):
          ecg_epochs = create_ecg_epochs(raw, picks=picks)
      ica.plot_overlay(ecg_epochs.average())
      with pytest.warns(RuntimeWarning, match="projection"):
          eog_epochs = create_eog_epochs(raw, picks=picks)
      ica.plot_overlay(eog_epochs.average(), n_pca_components=2)
      pytest.raises(TypeError, ica.plot_overlay, raw[:2, :3][0])
      pytest.raises(TypeError, ica.plot_overlay, raw, exclude=2)
      ica.plot_overlay(raw)
      plt.close("all")
  
      # smoke test for CTF
      raw = read_raw_fif(raw_ctf_fname)
      raw.apply_gradient_compensation(3)
      with raw.info._unlock():
          raw.info["highpass"] = 1.0  # fake high-pass filtering
      picks = pick_types(raw.info, meg=True, ref_meg=False)
      ica = ICA(
          n_components=2,
      )
      ica.fit(raw, picks=picks)
      with pytest.warns(RuntimeWarning, match="longer than"):
          ecg_epochs = create_ecg_epochs(raw)
      ica.plot_overlay(ecg_epochs.average())
  
imports: import sys
  from pathlib import Path
  import matplotlib.pyplot
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal, assert_equal
  from mne import Annotations, Epochs, make_fixed_length_events, pick_types, read_cov, read_events
  from mne.io import read_raw_fif
  from mne.preprocessing import ICA, create_ecg_epochs, create_eog_epochs
  from mne.utils import _record_warnings, catch_logging
  from mne.viz.ica import _create_properties_layout, plot_ica_properties
  from mne.viz.utils import _fake_click, _fake_keypress
label_desc: Use image node_id 8 for calling a global function with example usage: test_plot_ica_overlay() without return types