DTUProcessedDataset¶
- class torcheeg.datasets.DTUProcessedDataset(root_path: str = './DATA_preproc', chunk_size: int = 64, overlap: int = 0, num_channel: int = 64, 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_subject: None | Callable = None, io_path: None | str = None, io_size: int = 1048576, io_mode: str = 'lmdb', num_worker: int = 0, verbose: bool = True)[source][source]¶
This dataset contains EEG recordings from 18 subjects listening to one of two competing speech audio streams, after matlab preprocessing. This class generates training samples and test samples according to the given parameters, and caches the generated results in a unified input and output format (IO). The relevant information of the dataset is as follows:
Author: Fuglsang et al.
Year: 2017
Download URL: https://zenodo.org/records/1199011
Reference: Fuglsang S A, Dau T, Hjortkjær J. Noise-robust cortical tracking of attended speech in real-world acoustic scenes[J]. NeuroImage, 2017, 156: 435-444.
Stimulus: Continuous speech in trials of ~50 seconds with target speakers positioned from -60° to 60°.
Signals: Electroencephalogram recorded in a double-walled soundproof booth at the Technical University of Denmark (DTU) using a 64-channel Biosemi system (channels 1-64: scalp EEG electrodes, channel 65: right mastoid electrode, channel 66: left mastoid electrode) and digitized at a sampling rate of 512 Hz (downsampled to 64 Hz).
Labels: Attended speaker (attended_speaker=1 for male, attended_speaker=2 for female).
In order to use this dataset, the download file
DATA_preproc.zipis required. After unzipping, the folder should contain the following files:DATA_preproc/ ├── S1_data_preproc.mat ├── S2_data_preproc.mat ├── S3_data_preproc.mat ├── ... └── S18_data_preproc.mat
An example dataset for CNN-based methods:
from torcheeg.datasets import DTUProcessedDataset from torcheeg import transforms dataset = DTUProcessedDataset(root_path='./DATA_preproc', offline_transform=transforms.To2d(), online_transform=transforms.ToTensor(), label_transform=transforms.Compose([ transforms.Select('attended_speaker'), transforms.Lambda(lambd=lambda x: x - 1) ])) print(dataset[0]) # EEG signal (torch.Tensor[1, 64, 64]), # label (int)
- Parameters:
root_path (str) – Path to the downloaded data files in MATLAB format (unzipped DATA_preproc.zip). (default:
'./DATA_preproc')chunk_size (int) – Number of data points included in each EEG chunk as training or test samples. If set to -1, the EEG signal of an entire trial is used as a single chunk. (default:
64)overlap (int) – The number of overlapping data points between different chunks when dividing EEG data. (default:
0)num_channel (int) – Number of channels to use. The dataset contains 66 channels total (64 scalp EEG + 2 mastoid electrodes). (default:
64)online_transform (Callable, optional) – The transformation applied to the EEG signals. The input is a
np.ndarray, and the output is used as the first 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 applied to the label. The input is an information dictionary, and the output is used as the second value of each element in the dataset. (default:
None)before_trial (Callable, optional) – A hook function performed on the trial to which the sample belongs. It is executed before the offline transformation and is typically used to implement context-dependent sample transformations, such as moving averages. The input of this hook function is a 2D EEG signal with shape (number of electrodes, number of data points), and the ideal output shape is also (number of electrodes, number of data points).
after_trial (Callable, optional) – A hook function performed on the trial to which the sample belongs. It is executed after the offline transformation and is typically used to implement context-dependent sample transformations, such as moving averages. 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.after_subject (Callable, optional) – A hook function performed on the subject to which the sample belongs. It is executed after the offline transformation and is typically used to implement context-dependent sample transformations, such as moving averages. 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 the generated unified data IO, cached as an intermediate result. If set to None, a random path will be generated. (default:
None)io_size (int) – Maximum size the database may grow to; used to size the memory mapping. If the 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 signals. 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 is used. (default:lmdb)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)verbose (bool) – Whether to display logs during processing, such as progress bars. (default:
True)