FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

SpeechBrain EEG by ddavidebb · Pull Request #975 · speechbrain/speechbrain · GitHub

SpeechBrain EEG - #975

Merged
mravanelli merged 240 commits into
speechbrain:developfrom
ddavidebb:eeg_decoding
Oct 2, 2023
Merged

SpeechBrain EEG#975
mravanelli merged 240 commits into
speechbrain:developfrom
ddavidebb:eeg_decoding

Conversation

Copy link
Copy Markdown
Collaborator

This is the first commit for a motor imagery decoding recipe based on a benchmark motor imagery dataset (BNCI2014001).
README and other minors are missing.

ddavidebb requested a review from mravanelli September 8, 2021 17:50
ddavidebb added enhancement New feature or request work in progress Not ready for merge labels Sep 8, 2021
@@ -0,0 +1,409 @@
import numpy as np

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please, add a short docstring that explain what we are doing here



class WithinSession(object):
"""Within Session """

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Here you should improve the docstring with a better description of what we are doing + description of the arguments (see other docstrings)

self.iterator_tag = "within-session"

def prepare(self, dataset):
if not (isinstance(dataset, BaseDataset)):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please, add a docstring + description of input/output arguments



class CrossSession(object):
"""Cross Session """

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Improve docstring (like above)



class LeaveOneSubjectOut(object):
"""Leave one subject out"""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Improve docstring (like above)

if __name__ == "__main__":
argv = sys.argv[1:]
# Temporary switching off deprecation warning from mne
import warnings # noqa

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Is that needed? I don't use mne used and I think we solved the warning issue in the previous recipe, right?

# to run on a subset of subjects: moabb_dataset.subject_list = [1, 2, 3, 4]
moabb_dataset.download(path=hparams["data_folder"])
moabb_paradigm = MotorImagery(
n_classes=4,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The number of classes seems hardcoded it. Can we put in the yaml file?

@@ -0,0 +1,144 @@
###################################################

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please, write the header. Here is the place where I would mention the EEGNET


# DIRECTORIES
data_folder: !PLACEHOLDER #'/path/to/MOABB_BNCI2014001'
output_folder: '/home/prometheus/Documents/results/MOABB_BNCI2014001' #!ref results/MOABB_BNCI2014001/<seed>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think this should be output_folder: results/MOABB_BNCI2014001/<seed>. Otherwise, it is hardcoded.

p_drop: 0.5 # dropout rate
padding_mode: 'constant'

layer0: !new:speechbrain.nnet.CNN.Conv2d

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

An alternative here would be to define the model in lobes (e.g. speechbrain/lobes/EEGNET.py). However, defining it every time doesn't look that bad to me in the end.

Copy link
Copy Markdown
Collaborator

Thank you @ddavidebb , great job! This looks already in a good shape.
Beyond the punctual comments done above, let me share a couple of additional suggestions:

  1. It looks like train.py is dataset-specific (BNCI2014001). However, I think the code should be easily made dataset-independent. For instance, instead of importing the library at the beginning, you can import it right after reading the hparams file. You can add a variable like in the yaml file (e.g., dataset="moabb.datasets.BNCI2014001") and import the library from this string using importlib like:
moabb_dataset= importlib.import_module(hparams["dataset"])
moabb_dataset = moabb_dataset()

e.g, https://www.devdungeon.com/content/import-python-module-string-name

If we are able to make the train.py dataset independent we can share it across all the datasets that we would like to address. Not sure about that, but maybe we can even create a single train.py for all the MOABB tasks (i.e., not only for Motor imagery detection). What do you think?

  1. The MOABB_dataio_iterators.py looks something in common to all the MOABB datasets. One possible approach here (already used in other recipes for the data preparation part) could be to put the script in recipes/MOABB/ and add a symboling link in recipes/MOABB/MOABB/MotorImagery_decoding/BNCI2014001/

return standardized


def nth(iterable, n, default=None):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think this is used on the StratifiedKFold splits...
don't we want to split the data such that we don't have the same sessions of the same subject on train and test?
I think there's a data leakage problem if we do like this. In fact, you already "know" your subject from the train set.
Maybe this is implemented somewhere else and I am just missing it!

mravanelli removed the work in progress Not ready for merge label Oct 2, 2023

Copy link
Copy Markdown
Collaborator

I'm now going to merge the content of this PR in develop and open a new one in speechbrain/benchmarks with the EEG recipes.

mravanelli merged commit 48f5ddd into speechbrain:develop Oct 2, 2023
This file contains hidden or 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL