

def _interpolate_bads_meg(inst, mode='accurate', verbose=None):
    "Interpolate bad channels from data in good channels.\n\n    Parameters\n    ----------\n    inst : mne.io.Raw, mne.Epochs or mne.Evoked\n        The data to interpolate. Must be preloaded.\n    mode : str\n        Either `'accurate'` or `'fast'`, determines the quality of the\n        Legendre polynomial expansion used for interpolation. `'fast'` should\n        be sufficient for most applications.\n    verbose : bool, str, int, or None\n        If not None, override default verbose level (see mne.verbose).\n    "
    picks_meg = pick_types(inst.info, meg=True, eeg=False, exclude=[])
    ch_names = [inst.info['ch_names'][p] for p in picks_meg]
    picks_good = pick_types(inst.info, meg=True, eeg=False, exclude='bads')
    if (len(inst.info['bads']) == 0):
        picks_bad = []
    else:
        picks_bad = pick_channels(ch_names, inst.info['bads'], exclude=[])
    if ((len(picks_meg) == 0) or (len(picks_bad) == 0)):
        return
    info_from = pick_info(inst.info, picks_good)
    info_to = pick_info(inst.info, picks_bad)
    mapping = _map_meg_channels(info_from, info_to, mode=mode)
    _do_interp_dots(inst, mapping, picks_good, picks_bad)

dataset/ETHPy150Open mne-tools/mne-python/mne/channels/interpolation.py _interpolate_bads_meg/original