11"""
2- =========================
3- MNE Epochs-based piplines
4- =========================
2+ ==========================
3+ MNE Epochs-based pipelines
4+ ==========================
55
66This example shows how to use machine learning pipeline based on MNE Epochs
7- instead of numpy arrays. This is useful to make the most of the MNE code base
7+ instead of Numpy arrays. This is useful to make the most of the MNE code base
88and to embed EEG specific code inside sklearn pipelines.
99
10- We will compare compare different pipelines for P300:
11- - Logistic Regression , based on MNE Epochs
10+ We will compare different pipelines for P300:
11+ - Logistic regression , based on MNE Epochs
1212- XDAWN and Logistic Regression (LR), based on MNE Epochs
13- - XDAWN extended covariance and LR on tangent space, based on numpy
13+ - XDAWN extended covariance and LR on tangent space, based on Numpy
1414
1515"""
1616# Authors: Sylvain Chevallier
4747moabb .set_log_level ("info" )
4848
4949###############################################################################
50- # Loading dataset
50+ # Loading Dataset
5151# ---------------
5252#
5353# Load 2 subjects of BNCI 2014-009 dataset, with 3 session each
5858paradigm = P300 ()
5959
6060##############################################################################
61- # Get data (optional)
61+ # Get Data (optional)
6262# -------------------
6363#
6464# To get access to the EEG signals downloaded from the dataset, you could
6565# use ``dataset.get_data([subject_id)`` to obtain the EEG as MNE Epochs, stored
6666# in a dictionary of sessions and runs.
6767# The ``paradigm.get_data(dataset=dataset, subjects=[subject_id])`` allows to
6868# obtain the preprocessed EEG data, the labels and the meta information. By
69- # default, the EEG is return as a numpy array. With ``return_epochs=True``, MNE
69+ # default, the EEG is return as a Numpy array. With ``return_epochs=True``, MNE
7070# Epochs are returned.
7171
7272subject_list = [1 ]
7777)
7878
7979##############################################################################
80- # A simple MNE pipeline
80+ # A Simple MNE Pipeline
8181# ---------------------
8282#
8383# Using ``return_epochs=True`` in the evaluation, it is possible to design a
8484# pipeline based on MNE Epochs input. Let's create a simple one, that
8585# reshape the input data from epochs, rescale the data and uses a logistic
8686# regression to classify the data. We will need to write a basic Transformer
87- # estimator, that comply with
87+ # estimator, that complies with
8888# `sklearn convention <https://scikit-learn.org/stable/developers/develop.html>`_.
8989# This transformer will extract the data from an input Epoch, and reshapes into
9090# 2D array.
@@ -124,13 +124,13 @@ def transform(self, X, y=None):
124124mne_res = mne_eval .process (mne_ppl )
125125
126126##############################################################################
127- # Advanced MNE pipeline
127+ # Advanced MNE Pipeline
128128# ---------------------
129129#
130130# In some case, the MNE pipeline should have access to the original labels from
131131# the dataset. This is the case for the XDAWN code of MNE. One could pass
132132# `mne_labels` to evaluation in order to keep this label.
133- # As an example, we will define a pipeline that compute an XDAWN filter, rescale,
133+ # As an example, we will define a pipeline that computes an XDAWN filter, rescale,
134134# then apply a logistic regression.
135135
136136mne_adv = {}
@@ -151,10 +151,10 @@ def transform(self, X, y=None):
151151adv_res = mne_eval .process (mne_adv )
152152
153153###############################################################################
154- # Numpy-based pipeline
154+ # Numpy-based Pipeline
155155# --------------------
156156#
157- # For the comparison, we will define a numpy -based pipeline that relies on
157+ # For the comparison, we will define a Numpy -based pipeline that relies on
158158# pyriemann to estimate XDAWN-extended covariance matrices that are projected
159159# on the tangent space and classified with a logistic regression.
160160
@@ -173,11 +173,12 @@ def transform(self, X, y=None):
173173sk_res = sk_eval .process (sk_ppl )
174174
175175###############################################################################
176- # Combining results
176+ # Combining Results
177177# -----------------
178178#
179179# Even if the results have been obtained by different evaluation processes, it
180- # possible to combine the resulting dataframes to analyze and plot the results.
180+ # is possible to combine the resulting DataFrames to analyze and plot the
181+ # results.
181182
182183all_res = pd .concat ([mne_res , adv_res , sk_res ])
183184
0 commit comments