Skip to content

Instantly share code, notes, and snippets.

@sylvchev
Created February 29, 2016 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sylvchev/0b8f37252aca85f41f0d to your computer and use it in GitHub Desktop.
Save sylvchev/0b8f37252aca85f41f0d to your computer and use it in GitHub Desktop.
Opening and plotting coavriance matrices estimated from SSVEP dataset
import numpy as np
import mne
from sklearn.cross_validation import cross_val_score, KFold
from pyriemann.estimation import covariances
import matplotlib.pyplot as plt
tmin, tmax = 2., 5.
event_id = dict(resting=1, stim13=2, stim17=3, stim21=4)
data_path = './'
fname = 'subject12/record-[2014.03.10-19.17.37]'
raw = mne.io.read_raw_fif(data_path + fname + '_raw.fif',
preload=True, add_eeg_ref=False)
events = mne.read_events(data_path + fname + '-eve.fif')
picks = mne.pick_types(raw.info, meg=False, eeg=True, stim=False, eog=False)
raw.filter(6., 30., method='iir', picks=picks)
raw.plot(events=events, event_color={1:'red', 2:'blue', 3:'green', 4:'cyan' },
duration=6, n_channels=8, color={'eeg':'steelblue'}, scalings={'eeg':2e-2},
show_options=False, title='Raw EEG from S12')
epochs = mne.Epochs(raw, events, event_id, tmin, tmax, proj=True, picks=picks,
baseline=None, preload=True, add_eeg_ref=False, verbose=False)
epochs.plot(title='SSVEP epochs', n_channels=8, n_epochs=4)
labels = epochs.events[:, -1]
cv = KFold(len(labels), 10, shuffle=True, random_state=42)
epochs_data_train = 1e3*epochs.get_data()
plt.figure()
plt.imshow(cov_data_train[0,:,:], interpolation='nearest')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment