コード例 #1
0
                       eeg=False,
                       stim=True,
                       eog=True,
                       exclude='bads')

# Read epochs
epochs = mne.Epochs(raw,
                    events,
                    event_id,
                    tmin,
                    tmax,
                    proj=True,
                    picks=picks,
                    baseline=None,
                    preload=True,
                    reject=dict(grad=4000e-13, eog=150e-6))

epochs_list = [epochs[k] for k in event_id]
mne.epochs.equalize_epoch_counts(epochs_list)
data_picks = mne.pick_types(epochs.info, meg=True, exclude='bads')

###############################################################################
# Setup decoding: default is linear SVC
td = TimeDecoding(predict_mode='cross-validation', n_jobs=1)
# Fit
td.fit(epochs)
# Compute accuracy
td.score(epochs)
# Plot scores across time
td.plot(title='Sensor space decoding')
コード例 #2
0
# Temporal decoding
# -----------------
#
# We'll use the default classifer for a binary classification problem
# which is a linear Support Vector Machine (SVM).

td = TimeDecoding(predict_mode='cross-validation', n_jobs=1)

# Fit
td.fit(epochs)

# Compute accuracy
td.score(epochs)

# Plot scores across time
td.plot(title='Sensor space decoding')

###############################################################################
# Generalization Across Time
# --------------------------
#
# Here we'll use a stratified cross-validation scheme.

# make response vector
y = np.zeros(len(epochs.events), dtype=int)
y[epochs.events[:, 2] == 3] = 1
cv = StratifiedKFold(y=y)  # do a stratified cross-validation

# define the GeneralizationAcrossTime object
gat = GeneralizationAcrossTime(predict_mode='cross-validation', n_jobs=1,
                               cv=cv, scorer=roc_auc_score)
コード例 #3
0
# Temporal decoding
# -----------------
#
# We'll use the default classifer for a binary classification problem
# which is a linear Support Vector Machine (SVM).

td = TimeDecoding(predict_mode="cross-validation", n_jobs=1)

# Fit
td.fit(epochs)

# Compute accuracy
td.score(epochs)

# Plot scores across time
td.plot(title="Sensor space decoding")

###############################################################################
# Generalization Across Time
# --------------------------
#
# This runs the analysis used in [1]_ and further detailed in [2]_
#
# Here we'll use a stratified cross-validation scheme.

# make response vector
y = np.zeros(len(epochs.events), dtype=int)
y[epochs.events[:, 2] == 3] = 1
cv = StratifiedKFold(y=y)  # do a stratified cross-validation

# define the GeneralizationAcrossTime object
コード例 #4
0
data_picks = mne.pick_types(epochsR.info, meg=True, exclude='bads')

epochsR.plot()
epochsL.plot()

# Temporal decoding

#####     Left Hemisphere Temporal Decoding
td = TimeDecoding(predict_mode='cross-validation', n_jobs=1)

# Fit
td.fit(epochsL)
# Compute accuracy
z = td.score(epochsL)
# Plot scores across time
td.plot(title='Left Sensor space decoding')

#####     Right Hemisphere Temporal Decoding

# Fit
td.fit(epochsR)
# Compute accuracy
x = td.score(epochsR)
# Plot scores across time
td.plot(title='Right Sensor space decoding')

############
epochsL_train = epochsL.copy().crop(tmin=-0.1, tmax=1)
labelsL = epochsL.events[:, -1]
epochsR_train = epochsR.copy().crop(tmin=-0.1, tmax=1)
labelsR = epochsR.events[:, -1]