@verbose
def rap_music(evoked, forward, noise_cov, n_dipoles=5, return_residual=False,
              picks=None, verbose=None):

    info = evoked.info
    data = evoked.data
    times = evoked.times

    picks = _setup_picks(picks, info, forward, noise_cov)

    data = data[picks]

    dipoles, explained_data = _apply_rap_music(data, info, times, forward,
                                               noise_cov, n_dipoles,
                                               picks, return_residual)

    if return_residual:
        residual = evoked.copy()
        selection = [info['ch_names'][p] for p in picks]

        residual = pick_channels_evoked(residual,
                                        include=selection)
        residual.data -= explained_data
        active_projs = [p for p in residual.info['projs'] if p['active']]
        for p in active_projs:
            p['active'] = False
        residual.add_proj(active_projs, remove_existing=True)
        residual.apply_proj()
        return dipoles, residual
    else:
        return dipoles
RAP-MUSIC source localization method.
dataset/ETHPy150Open mne-tools/mne-python/mne/beamformer/_rap_music.py/rap_music