-
Notifications
You must be signed in to change notification settings - Fork 167
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
Sara04
wants to merge
27
commits into
NeuroTechX:develop
Choose a base branch
from
Sara04:Dreyer2023_MI_dataset
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 cc5de0c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4c4ec42
Add data loading, update docstring
Sara04 a6786ea
Merge branch 'NeuroTechX:develop' into Dreyer2023_MI_dataset
Sara04 594a306
merge
Sara04 7efaf94
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 2da66cd
Merge branch 'develop' into Dreyer2023_MI_dataset
bruAristimunha 8bcbb06
Update dataset and add example
Sara04 d468441
Merge branch 'Dreyer2023_MI_dataset' of https://github.com/Sara04/moa…
Sara04 8e6eef0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] ebce567
Merge branch 'NeuroTechX:develop' into Dreyer2023_MI_dataset
Sara04 e146fb8
Merge branch 'NeuroTechX:develop' into Dreyer2023_MI_dataset
Sara04 cc33198
Merge branch 'NeuroTechX:develop' into Dreyer2023_MI_dataset
Sara04 e4e7ee9
Merge branch 'develop' into Dreyer2023_MI_dataset
bruAristimunha c4ce3eb
Update Dreyer 2023 dataset class and example
Sara04 d5e7b8f
Remove loading info before db is downloaded
Sara04 fb157b7
Merge branch 'develop' into Dreyer2023_MI_dataset
bruAristimunha d8993fc
Merge branch 'NeuroTechX:develop' into Dreyer2023_MI_dataset
Sara04 8f001e4
Merge branch 'develop' into Dreyer2023_MI_dataset
Sara04 2386c96
Update dataset session and run naming; update plotting
Sara04 c353080
Add whats_new
Sara04 3e21b66
Add words to ignore in pre commit config
Sara04 77620b4
Add words to ignore in pre commit config
Sara04 5fbde2d
Merge branch 'develop' into Dreyer2023_MI_dataset
bruAristimunha fac087d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] d9ddebe
Merge branch 'develop' into Dreyer2023_MI_dataset
bruAristimunha 09ed4b6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
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() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ^^
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 theplot_
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 folderexamples/images/
, then you could include the resulting image from your example code (see for example this page or that page).