code: def test_ica_projs(n_pca_components, proj, cov, picks):
      """Test that ICA handles projections properly."""
      if cov and not proj:  # proj is always done with cov
          return
      if not len(picks):  # no channels
          return
      raw = read_raw_fif(raw_fname).crop(0.5, stop).pick(picks)
      raw.pick(np.arange(0, len(raw.ch_names), 5))  # just for speed
      raw.info.normalize_proj()
      assert 10 < len(raw.ch_names) < 75
      if "eeg" in picks:
          raw.set_eeg_reference(projection=True)
      raw.load_data()
      raw._data -= raw._data.mean(-1, keepdims=True)
      raw_data = raw.get_data()
      assert len(raw.info["projs"]) > 0
      assert not raw.proj
      raw_fit = raw.copy()
      kwargs = dict(atol=1e-12 if "eeg" in picks else 1e-20, rtol=1e-8)
      if proj:
          raw_fit.apply_proj()
      fit_data = raw_fit.get_data()
      if proj:
          assert not np.allclose(raw_fit.get_data(), raw_data, **kwargs)
      else:
          assert np.allclose(raw_fit.get_data(), raw_data, **kwargs)
      assert raw_fit.proj == proj
      if cov:
          noise_cov = make_ad_hoc_cov(raw.info)
      else:
          noise_cov = None
      # infomax here just so we don't require sklearn
      ica = ICA(
          max_iter=1,
          noise_cov=noise_cov,
          method="infomax",
          n_components=10,
      )
      with _record_warnings():  # convergence
          ica.fit(raw_fit)
      if cov:
          assert ica.pre_whitener_.shape == (len(raw.ch_names),) * 2
      else:
          assert ica.pre_whitener_.shape == (len(raw.ch_names), 1)
      with catch_logging() as log:
          raw_apply = ica.apply(
              raw_fit.copy(),
              n_pca_components=n_pca_components,
              verbose=True,
          )
      log = log.getvalue()
      print(log)  # very useful for debugging, might as well leave it in
      if proj:
          assert "Applying projection" in log
      else:
          assert "Applying projection" not in log
      assert_allclose(raw_apply.get_data(), fit_data, **kwargs)
      raw_apply = ica.apply(raw.copy())
      apply_data = raw_apply.get_data()
      assert_allclose(apply_data, fit_data, **kwargs)
      if proj:
          assert not np.allclose(apply_data, raw_data, **kwargs)
      else:
          assert_allclose(apply_data, raw_data, **kwargs)
  
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 10 for calling a global function with example usage: test_ica_projs(n_pca_components, proj, cov, picks) without return types