code: def test_regress_artifact_bads():
      """Test that bad channels are handled properly."""
      # Pick the first few EEG channels
      raw = (
          read_raw_fif(raw_fname)
          .del_proj()
          .set_eeg_reference(projection=True)
      )
      picks_all = np.concatenate(
          [
              pick_types(raw.info, meg=True)[:4],
              pick_types(raw.info, eeg=True)[:8],
              pick_types(raw.info, eog=True)[:1],
          ]
      )
      raw.pick(picks_all).load_data()
      assert len(raw.ch_names) == 13  # 4 MEG, 8 EEG, 1 EOG
      del picks_all
      picks = pick_types(raw.info, eeg=True)
      assert_array_equal(picks, np.arange(4, 12))
      norms = np.linalg.norm(raw.get_data(picks), axis=1)
      raw_reg, _ = regress_artifact(
          raw, picks=picks, picks_artifact="eog"
      )
      assert_allclose(
          raw_reg.get_data("meg"), raw.get_data("meg")
      )  # unchanged
      data_reg = raw_reg.get_data()
      norms_reg = np.linalg.norm(data_reg[picks], axis=1)
      suppression = 20 * np.log10(norms / norms_reg)
      assert_array_less(3, suppression)  # at least 3 dB suppression
      # Adding some bad channels shouldn't affect anything when we supply picks
      raw.info["bads"] = raw.ch_names[:2] + raw.ch_names[-2:-1]
      raw_reg, _ = regress_artifact(
          raw, picks=picks, picks_artifact="eog"
      )
      data_reg_new = raw_reg.get_data()
      assert_allclose(data_reg, data_reg_new)
  
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 4 for calling a global function with example usage: test_regress_artifact_bads() without return types