当前位置: 首页>>代码示例>>Python>>正文


Python GeneralizationAcrossTime.estimators_方法代码示例

本文整理汇总了Python中mne.decoding.GeneralizationAcrossTime.estimators_方法的典型用法代码示例。如果您正苦于以下问题:Python GeneralizationAcrossTime.estimators_方法的具体用法?Python GeneralizationAcrossTime.estimators_怎么用?Python GeneralizationAcrossTime.estimators_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mne.decoding.GeneralizationAcrossTime的用法示例。


在下文中一共展示了GeneralizationAcrossTime.estimators_方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _run

# 需要导入模块: from mne.decoding import GeneralizationAcrossTime [as 别名]
# 或者: from mne.decoding.GeneralizationAcrossTime import estimators_ [as 别名]
def _run(epochs, events, analysis):
    """Runs temporal generalization for a given subject and analysis"""
    print(subject, analysis['name'])

    # subselect the trials (e.g. exclude absent trials) with a
    # dataframe query defined in conditions.py
    query, condition = analysis['query'], analysis['condition']
    sel = range(len(events)) if query is None \
        else events.query(query).index
    sel = [ii for ii in sel if ~np.isnan(events[condition][sel][ii])]

    # The to-be-predicted value, for each trial:
    y = np.array(events[condition], dtype=np.float32)

    print analysis['name'], np.unique(y[sel]), len(sel)

    # Abort if there is no trial
    if len(sel) == 0:
        return

    # Apply analysis
    gat = GeneralizationAcrossTime(clf=analysis['clf'],
                                   cv=analysis['cv'],
                                   scorer=analysis['scorer'],
                                   n_jobs=-1)
    print(subject, analysis['name'], 'fit')
    gat.fit(epochs[sel], y=y[sel])
    print(subject, analysis['name'], 'score')
    score = gat.score(epochs[sel], y=y[sel])
    print(subject, analysis['name'], 'save')

    # save space
    if analysis['name'] not in ['probe_phase', 'target_circAngle']:
        # we'll need the estimator trained on the probe_phase and to generalize
        # to the target phase and prove that there is a significant signal.
        gat.estimators_ = None
    if analysis['name'] not in ['target_present', 'target_circAngle',
                                'probe_circAngle']:
        # We need these individual prediction to control for the correlation
        # between target and probe angle.
        gat.y_pred_ = None

    # Save analysis
    save([gat, analysis, sel, events], 'decod',
         subject=subject, analysis=analysis['name'], overwrite=True,
         upload=True)
    save([score, epochs.times], 'score',
         subject=subject, analysis=analysis['name'], overwrite=True,
         upload=True)
    return
开发者ID:kingjr,项目名称:decoding_unconscious_maintenance,代码行数:52,代码来源:run_decoding.py

示例2: _decod

# 需要导入模块: from mne.decoding import GeneralizationAcrossTime [as 别名]
# 或者: from mne.decoding.GeneralizationAcrossTime import estimators_ [as 别名]
def _decod(subject, analysis):
    from mne.decoding import GeneralizationAcrossTime

    # if already computed let's just load it from disk
    fname_kwargs = dict(subject=subject, analysis=analysis['name'] + '_vhp')
    score_fname = paths('score', **fname_kwargs)
    if op.exists(score_fname):
        return load('score', **fname_kwargs)

    epochs = _get_epochs(subject)
    events = load('behavior', subject=subject)

    # Let's not recompute everything, this is just a control analysis
    print(subject, analysis['name'])
    epochs._data = epochs.get_data()
    epochs.preload = True
    epochs.crop(0., .900)
    epochs.decimate(2)

    query, condition = analysis['query'], analysis['condition']
    sel = range(len(events)) if query is None else events.query(query).index
    sel = [ii for ii in sel if ~np.isnan(events[condition][sel][ii])]
    y = np.array(events[condition], dtype=np.float32)

    print analysis['name'], np.unique(y[sel]), len(sel)

    if len(sel) == 0:
        return

    # Apply analysis
    gat = GeneralizationAcrossTime(clf=analysis['clf'],
                                   cv=analysis['cv'],
                                   scorer=analysis['scorer'],
                                   n_jobs=-1)
    print(subject, analysis['name'], 'fit')
    gat.fit(epochs[sel], y=y[sel])
    print(subject, analysis['name'], 'score')
    score = gat.score(epochs[sel], y=y[sel])
    print(subject, analysis['name'], 'save')

    # save space
    gat.estimators_ = None
    gat.y_pred_ = None

    # Save analysis
    save([score, epochs.times], 'score', overwrite=True, upload=True,
         **fname_kwargs)
    return score, epochs.times
开发者ID:kingjr,项目名称:decoding_unconscious_maintenance,代码行数:50,代码来源:run_plot_veryhighpass.py


注:本文中的mne.decoding.GeneralizationAcrossTime.estimators_方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。