MOABBDataset¶
- class torcheeg.datasets.moabb.MOABBDataset(dataset: BaseDataset, paradigm: BaseParadigm, chunk_size: int = -1, overlap: int = 0, online_transform: None | Callable = None, offline_transform: None | Callable = None, label_transform: None | Callable = None, before_trial: None | Callable = None, after_trial: None | Callable = None, after_session: None | Callable = None, after_subject: None | Callable = None, io_path: str = '.torcheeg/io/moabb', io_size: int = 1048576, io_mode: str = 'lmdb', download_path: str | None = None, num_worker: int = 0, verbose: bool = True, **kwargs)[source][source]¶
Mother of all BCI Benchmarks (MoABB) aims at building a comprehensive benchmark of popular Brain-Computer Interface (BCI) algorithms applied on an extensive list of freely available EEG datasets. This class implements the conversion of MOABB datasets to TorchEEG datasets, allowing to import any MOABB datasets to use them like TorchEEG datasets.
A tiny case shows the use of
MOABBDataset
:from moabb.datasets import BNCI2014001 from moabb.paradigms import LeftRightImagery from torcheeg import transforms import torcheeg.datasets.moabb as moabb_dataset dataset = BNCI2014001() dataset.subject_list = [1, 2, 3] paradigm = LeftRightImagery() dataset = moabb_dataset.MOABBDataset(dataset=dataset, paradigm=paradigm, io_path='./io/moabb', offline_transform=transforms.Compose( [transforms.BandDifferentialEntropy()]), online_transform=transforms.ToTensor(), label_transform=transforms.Compose([ transforms.Select('label') ]))
- Parameters:
dataset (MOABBDataset) – an instance of
BaseDataset
defined by moabb.paradigm (MOABBParadigm) – an instance of
BaseParadigm
defined by moabb.chunk_size (int) – The length of each EEG sample. If set to
-1
, the length of each EEG sample is the same as the length of the EEG signal in event. (default:-1
)overlap (int) – The overlap between two adjacent EEG samples. (default:
0
)online_transform (Callable, optional) – The transformation of the EEG signals and baseline EEG signals. The input is a
np.ndarray
, and the ouput is used as the first and second value of each element in the dataset. (default:None
)offline_transform (Callable, optional) – The usage is the same as
online_transform
, but executed before generating IO intermediate results. (default:None
)label_transform (Callable, optional) – The transformation of the label. The input is an information dictionary, and the ouput is used as the third value of each element in the dataset. (default:
None
)before_trial (Callable, optional) – The hook performed on the trial to which the sample belongs. It is performed before the offline transformation and thus typically used to implement context-dependent sample transformations, such as filter, reference, moving average and etc. Its input is a
mne.io.Raw
object, and its output should also be amne.io.Raw
object. (default:None
)after_trial (Callable, optional) – The hook performed on the trial to which the sample belongs. It is performed after the offline transformation and thus typically used to implement context-dependent sample transformations, such as moving averages, etc. The input and output of this hook function should be a sequence of dictionaries representing a sequence of EEG samples. Each dictionary contains two key-value pairs, indexed by
eeg
(the EEG signal matrix) andkey
(the index in the database) respectively.io_path (str) – The path to generated unified data IO, cached as an intermediate result. If set to None, a random path will be generated. (default:
/io/moabb
)io_size (int) – Maximum size database may grow to; used to size the memory mapping. If database grows larger than
map_size
, an exception will be raised and the user must close and reopen. (default:1048576
)io_mode (str) – Storage mode of EEG signal. When io_mode is set to
lmdb
, TorchEEG provides an efficient database (LMDB) for storing EEG signals. LMDB may not perform well on limited operating systems, where a file system based EEG signal storage is also provided. When io_mode is set topickle
, pickle-based persistence files are used. When io_mode is set tomemory
, memory are used. (default:lmdb
)download_path (str) – The path to download raw data. If set to
None
, the raw data will be downloaded tof'{self.io_path}/raw'
. If the path already exists, the download will be skipped. (default:None
)num_worker (int) – Number of subprocesses to use for data loading. 0 means that the data will be loaded in the main process. (default:
0
)