xdawn.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:decoding_challenge_cortana_2016_3rd 作者: kingjr 项目源码 文件源码
def least_square_evoked(epochs, return_toeplitz=False):
    """Least square estimation of evoked response from a Epochs instance.

    Parameters
    ----------
    epochs : Epochs instance
        An instance of Epochs.
    return_toeplitz : bool (default False)
        If true, compute the toeplitz matrix.

    Returns
    -------
    evokeds : dict of evoked instance
        An dict of evoked instance for each event type in epochs.event_id.
    toeplitz : dict of ndarray
        If return_toeplitz is true, return the toeplitz matrix for each event
        type in epochs.event_id.
    """
    if not isinstance(epochs, _BaseEpochs):
        raise ValueError('epochs must be an instance of `mne.Epochs`')

    events = epochs.events.copy()
    events[:, 0] -= (np.min(events[:, 0]) +
                     int(epochs.tmin * epochs.info['sfreq']))
    data = _construct_signal_from_epochs(epochs)
    evoked_data, toeplitz = _least_square_evoked(data, events, epochs.event_id,
                                                 tmin=epochs.tmin,
                                                 tmax=epochs.tmax,
                                                 sfreq=epochs.info['sfreq'])
    evokeds = dict()
    info = cp.deepcopy(epochs.info)
    for name, data in evoked_data.items():
        n_events = len(events[events[:, 2] == epochs.event_id[name]])
        evoked = EvokedArray(data, info, tmin=epochs.tmin,
                             comment=name, nave=n_events)
        evokeds[name] = evoked

    if return_toeplitz:
        return evokeds, toeplitz

    return evokeds
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号