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 18 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
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
BNCI2015001
BNCI2015004
Cho2017
Dreyer2023A
Dreyer2023B
Dreyer2023C
Lee2019_MI
MunichMI
Ofner2017
Expand Down
1 change: 1 addition & 0 deletions docs/source/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Enhancements
- Adding saving option for the models (:gh:`401` by `Bruno Aristimunha`_ and `Igor Carrara`_)
- Adding example to load different type of models (:gh:`401` by `Bruno Aristimunha`_ and `Igor Carrara`_)
- Add resting state paradigm with dataset and example (:gh:`400` by `Gregoire Cattan`_ and `Pedro L. C. Rodrigues`_)
- Add Dreyer 2023 Left-Right Motor Imagery dataset (:gh:`404` by `Sara Sedlar`_ and `Sylvain Chevallier`_)

Bugs
~~~~
Expand Down
134 changes: 134 additions & 0 deletions examples/plot_Dreyer_clf_scores_vs_subj_info.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
"""
===============================================
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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dreyer2023 = Dreyer2023A()
dreyer2023 = Dreyer2023A()
dreyer2023.subject_list = dataset.subject_list[:6]

Generating documentation uses lots of computational ressources, both for CPU and network bandwidth. We try to limit as much as possible the datasets downloaded for generating docs (they are shared between the examples). As the user's profile included in this dataset could give some interesting insight, we could consider to add this dataset in the documentation, but it should use only a selection of subjects to keep the bandwidth usage within reasonable limits. Could you adapt the above line to select only a representative individual for your analysis below. If you could keep the number of subjects between 4 and 8, it will really lower the doc building time.
Cherry picking subjects for the documentation is allowed ^^

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've selected 4 subjects (to include all combinations of participants' and experimenters' genders). However, since data of all subjects are zipped they all need to be downloaded together, is there some solution for this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No unfortunately.
The only possibility I see is to make this example a static one, that is you change the name of the file into Dreyer_clf_scores_vs_subj_info.py (without the plot_ prefix) and Sphinx won't execute this example, only display the code. If you want, you could generate a figure on your computer and upload it in a new folder examples/images/, then you could include the resulting image from your example code (see for example this page or that page).

dreyer2023.subject_list = [1, 5, 7, 45]
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=False
)
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.stripplot(
data=results_info,
y="score",
x="SUJ_gender",
ax=ax[0, 0],
jitter=True,
alpha=0.5,
zorder=1,
palette="Set1",
)
sb.pointplot(data=results_info, y="score", x="SUJ_gender", ax=ax[0, 0], palette="Set1")
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 experimenter's 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)
red_man = mpatches.Patch(color="#e41a1c", label="Man")
blue_woman = mpatches.Patch(color="#377eb8", label="Woman")
ax[0, 1].legend(handles=[red_man, blue_woman])
########################################################################################
# 5.3 Plotting subject AUC ROC scores vs experimenter's gender
sb.stripplot(
data=results_info,
y="score",
x="EXP_gender",
ax=ax[1, 0],
jitter=True,
alpha=0.5,
zorder=1,
palette="Set1",
)
sb.pointplot(data=results_info, y="score", x="EXP_gender", ax=ax[1, 0], palette="Set1")
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()
Loading
Loading