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


Python EpochsArray.times方法代码示例

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


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

示例1: _read_epochs

# 需要导入模块: from mne import EpochsArray [as 别名]
# 或者: from mne.EpochsArray import times [as 别名]
def _read_epochs(epochs_mat_fname, info, return_fixations_motor):
    """read the epochs from matfile"""
    data = scio.loadmat(epochs_mat_fname,
                        squeeze_me=True)['data']
    ch_names = [ch for ch in data['label'].tolist()]
    info['sfreq'] = data['fsample'].tolist()
    times = data['time'].tolist()[0]
    # deal with different event lengths
    if return_fixations_motor is not None:
        fixation_mask = data['trialinfo'].tolist()[:, 1] == 6
        if return_fixations_motor is False:
            fixation_mask = ~fixation_mask
        data = np.array(data['trial'].tolist()[fixation_mask].tolist())
    else:
        data = np.array(data['trial'].tolist().tolist())

    # warning: data are not chronologically ordered but
    # match the trial info
    events = np.zeros((len(data), 3), dtype=np.int)
    events[:, 0] = np.arange(len(data))
    events[:, 2] = 99  # all events
    # we leave it to the user to construct his events
    # as from the data['trialinfo'] arbitrary events can be constructed.
    # and it is task specific.
    this_info = _hcp_pick_info(info, ch_names)
    epochs = EpochsArray(data=data, info=this_info, events=events,
                         tmin=times.min())
    # XXX hack for now due to issue with EpochsArray constructor
    # cf https://github.com/mne-tools/mne-hcp/issues/9
    epochs.times = times
    return epochs
开发者ID:mne-tools,项目名称:mne-hcp,代码行数:33,代码来源:read.py

示例2: StratifiedKFold

# 需要导入模块: from mne import EpochsArray [as 别名]
# 或者: from mne.EpochsArray import times [as 别名]
data_pln = np.asarray(pln_all)

# Setup data for epochs and cross validation
X = np.vstack([data_cls, data_pln])
y = np.concatenate([np.zeros(len(data_cls)), np.ones(len(data_pln))])
cv = StratifiedKFold(n_splits=7, shuffle=True)

# Create epochs to use for classification
n_trial, n_chan, n_time = X.shape
events = np.vstack((range(n_trial), np.zeros(n_trial, int), y.astype(int))).T
chan_names = ['MEG %i' % chan for chan in range(n_chan)]
chan_types = ['mag'] * n_chan
sfreq = 250
info = create_info(chan_names, sfreq, chan_types)
epochs = EpochsArray(data=X, info=info, events=events, verbose=False)
epochs.times = selected_times[:n_time]

# make classifier
clf = LogisticRegression(C=0.0001)

# fit model and score
gat = GeneralizationAcrossTime(
    clf=clf, scorer="roc_auc", cv=cv, predict_method="predict")
gat.fit(epochs, y=y)
gat.score(epochs, y=y)

# Save model
joblib.dump(gat, data_path + "decode_time_gen/gat_ge.jl")

# make matrix plot and save it
fig = gat.plot(
开发者ID:MadsJensen,项目名称:RP_scripts,代码行数:33,代码来源:sk_sliding_trans_bin.py


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