code: def test_picks_to_idx():
      """Test checking type integrity checks of picks."""
      info = create_info(12, 1000.0, "eeg")
      _assert_channel_types(info)
      picks = np.arange(info["nchan"])
      # Array and list
      assert_array_equal(picks, _picks_to_idx(info, picks))
      assert_array_equal(picks, _picks_to_idx(info, list(picks)))
      with pytest.raises(
          TypeError, match="data type float64 is invalid"
      ):
          _picks_to_idx(info, 1.0)
      # None
      assert_array_equal(picks, _picks_to_idx(info, None))
      # Type indexing
      assert_array_equal(picks, _picks_to_idx(info, "eeg"))
      assert_array_equal(picks, _picks_to_idx(info, ["eeg"]))
      # Negative indexing
      assert_array_equal(
          [len(picks) - 1], _picks_to_idx(info, len(picks) - 1)
      )
      assert_array_equal([len(picks) - 1], _picks_to_idx(info, -1))
      assert_array_equal([len(picks) - 1], _picks_to_idx(info, [-1]))
      # Name indexing
      assert_array_equal([2], _picks_to_idx(info, info["ch_names"][2]))
      assert_array_equal(
          np.arange(5, 9), _picks_to_idx(info, info["ch_names"][5:9])
      )
      with pytest.raises(IndexError, match="must be >= "):
          _picks_to_idx(info, -len(picks) - 1)
      with pytest.raises(IndexError, match="must be < "):
          _picks_to_idx(info, len(picks))
      with pytest.raises(ValueError, match="could not be interpreted"):
          _picks_to_idx(info, ["a", "b"])
      with pytest.raises(ValueError, match="could not be interpreted"):
          _picks_to_idx(info, "b")
      # bads behavior
      info["bads"] = info["ch_names"][1:2]
      picks_good = np.array([0] + list(range(2, 12)))
      assert_array_equal(picks_good, _picks_to_idx(info, None))
      assert_array_equal(
          picks_good, _picks_to_idx(info, None, exclude=info["bads"])
      )
      assert_array_equal(picks, _picks_to_idx(info, None, exclude=()))
      with pytest.raises(ValueError, match=" 1D, got"):
          _picks_to_idx(info, [[1]])
      # MEG types
      info = read_info(fname_mc)
      meg_picks = np.arange(306)
      mag_picks = np.arange(2, 306, 3)
      grad_picks = np.setdiff1d(meg_picks, mag_picks)
      assert_array_equal(meg_picks, _picks_to_idx(info, "meg"))
      assert_array_equal(
          meg_picks, _picks_to_idx(info, ("mag", "grad"))
      )
      assert_array_equal(mag_picks, _picks_to_idx(info, "mag"))
      assert_array_equal(grad_picks, _picks_to_idx(info, "grad"))
  
      info = create_info(["eeg", "foo"], 1000.0, "eeg")
      with pytest.raises(
          RuntimeError, match="equivalent to channel types"
      ):
          _picks_to_idx(info, "eeg")
      with pytest.raises(ValueError, match="same length"):
          create_info(["a", "b"], 1000.0, dict(hbo=["a"], hbr=["b"]))
      info = create_info(["a", "b"], 1000.0, ["hbo", "hbr"])
      assert_array_equal(np.arange(2), _picks_to_idx(info, "fnirs"))
      assert_array_equal([0], _picks_to_idx(info, "hbo"))
      assert_array_equal([1], _picks_to_idx(info, "hbr"))
      info = create_info(["a", "b"], 1000.0, ["hbo", "misc"])
      assert_array_equal(
          np.arange(len(info["ch_names"])), _picks_to_idx(info, "all")
      )
      assert_array_equal([0], _picks_to_idx(info, "data"))
      info = create_info(
          ["a", "b"], 1000.0, ["fnirs_cw_amplitude", "fnirs_od"]
      )
      assert_array_equal(np.arange(2), _picks_to_idx(info, "fnirs"))
      assert_array_equal([0], _picks_to_idx(info, "fnirs_cw_amplitude"))
      assert_array_equal([1], _picks_to_idx(info, "fnirs_od"))
      info = create_info(
          ["a", "b"], 1000.0, ["fnirs_cw_amplitude", "misc"]
      )
      assert_array_equal(
          np.arange(len(info["ch_names"])), _picks_to_idx(info, "all")
      )
      assert_array_equal([0], _picks_to_idx(info, "data"))
      info = create_info(["a", "b"], 1000.0, ["fnirs_od", "misc"])
      assert_array_equal(
          np.arange(len(info["ch_names"])), _picks_to_idx(info, "all")
      )
      assert_array_equal([0], _picks_to_idx(info, "data"))
      # MEG reference sensors
      info_ref = read_info(ctf_fname)
      picks_meg = pick_types(info_ref, meg=True, ref_meg=False)
      assert len(picks_meg) == 275
      picks_ref = pick_types(info_ref, meg=False, ref_meg=True)
      assert len(picks_ref) == 29
      picks_meg_ref = np.sort(np.concatenate([picks_meg, picks_ref]))
      assert len(picks_meg_ref) == 275 + 29
      assert_array_equal(
          picks_meg_ref, pick_types(info_ref, meg=True, ref_meg=True)
      )
      assert_array_equal(
          picks_meg, _picks_to_idx(info_ref, "meg", with_ref_meg=False)
      )
      assert_array_equal(  # explicit trumps implicit
          picks_ref,
          _picks_to_idx(info_ref, "ref_meg", with_ref_meg=False),
      )
      assert_array_equal(
          picks_meg_ref,
          _picks_to_idx(info_ref, "meg", with_ref_meg=True),
      )
      # Eyetrack
      info = create_info(["a", "b"], 1000.0, ["eyegaze", "pupil"])
      assert_array_equal(np.arange(2), _picks_to_idx(info, "eyetrack"))
      assert_array_equal([0], _picks_to_idx(info, "eyegaze"))
      assert_array_equal([1], _picks_to_idx(info, "pupil"))
  
imports: from copy import deepcopy
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_array_equal
  from mne import Epochs, channel_indices_by_type, channel_type, create_info, make_ad_hoc_cov, pick_channels, pick_channels_cov, pick_channels_regexp, pick_info, pick_types, pick_types_forward, read_forward_solution, rename_channels
  from mne._fiff.constants import FIFF
  from mne._fiff.pick import _DATA_CH_TYPES_SPLIT, _contains_ch_type, _picks_by_type, _picks_to_idx, get_channel_type_constants
  from mne.channels import make_standard_montage
  from mne.datasets import testing
  from mne.io import RawArray, read_info, read_raw_bti, read_raw_fif, read_raw_kit
  from mne.preprocessing import compute_current_source_density
  from mne.utils import assert_object_equal, catch_logging
label_desc: Use image node_id 18 for calling a global function with example usage: test_picks_to_idx() without return types