code: def pick_info(info, sel=(), copy=True, verbose=None):
      """Restrict an info structure to a selection of channels.
  
      Parameters
      ----------
      %(info_not_none)s
      sel : list of int | None
          Indices of channels to include. If None, all channels
          are included.
      copy : bool
          If copy is False, info is modified inplace.
      %(verbose)s
  
      Returns
      -------
      res : dict
          Info structure restricted to a selection of channels.
      """
      # avoid circular imports
      from .meas_info import _bad_chans_comp
  
      info._check_consistency()
      info = info.copy() if copy else info
      if sel is None:
          return info
      elif len(sel) == 0:
          raise ValueError("No channels match the selection.")
      n_unique = len(np.unique(np.arange(len(info["ch_names"]))[sel]))
      if n_unique != len(sel):
          raise ValueError(
              "Found %d / %d unique names, sel is not unique"
              % (n_unique, len(sel))
          )
  
      # make sure required the compensation channels are present
      if len(info.get("comps", [])) > 0:
          ch_names = [info["ch_names"][idx] for idx in sel]
          _, comps_missing = _bad_chans_comp(info, ch_names)
          if len(comps_missing) > 0:
              logger.info(
                  "Removing %d compensators from info because "
                  "not all compensation channels were picked."
                  % (len(info["comps"]),)
              )
              with info._unlock():
                  info["comps"] = []
      with info._unlock():
          info["chs"] = [info["chs"][k] for k in sel]
      info._update_redundant()
      info["bads"] = [
          ch for ch in info["bads"] if ch in info["ch_names"]
      ]
      if "comps" in info:
          comps = deepcopy(info["comps"])
          for c in comps:
              row_idx = [
                  k
                  for k, n in enumerate(c["data"]["row_names"])
                  if n in info["ch_names"]
              ]
              row_names = [c["data"]["row_names"][i] for i in row_idx]
              rowcals = c["rowcals"][row_idx]
              c["rowcals"] = rowcals
              c["data"]["nrow"] = len(row_names)
              c["data"]["row_names"] = row_names
              c["data"]["data"] = c["data"]["data"][row_idx]
          with info._unlock():
              info["comps"] = comps
      if info.get("custom_ref_applied", False) and not _electrode_types(
          info
      ):
          with info._unlock():
              info["custom_ref_applied"] = FIFF.FIFFV_MNE_CUSTOM_REF_OFF
      info._check_consistency()
  
      return info
  
imports: import re
  from copy import deepcopy
  import numpy
  from ..utils import _check_option, _ensure_int, _validate_type, fill_doc, logger, verbose, warn
  from .constants import FIFF
label_desc: Use image node_id 11 for calling a global function with example usage: pick_info(info, sel, copy, verbose) and returns: info, info