Skip to content

Instantly share code, notes, and snippets.

@alexandrebarachant
Last active November 13, 2015 19:33
Show Gist options
  • Save alexandrebarachant/0b84d66ca6a6db499dc8 to your computer and use it in GitHub Desktop.
Save alexandrebarachant/0b84d66ca6a6db499dc8 to your computer and use it in GitHub Desktop.
pyRiemann Motor imagery template
from pyriemann.estimation import Covariances
from pyriemann.tangentspace import TangentSpace
from sklearn.pipeline import make_pipeline
from sklearn.linear_model import LogisticRegression
from sklearn.cross_validation import cross_val_score
# load your data
X = ... # your EEG data, in format Ntrials x Nchannels X Nsamples
y = ... # the labels
# Make sure your data are band-pass filtered
# build your pipeline
clf = make_pipeline(Covariances(estimator='lwf'),
TangentSpace(metric='riemann'),
LogisticRegression())
# cross validation
auc = cross_val_score(clf, X, y, scoring='roc_auc')
print(auc.mean())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment