Skip to content

Commit

Permalink
Alphawaves dataset (#602)
Browse files Browse the repository at this point in the history
* push Pedro's implementation

* complete constructor

* Complete doc

* fix bug with file location

* rename on/off to closed/open

* push example

* fix example

* minor refacto of the example

* [pre-commit.ci] auto fixes from pre-commit.com hooks

* what's new

* typo

* [pre-commit.ci] auto fixes from pre-commit.com hooks

* remove examples

* Fixing citation and table

---------

Co-authored-by: Gregoire Cattan <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bru <[email protected]>
  • Loading branch information
4 people authored May 21, 2024
1 parent 52e7491 commit 04e6688
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/source/dataset_summary.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ is a resting state experiment.

:class:`Cattan2019_PHMD`,12,16,2,10,60s,512Hz,1
:class:`Hinss2021`,15,62,4,1,2s,250Hz,1
:class:`Rodrigues2017`,20,16,2,5,10s,512Hz,1

Compound Datasets
======================
Expand Down
1 change: 1 addition & 0 deletions docs/source/datasets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Resting State Datasets

Cattan2019_PHMD
Hinss2021
Rodrigues2017


------------
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 @@ -34,6 +34,7 @@ Enhancements
- Add SSVEP and ERP paradigms to DL pipelines (:gh:`590` by `Pierre Guetschel`_)
- Allow to pass a single pipeline file to ``benchmark`` (:gh:`591` by `Pierre Guetschel`_)
- Exposing the `drop_rate` for all the deep learning parameters (:gh:`592` by `Bruno Aristimunha`_)
- Add Alphawes dataset (:gh:`602` by `Gregoire Cattan`_ and `Pedro L. C. Rodrigues`_)

Bugs
~~~~
Expand Down
1 change: 1 addition & 0 deletions moabb/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

# flake8: noqa
from .alex_mi import AlexMI
from .alphawaves import Rodrigues2017
from .bbci_eeg_fnirs import Shin2017A, Shin2017B

# Depreciated datasets (will be removed in the future):
Expand Down
149 changes: 149 additions & 0 deletions moabb/datasets/alphawaves.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import os

import mne
import numpy as np
from scipy.io import loadmat

from moabb.datasets import download as dl
from moabb.datasets.base import BaseDataset


ALPHAWAVES_URL = "https://zenodo.org/record/2348892/files/"


class Rodrigues2017(BaseDataset):
"""Alphawaves dataset
.. admonition:: Dataset summary
=============== ======= ======= ========== =============== ============ =============== ===========
Name #Subj #Chan #Classes #Blocks/class Trials len Sampling rate #Sessions
=============== ======= ======= ========== =============== ============ =============== ===========
Rodrigues2017 20 16 2 5 10s 512Hz 1
=============== ======= ======= ========== =============== ============ =============== ===========
Dataset containing EEG recordings of subjects in a simple
resting-state eyes open/closed experimental protocol. Data were recorded
during a pilot experiment taking place in the GIPSA-lab, Grenoble,
France, in 2017 [1]_.
**Dataset Description**
This experiment was conducted to
provide a simple yet reliable set of EEG signals carrying very distinct
signatures on each experimental condition. It can be useful for researchers
and students looking for an EEG dataset to perform tests with signal
processing and machine learning algorithms.
I. Participants
A total of 20 volunteers participated in the experiment (7 females), with
mean (sd) age 25.8 (5.27) and median 25.5. 18 subjects were between 19 and
28 years old. Two participants with age 33 and 44 were outside this range.
II. Procedures
EEG signals were acquired using a standard research grade amplifier
(g.USBamp, g.tec, Schiedlberg, Austria) and the EC20 cap equipped with 16
wet electrodes (EasyCap, Herrsching am Ammersee, Germany), placed according
to the 10-20 international system.
We acquired the data with no digital filter and a sampling frequency of 512Hz
was used.
Each participant underwent one session consisting of
ten blocks of ten seconds of EEG data recording.
Five blocks were recorded while a subject was keeping his eyes
closed (condition 1) and the others while his eyes were open (condition 2).
The two conditions were alternated. Before the onset of each block, the
subject was asked to close or open his eyes according to the experimental
condition.
We supply an online and open-source example working with Python [2]_.
References
----------
.. [1] G. Cattan, P. L. Coelho Rodrigues, and M. Congedo,
‘EEG Alpha Waves Dataset’, 2018.
Available: https://hal.archives-ouvertes.fr/hal-02086581
.. [2] Rodrigues PLC. Alpha-Waves-Dataset [Internet].
Grenoble: GIPSA-lab; 2018. Available from:
https://github.com/plcrodrigues/Alpha-Waves-Dataset
Notes
-----
.. versionadded:: 1.0.1
"""

def __init__(self):
subject_list = list(range(1, 6 + 1)) + list(range(8, 20 + 1))
super().__init__(
subjects=subject_list,
sessions_per_subject=1,
events=dict(closed=1, open=2),
code="Rodrigues2017",
interval=[0, 10],
paradigm="rstate",
doi="https://doi.org/10.5281/zenodo.2348892",
)

def _get_single_subject_data(self, subject):
"""return data for a single subject"""

dirpath = self.data_path(subject)[0]
filepath = os.listdir(dirpath)[0]

data = loadmat(os.path.join(dirpath, filepath))

S = data["SIGNAL"][:, 1:17]
stim_close = data["SIGNAL"][:, 17]
stim_open = data["SIGNAL"][:, 18]
stim = 1 * stim_close + 2 * stim_open
chnames = [
"Fp1",
"Fp2",
"Fc5",
"Fz",
"Fc6",
"T7",
"Cz",
"T8",
"P7",
"P3",
"Pz",
"P4",
"P8",
"O1",
"Oz",
"O2",
"stim",
]
chtypes = ["eeg"] * 16 + ["stim"]
X = np.concatenate([S, stim[:, None]], axis=1).T

info = mne.create_info(
ch_names=chnames, sfreq=512, ch_types=chtypes, verbose=False
)
raw = mne.io.RawArray(data=X, info=info, verbose=False)

return {"0": {"0": raw}}

def data_path(
self, subject, path=None, force_update=False, update_path=None, verbose=None
):

if subject not in self.subject_list:
raise (ValueError("Invalid subject number"))

url = "{:s}subject_{:02d}.mat".format(ALPHAWAVES_URL, subject)
file_path = dl.data_path(url, "ALPHAWAVES")

return [file_path]

0 comments on commit 04e6688

Please sign in to comment.