當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。