code: def _interpolate_bads_eeg(
      inst, origin, exclude=None, ecog=False, verbose=None
  ):
      if exclude is None:
          exclude = list()
      bads_idx = np.zeros(len(inst.ch_names), dtype=bool)
      goods_idx = np.zeros(len(inst.ch_names), dtype=bool)
  
      picks = pick_types(
          inst.info, meg=False, eeg=not ecog, ecog=ecog, exclude=exclude
      )
      inst.info._check_consistency()
      bads_idx[picks] = [
          inst.ch_names[ch] in inst.info["bads"] for ch in picks
      ]
  
      if len(picks) == 0 or bads_idx.sum() == 0:
          return
  
      goods_idx[picks] = True
      goods_idx[bads_idx] = False
  
      pos = inst._get_channel_positions(picks)
  
      # Make sure only EEG are used
      bads_idx_pos = bads_idx[picks]
      goods_idx_pos = goods_idx[picks]
  
      # test spherical fit
      distance = np.linalg.norm(pos - origin, axis=-1)
      distance = np.mean(distance / np.mean(distance))
      if np.abs(1.0 - distance) > 0.1:
          warn(
              "Your spherical fit is poor, interpolation results are "
              "likely to be inaccurate."
          )
  
      pos_good = pos[goods_idx_pos] - origin
      pos_bad = pos[bads_idx_pos] - origin
      logger.info(
          f"Computing interpolation matrix from {len(pos_good)} sensor positions"
      )
      interpolation = _make_interpolation_matrix(pos_good, pos_bad)
  
      logger.info(f"Interpolating {len(pos_bad)} sensors")
      _do_interp_dots(inst, interpolation, goods_idx, bads_idx)
  
imports: import numpy
  from numpy.polynomial.legendre import legval
  from scipy.interpolate import RectBivariateSpline
  from scipy.linalg import pinv
  from scipy.spatial.distance import pdist, squareform
  from .._fiff.meas_info import _simplify_info
  from .._fiff.pick import pick_channels, pick_info, pick_types
  from ..surface import _normalize_vectors
  from ..utils import _validate_type, logger, verbose, warn
label_desc: Use image node_id 5 for calling a global function with example usage: _interpolate_bads_eeg(inst, origin, exclude, ecog, verbose) without return types