AVEDProcessedDataset¶
- class torcheeg.datasets.AVEDProcessedDataset(root_path: str = './eeg_preproc', chunk_size: int = 128, overlap: int = 0, num_channel: int = 32, 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 10 subjects listening to one of two competing speech audio streams under audio-video or audio-only conditions. 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: Zhang et al.
Year: 2024
Download URL: https://iiphci.ahu.edu.cn/toAuditoryAttention
Reference: ZHANG H, ZHANG J. Based on audio-video evoked auditory attention detection electroencephalogram dataset[J]. Journal of Tsinghua University (Science and Technology), 2024, 64(11): 1919-1926.
Stimulus: 16 stories selected from the Chinese short story collection “Strange Tales from a Chinese Studio”, narrated by a male and a female speaker. Each trial lasts 152 seconds with the target speaker from either 90° left or right.
Signals: Electroencephalogram recorded in a double-walled soundproof booth at the Technical University of Denmark (DTU) using a 32-channel system and digitized at a sampling rate of 1000 Hz (downsampled to 128 Hz).
Rating: Attended speaker (1 for male, 2 for female), attended direction (1 for left, 2 for right), condition (audio-video or audio-only)
In order to use this dataset, the download folder
eeg_preproc.zipis required. After unzipping, the folder should contain the following files:eeg_preproc/ ├── audio-video │ ├── sub1.csv │ ├── sub2.csv │ ├── sub3.csv │ ├── ... │ └── sub10.csv └── audio-only ├── sub1.csv ├── sub2.csv ├── sub3.csv ├── ... └── sub10.csvIn the dataset, 50 Hz power line interference is removed, and the signals are band-pass filtered (0.1-50 Hz) and downsampled to 128 Hz. Subsequently, ocular and muscle artifacts are eliminated using independent component analysis (ICA). Finally, all EEG channels were re-referenced.
An example dataset for CNN-based methods:
from torcheeg.datasets import AVEDProcessedDataset from torcheeg import transforms dataset = AVEDProcessedDataset(root_path='./eeg_preproc', chunk_size=128, overlap=0, num_channel=32, online_transform=transforms.ToTensor(), label_transform=transforms.Compose([ transforms.Select('attended_speaker'), transforms.Lambda(lambda x: int(x) - 1) ])) print(dataset[0])
- Parameters:
root_path (str) – Downloaded data files in CSV format (unzipped eeg_preproc folder) (default:
'./eeg_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 a trial is used as a sample of a chunk. (default:
128)overlap (int) – The number of overlapping data points between different chunks when dividing EEG chunks. (default:
0)num_channel (int) – Number of channels used. (default:
32)online_transform (Callable, optional) – The transformation of 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 of 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) – 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 moving averages, etc. The input of this hook function is a 2D EEG signal with shape (number of electrodes, number of data points), whose ideal output shape is also (number of electrodes, number of data points).
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.after_subject (Callable, optional) – The hook performed on the subject 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:
None)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)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, etc. (default:
True)