Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Adding a A large EEG database with users' profile information for motor imagery Brain-Computer Interface dataset #404

Open
wants to merge 27 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5d5a366
Adding a new dataset
Sara04 Jun 21, 2023
cc5de0c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 21, 2023
4c4ec42
Add data loading, update docstring
Sara04 Jun 23, 2023
a6786ea
Merge branch 'NeuroTechX:develop' into Dreyer2023_MI_dataset
Sara04 Jun 23, 2023
594a306
merge
Sara04 Jun 23, 2023
7efaf94
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 23, 2023
2da66cd
Merge branch 'develop' into Dreyer2023_MI_dataset
bruAristimunha Jun 26, 2023
8bcbb06
Update dataset and add example
Sara04 Jun 27, 2023
d468441
Merge branch 'Dreyer2023_MI_dataset' of https://github.com/Sara04/moa…
Sara04 Jun 27, 2023
8e6eef0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 27, 2023
ebce567
Merge branch 'NeuroTechX:develop' into Dreyer2023_MI_dataset
Sara04 Jun 27, 2023
e146fb8
Merge branch 'NeuroTechX:develop' into Dreyer2023_MI_dataset
Sara04 Jun 29, 2023
cc33198
Merge branch 'NeuroTechX:develop' into Dreyer2023_MI_dataset
Sara04 Jul 3, 2023
e4e7ee9
Merge branch 'develop' into Dreyer2023_MI_dataset
bruAristimunha Jul 4, 2023
c4ce3eb
Update Dreyer 2023 dataset class and example
Sara04 Jul 5, 2023
d5e7b8f
Remove loading info before db is downloaded
Sara04 Jul 5, 2023
fb157b7
Merge branch 'develop' into Dreyer2023_MI_dataset
bruAristimunha Jul 8, 2023
d8993fc
Merge branch 'NeuroTechX:develop' into Dreyer2023_MI_dataset
Sara04 Jul 10, 2023
8f001e4
Merge branch 'develop' into Dreyer2023_MI_dataset
Sara04 Nov 17, 2023
2386c96
Update dataset session and run naming; update plotting
Sara04 Nov 18, 2023
c353080
Add whats_new
Sara04 Nov 18, 2023
3e21b66
Add words to ignore in pre commit config
Sara04 Nov 18, 2023
77620b4
Add words to ignore in pre commit config
Sara04 Nov 18, 2023
5fbde2d
Merge branch 'develop' into Dreyer2023_MI_dataset
bruAristimunha Apr 11, 2024
fac087d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 11, 2024
d9ddebe
Merge branch 'develop' into Dreyer2023_MI_dataset
bruAristimunha Apr 11, 2024
09ed4b6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ repos:
hooks:
- id: codespell
args:
- --ignore-words-list=additionals,alle,alot,bund,currenty,datas,farenheit,falsy,fo,haa,hass,iif,incomfort,ines,ist,nam,nd,pres,pullrequests,resset,rime,ser,serie,te,technik,ue,unsecure,withing,zar
- --ignore-words-list=additionals,alle,aline,alot,bund,currenty,datas,farenheit,falsy,fo,haa,hass,iif,incomfort,ines,ist,nam,nd,perfomances,pres,pullrequests,resset,rime,ser,serie,te,technik,ue,unsecure,withing,zar
- --skip="./.*,*.csv,*.json,*.ambr"
- --quiet-level=2
exclude_types: [ csv, json, svg ]
Expand Down
3 changes: 3 additions & 0 deletions docs/source/datasets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Motor Imagery Datasets
BNCI2015_001
BNCI2015_004
Cho2017
Dreyer2023A
Dreyer2023B
Dreyer2023C
Lee2019_MI
GrosseWentrup2009
Ofner2017
Expand Down
2 changes: 2 additions & 0 deletions docs/source/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Enhancements

- Adding cache option to the evaluation (:gh:`517` by `Bruno Aristimunha`_)
- Option to interpolate channel in paradigms' `match_all` method (:gh:`480` by `Gregoire Cattan`_)
- Adding new motor imagery dataset, Dreyer2023 (PR :gh: `404` by `Sara Sedlar`_ and `Sylvain Chevallier`_)
- Adding leave k-Subjects out evaluations (:gh:`470` by `Bruno Aristimunha`_)
- Update Braindecode dependency to 0.8 (:gh:`542` by `Pierre Guetschel`_)
- Improve transform function of AugmentedDataset (:gh:`541` by `Quentin Barthelemy`_)
Expand All @@ -31,6 +32,7 @@ Bugs

- Fix TRCA implementation for different stimulation freqs and for signal filtering (:gh:522 by `Sylvain Chevallier`_)
- Fix saving to BIDS runs with a description string in their name (:gh:`530` by `Pierre Guetschel`_)
- Fix issue with WithinSessionEvaluation with multiple datasets (PR :gh: `521`, issue :gh: `514` by `Sara Sedlar`_)
- Fix import of keras BatchNormalization for TF 2.13 and higher (:gh:`544` by `Brian Irvine`_)
- Fix the doc summary tables of :class:`moabb.datasets.Lee2019_SSVEP` (:gh:`548` :gh:`547` :gh:`546` by `Pierre Guetschel`_)
- Fix the doc summary for Castillos2023 dataset (:gh:`561` by `Bruno Aristimunha`_)
Expand Down
159 changes: 159 additions & 0 deletions examples/Dreyer_clf_scores_vs_subj_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
"""
===============================================
Examples of analysis of a Dreyer2023 A dataset.
===============================================

This example shows how to plot Dreyer2023A Left-Right Imagery ROC AUC scores
obtained with CSP+LDA pipeline versus demographic information of the examined
subjects (gender and age) and experimenters (gender).

To reduce computational time, the example is provided for four subjects.

"""

