code: def test_regress_artifact():
      """Test regressing artifact data."""
      raw = read_raw_fif(raw_fname).pick(["eeg", "eog"])
      raw.load_data()
      epochs = create_eog_epochs(raw)
      epochs.apply_baseline((None, None))
      orig_data = epochs.get_data("eeg")
      orig_norm = np.linalg.norm(orig_data)
      epochs_clean, betas = regress_artifact(epochs)
      regress_artifact(
          epochs, betas=betas, copy=False
      )  # inplace, and w/betas
      assert_allclose(
          epochs_clean.get_data(copy=False), epochs.get_data(copy=False)
      )
      clean_data = epochs_clean.get_data("eeg")
      clean_norm = np.linalg.norm(clean_data)
      assert orig_norm / 2 > clean_norm > orig_norm / 10
      with pytest.raises(
          ValueError, match=r"Invalid value.*betas\.shape.*"
      ):
          regress_artifact(epochs, betas=betas[:-1])
      # Regressing channels onto themselves should work
      epochs, betas = regress_artifact(
          epochs, picks="eog", picks_artifact="eog"
      )
      assert np.ptp(epochs.get_data("eog")) < 1e-15  # constant value
      assert_allclose(betas, 1)
  
file_path: mne-python/mne/preprocessing/tests/test_regress.py
imports: import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal, assert_array_less
  from mne import pick_types
  from mne.datasets import testing
  from mne.io import read_raw_fif
  from mne.preprocessing import EOGRegression, create_eog_epochs, read_eog_regression, regress_artifact
label_desc: Use image node_id 1 for calling a global function with example usage: test_regress_artifact() without return types