| """ |
| ================================ |
| Select Electrodes and Resampling |
| ================================ |
| |
| Within paradigm, it is possible to restrict analysis only to a subset of |
| electrodes and to resample to a specific sampling rate. There is also a |
| utility function to select common electrodes shared between datasets. |
| This tutorial demonstrates how to use this functionality. |
| """ |
|
|
| |
| |
| |
| import matplotlib.pyplot as plt |
| from mne.decoding import CSP |
| from pyriemann.estimation import Covariances |
| from pyriemann.tangentspace import TangentSpace |
| from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA |
| from sklearn.linear_model import LogisticRegression as LR |
| from sklearn.pipeline import make_pipeline |
|
|
| import moabb.analysis.plotting as moabb_plt |
| from moabb.analysis.chance_level import chance_by_chance |
| from moabb.datasets import BNCI2014_001, Zhou2016 |
| from moabb.datasets.utils import find_intersecting_channels |
| from moabb.evaluations import WithinSessionEvaluation |
| from moabb.paradigms import LeftRightImagery |
|
|
|
|
| |
| |
| |
| |
| |
|
|
| subj = [1, 2] |
| datasets = [Zhou2016(), BNCI2014_001()] |
| for d in datasets: |
| d.subject_list = subj |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| paradigm = LeftRightImagery(channels=["C3", "C4", "Cz"], resample=200.0) |
|
|
| |
| |
| |
| |
| |
| |
|
|
| evaluation = WithinSessionEvaluation(paradigm=paradigm, datasets=datasets) |
| csp_lda = make_pipeline(CSP(n_components=2), LDA()) |
| ts_lr = make_pipeline( |
| Covariances(estimator="oas"), TangentSpace(metric="riemann"), LR(C=1.0) |
| ) |
| results = evaluation.process({"csp+lda": csp_lda, "ts+lr": ts_lr}) |
| print(results.head()) |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| electrodes, datasets = find_intersecting_channels(datasets) |
| evaluation = WithinSessionEvaluation( |
| paradigm=paradigm, datasets=datasets, overwrite=True, suffix="resample" |
| ) |
| results = evaluation.process({"csp+lda": csp_lda, "ts+lr": ts_lr}) |
| print(results.head()) |
|
|
| |
| |
| |
| |
| |
| |
|
|
| chance_levels = chance_by_chance(results, alpha=[0.05, 0.01]) |
|
|
| fig = moabb_plt.paired_plot(results, "csp+lda", "ts+lr", chance_level=chance_levels) |
| plt.show() |
|
|