Shortcuts

SEEDIVFeatureDataset

class torcheeg.datasets.SEEDIVFeatureDataset(root_path: str = './eeg_feature_smooth', feature: list = ['de_movingAve'], num_channel: int = 62, 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: None | str = None, io_size: int = 1048576, io_mode: str = 'lmdb', num_worker: int = 0, verbose: bool = True)[source][source]

The SEED-IV dataset provided by the BCMI laboratory, which is led by Prof. Bao-Liang Lu. Since the SEED dataset provides features based on matlab, this class implements the processing of these feature files to initialize the dataset. The relevant information of the dataset is as follows:

  • Author: Zheng et al.

  • Year: 2018

  • Download URL: https://bcmi.sjtu.edu.cn/home/seed/seed-iv.html

  • Reference: Zheng W L, Liu W, Lu Y, et al. Emotionmeter: A multimodal framework for recognizing human emotions[J]. IEEE transactions on cybernetics, 2018, 49(3): 1110-1122.

  • Stimulus: 168 film clips.

  • Signals: Electroencephalogram (62 channels at 200Hz) and eye movement data of 15 subjects (8 females). Each subject conducts the experiments in three sessions, and each session contains 24 trials (6 per emotional category) totally 15 people x 3 sessions x 24 trials.

  • Rating: neutral (0), sad (1), fear (2), and happy (3).

  • Features: de_movingAve, de_LDS, psd_movingAve, psd_LDS, dasm_movingAve, dasm_LDS, rasm_movingAve, rasm_LDS, asm_movingAve, asm_LDS, dcau_movingAve, dcau_LDS of 4-second long windows

In order to use this dataset, the download folder eeg_feature_smooth is required, containing the following folder:

  • 1

  • 2

  • 3

An example dataset for CNN-based methods:

from torcheeg.datasets import SEEDIVFeatureDataset
from torcheeg import transforms
from torcheeg.datasets.constants.emotion_recognition.seed import SEED_IV_CHANNEL_LOCATION_DICT

dataset = SEEDIVFeatureDataset(root_path='./eeg_feature_smooth',
                               features=['de_movingAve'],
                               offline_transform=transforms.ToGrid         (SEED_IV_CHANNEL_LOCATION_DICT),
                               online_transform=transforms.ToTensor(),
                               label_transform=transforms.Select('emotion'))
print(dataset[0])
# EEG signal (torch.Tensor[5, 9, 9]),
# coresponding baseline signal (torch.Tensor[5, 9, 9]),
# label (int)

An example dataset for GNN-based methods:

from torcheeg.datasets import SEEDIVFeatureDataset
from torcheeg import transforms
from torcheeg.datasets.constants.emotion_recognition.seed import SEED_ADJACENCY_MATRIX
from torcheeg.transforms.pyg import ToG

dataset = SEEDIVFeatureDataset(root_path='./eeg_feature_smooth',
                               features=['de_movingAve'],
                               online_transform=ToG(SEED_ADJACENCY_MATRIX),
                               label_transform=transforms.Select('emotion'))
print(dataset[0])
# EEG signal (torch_geometric.data.Data),
# coresponding baseline signal (torch_geometric.data.Data),
# label (int)
Parameters:
  • root_path (str) – Downloaded data files in matlab (unzipped ExtractedFeatures.zip) formats (default: './ExtractedFeatures')

  • feature (list) – A list of selected feature names. The selected features corresponding to each electrode will be concatenated together. Feature names supported by the SEED dataset include de_movingAve, de_LDS, psd_movingAve, and etc. (default: ['de_movingAve'])

  • num_channel (int) – Number of channels used, of which the first 62 channels are EEG signals. (default: 62)

  • 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 moving averages, etc. The input of this hook function is a 3D EEG signal with shape (number of windows, number of electrodes, number of features), whose ideal output shape is also (number of windows, number of electrodes, number of features).

  • 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) and key (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 to pickle, pickle-based persistence files are used. When io_mode is set to memory, 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)

Read the Docs v: latest
Versions
latest
stable
v1.1.1
v1.1.0
v1.0.11
v1.0.10
v1.0.9
v1.0.8.post1
v1.0.8
v1.0.7
v1.0.6
v1.0.4
v1.0.3
v1.0.2
v1.0.1
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources