code: def test_ica_eeg(fname, grade):
      """Test ICA on EEG."""
      method = "fastica"
      if fname.suffix == ".fif":
          raw = read_raw_fif(fif_fname)
          raw.pick(raw.ch_names[::5]).load_data()
          raw.info.normalize_proj()
      elif fname.suffix == ".set":
          raw = read_raw_eeglab(input_fname=eeglab_fname, preload=True)
      else:
          with pytest.warns(RuntimeWarning, match="MISC channel"):
              raw = read_raw_ctf(ctf_fname2)
          raw.pick(raw.ch_names[:30] + raw.ch_names[30::10]).load_data()
      if grade is not None:
          raw.apply_gradient_compensation(grade)
  
      events = make_fixed_length_events(
          raw, 99999, start=0, stop=0.3, duration=0.1
      )
      picks_meg = pick_types(
          raw.info, meg=True, eeg=False, ref_meg=False
      )[:2]
      picks_eeg = pick_types(raw.info, meg=False, eeg=True)[:2]
      picks_all = []
      picks_all.extend(picks_meg)
      picks_all.extend(picks_eeg)
      epochs = Epochs(
          raw,
          events=events,
          tmin=-0.1,
          tmax=0.1,
          baseline=None,
          preload=True,
          proj=False,
      )
      evoked = epochs.average()
  
      for picks in [picks_meg, picks_eeg, picks_all]:
          if len(picks) == 0:
              continue
          # test fit
          for inst in [raw, epochs]:
              ica = ICA(n_components=2, max_iter=2, method=method)
              with _record_warnings():
                  ica.fit(inst, picks=picks, verbose=True)
              _assert_ica_attributes(ica)
  
          # test apply and get_sources
          for inst in [raw, epochs, evoked]:
              ica.apply(inst)
              ica.get_sources(inst)
  
imports: import os
  import shutil
  from contextlib import nullcontext
  from pathlib import Path
  import matplotlib.pyplot
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from scipy import linalg, stats
  from scipy.io import loadmat, savemat
  from mne import Annotations, Epochs, EpochsArray, EvokedArray, Info, create_info, make_ad_hoc_cov, pick_channels_regexp, pick_types, read_events
  from mne._fiff.pick import _DATA_CH_TYPES_SPLIT, get_channel_type_constants
  from mne.cov import read_cov
  from mne.datasets import testing
  from mne.event import make_fixed_length_events
  from mne.io import RawArray, read_raw_ctf, read_raw_eeglab, read_raw_fif
  from mne.io.eeglab.eeglab import _check_load_mat
  from mne.preprocessing import ICA
  from mne.preprocessing import ica_find_ecg_events, ica_find_eog_events, read_ica
  from mne.preprocessing.ica import _ica_explained_variance, _sort_components, corrmap, get_score_funcs, read_ica_eeglab
  from mne.rank import _compute_rank_int
  from mne.utils import _record_warnings, catch_logging, check_version
label_desc: Use image node_id 26 for calling a global function with example usage: test_ica_eeg(fname, grade) without return types