# Authors: Sara Sedlar <sara.sedlar@gmail.com>
# Sylvain Chevallier <sylvain.chevallier@universite-paris-saclay.fr>
# License: BSD (3-clause)

import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sb
from pyriemann.estimation import Covariances
from pyriemann.spatialfilters import CSP
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as LDA
from sklearn.pipeline import make_pipeline

from moabb.datasets import Dreyer2023A
from moabb.evaluations import WithinSessionEvaluation
from moabb.paradigms import MotorImagery


# 1. Defining dataset, selecting subject for analysis and getting data
########################################################################################
dreyer2023 = Dreyer2023A()
dreyer2023.subject_list = [1, 5, 7, 35]
dreyer2023.get_data()
########################################################################################
# 2. Defining MotorImagery paradigm and CSP+LDA pipeline
paradigm = MotorImagery()
pipelines = {}
pipelines["CSP+LDA"] = make_pipeline(
Covariances(estimator="oas"), CSP(nfilter=6), LDA(solver="lsqr", shrinkage="auto")
)
########################################################################################
# 3. Within session evaluation of the pipeline
evaluation = WithinSessionEvaluation(
paradigm=paradigm, datasets=[dreyer2023], suffix="examples", overwrite=True
)
results = evaluation.process(pipelines)
results = results.loc[results["subject"].isin([str(s) for s in dreyer2023.subject_list])]
########################################################################################
# 4. Loading dataset info and concatenation with the obtained results
info = dreyer2023.get_subject_info().rename(columns={"score": "score_MR"})
results_info = pd.concat([info, results], axis=1)
results_info["Age"] = 2019 - results_info["Birth_year"]
########################################################################################
# 5.1 Plotting subject AUC ROC scores vs subject's gender
fig, ax = plt.subplots(nrows=2, ncols=2, facecolor="white", figsize=[16, 8], sharey=True)
fig.subplots_adjust(wspace=0.0, hspace=0.5)
sb.boxplot(
data=results_info, y="score", x="SUJ_gender", ax=ax[0, 0], palette="Set1", width=0.3
)
sb.stripplot(
data=results_info,
y="score",
x="SUJ_gender",
ax=ax[0, 0],
palette="Set1",
linewidth=1,
edgecolor="k",
size=3,
alpha=0.3,
zorder=1,
)
ax[0, 0].set_title("AUC ROC scores vs. subject gender")
ax[0, 0].set_xticklabels(["Man", "Woman"])
ax[0, 0].set_ylabel("ROC AUC")
ax[0, 0].set_xlabel(None)
ax[0, 0].set_ylim(0.3, 1)
########################################################################################
# 5.2 Plotting subject AUC ROC scores vs subjects's age per gender
sb.regplot(
data=results_info[results_info["SUJ_gender"] == 1][["score", "Age"]].astype(
"float32"
),
y="score",
x="Age",
ax=ax[0, 1],
scatter_kws={"color": "#e41a1c", "alpha": 0.5},
line_kws={"color": "#e41a1c"},
)
sb.regplot(
data=results_info[results_info["SUJ_gender"] == 2][["score", "Age"]].astype(
"float32"
),
y="score",
x="Age",
ax=ax[0, 1],
scatter_kws={"color": "#377eb8", "alpha": 0.5},
line_kws={"color": "#377eb8"},
)
ax[0, 1].set_title("AUC ROC scores vs. subject age per gender")
ax[0, 1].set_ylabel(None)
ax[0, 1].set_xlabel(None)
ax[0, 1].legend(
handles=[
mpatches.Patch(color="#e41a1c", label="Man"),
mpatches.Patch(color="#377eb8", label="Woman"),
]
)
########################################################################################
# 5.3 Plotting subject AUC ROC scores vs experimenter's gender
sb.boxplot(
data=results_info, y="score", x="EXP_gender", ax=ax[1, 0], palette="Set1", width=0.3
)
sb.stripplot(
data=results_info,
y="score",
x="EXP_gender",
ax=ax[1, 0],
palette="Set1",
linewidth=1,
edgecolor="k",
size=3,
alpha=0.3,
zorder=1,
)
ax[1, 0].set_title("AUC ROC scores vs. experimenter gender")
ax[1, 0].set_xticklabels(["Man", "Woman"])
ax[1, 0].set_ylabel("ROC AUC")
ax[1, 0].set_xlabel(None)
ax[1, 0].set_ylim(0.3, 1)
########################################################################################
# 5.4 Plotting subject AUC ROC scores vs subject's age
sb.regplot(
data=results_info[["score", "Age"]].astype("float32"),
y="score",
x="Age",
ax=ax[1, 1],
scatter_kws={"color": "black", "alpha": 0.5},
line_kws={"color": "black"},
)
ax[1, 1].set_title("AUC ROC scores vs. subject age")
ax[1, 1].set_ylabel(None)
plt.show()
########################################################################################
# 5.5 Obtained results for four selected subjects correspond to the following figure.
#
# .. image:: images/Dreyer_clf_scores_vs_subj_info/4_selected_subjects.png
# :align: center
# :alt: 4_selected_subjects
#
# Obtained results for all subjects correspond to the following figure.
#
# .. image:: images/Dreyer_clf_scores_vs_subj_info/all_subjects.png
# :align: center
# :alt: all_subjects
#
########################################################################################
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading