| """ |
| =========================== |
| Within Session P300 |
| =========================== |
| |
| This example shows how to perform a within session analysis on three different |
| P300 datasets. |
| |
| We will compare two pipelines : |
| |
| - Riemannian geometry |
| - XDAWN with Linear Discriminant Analysis |
| |
| We will use the P300 paradigm, which uses the AUC as metric. |
| |
| """ |
|
|
| |
| |
| |
|
|
| import warnings |
|
|
| import matplotlib.pyplot as plt |
| from mne.decoding import Vectorizer |
| from pyriemann.estimation import Xdawn, XdawnCovariances |
| from pyriemann.tangentspace import TangentSpace |
| from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA |
| from sklearn.pipeline import make_pipeline |
|
|
| import moabb |
| import moabb.analysis.plotting as moabb_plt |
| from moabb.analysis.chance_level import chance_by_chance |
| from moabb.datasets import BNCI2014_009 |
| from moabb.evaluations import WithinSessionEvaluation |
| from moabb.paradigms import P300 |
|
|
|
|
| |
| |
| warnings.simplefilter(action="ignore", category=FutureWarning) |
| warnings.simplefilter(action="ignore", category=RuntimeWarning) |
|
|
| moabb.set_log_level("info") |
|
|
| |
| |
| |
| |
| |
|
|
|
|
| pipelines = {} |
|
|
| |
| |
| |
| |
| labels_dict = {"Target": 1, "NonTarget": 0} |
|
|
| pipelines["RG+LDA"] = make_pipeline( |
| XdawnCovariances( |
| nfilter=2, classes=[labels_dict["Target"]], estimator="lwf", xdawn_estimator="scm" |
| ), |
| TangentSpace(), |
| LDA(solver="lsqr", shrinkage="auto"), |
| ) |
|
|
| pipelines["Xdw+LDA"] = make_pipeline( |
| Xdawn(nfilter=2, estimator="scm"), Vectorizer(), LDA(solver="lsqr", shrinkage="auto") |
| ) |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| paradigm = P300(resample=128) |
| dataset = BNCI2014_009() |
| dataset.subject_list = dataset.subject_list[:2] |
| datasets = [dataset] |
| overwrite = True |
| evaluation = WithinSessionEvaluation( |
| paradigm=paradigm, datasets=datasets, suffix="examples", overwrite=overwrite |
| ) |
| results = evaluation.process(pipelines) |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| chance_levels = chance_by_chance(results, alpha=[0.05, 0.01]) |
|
|
| fig, _ = moabb_plt.score_plot(results, chance_level=chance_levels) |
| plt.show() |
|
|