Shortcuts

ISRUCDataset

class torcheeg.datasets.ISRUCDataset(root_path: str = './ISRUC-SLEEP', groups: List = [0, 1, 2], channels: List = ['F3-M2', 'C3-M2', 'O1-M2', 'F4-M1', 'C4-M1', 'O2-M1'], l_freq: float = 0.5, h_freq: float = 30, sfreq: int = 100, online_transform: None | Callable = None, offline_transform: None | Callable = None, label_transform: None | Callable = None, io_path: None | str = None, io_size: int = 1048576, io_mode: str = 'lmdb', num_worker: int = 0, verbose: bool = True, **kwargs)[source][source]

A polysomnographic (PSG) dataset named ISRUC-Sleep that was created aiming to help sleep researchers in their studies. 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: Khalighi et al.

  • Year: 2016

  • Download URL: https://sleeptight.isr.uc.pt/

  • Reference: Khalighi S, Sousa T, Santos J M, et al. ISRUC-Sleep: A comprehensive public dataset for sleep researchers[J]. Computer methods and programs in biomedicine, 2016, 124: 180-192.

  • Signals: Three groups of data. Group 1’s data contains 100 subjects, with one recording session per subject; Group 2’s data contains 8 subjects, with two recording sessions per subject; Group 3’s data contains 10 healthy subjects. PSG recordings include electrophysiological signals, pneumological signals, and another contextual information of the subjects (‘C3-A2’, ‘C4-A1’, ‘DC3’, ‘DC8’, ‘F3-A2’, ‘F4-A1’, ‘LOC-A2’, ‘O1-A2’, ‘O2-A1’, ‘ROC-A1’, ‘SaO2’, ‘X1’, ‘X2’, ‘X3’, ‘X4’, ‘X5’, ‘X6’, ‘X7’, ‘X8’).

  • Rating: Sleep stages were annotated in 30 second contiguous intervals (Sleep stage W, Sleep stage N1, Sleep stage N2, Sleep stage N3, Sleep stage R, Lights off@@EEG F4-A1).

In order to use this dataset, the following file structure is required:

ISRUC-SLEEP/
├── Subgroup_1/
│   ├── 1/
│   │   ├── 1.rec
│   │   └── 1_1.txt
│   └── ...
├── Subgroup_2/
│   └── ...
└── Subgroup_3/
    └── ...

An example dataset:

dataset = ISRUCDataset(root_path='./ISRUC-SLEEP',
                    sfreq=100,
                    channels=['F3-M2', 'C3-M2', 'O1-M2',
                                'F4-M1', 'C4-M1', 'O2-M1'],
                    label_transform=transforms.Compose([
                        transforms.Select('label'),
                        transforms.Mapping({'Sleep stage W': 0,
                                            'Sleep stage N1': 1,
                                            'Sleep stage N2': 2,
                                            'Sleep stage N3': 3,
                                            'Sleep stage R': 4,
                                            'Lights off@@EEG F4-A1': 0})
                    ]),
                    online_transform=transforms.Compose([
                        transforms.MeanStdNormalize(),
                        transforms.ToTensor(),
                    ]),
                    )
print(dataset[0])
# EEG signal (torch.Tensor[6, 3000]),
# label (int)
Parameters:
  • root_path (str) – Root path of the ISRUC dataset. (default: './ISRUC-SLEEP')

  • groups (list) – List of groups to include in the dataset. 0 for Subgroup_1, 1 for Subgroup_2, and 2 for Subgroup_3. (default: [0, 1, 2])

  • channels (list) – List of EEG channels to use. Available channels are ‘C3-A2’, ‘C4-A1’, ‘DC3’, ‘DC8’, ‘F3-A2’, ‘F4-A1’, ‘LOC-A2’, ‘O1-A2’, ‘O2-A1’, ‘ROC-A1’, ‘SaO2’, ‘X1’, ‘X2’, ‘X3’, ‘X4’, ‘X5’, ‘X6’, ‘X7’, ‘X8’. (default: ['F3-M2', 'C3-M2', 'O1-M2', 'F4-M1', 'C4-M1', 'O2-M1'])

  • l_freq (float) – Low cut-off frequency in Hz. (default: 0.5)

  • h_freq (float) – High cut-off frequency in Hz. (default: 30)

  • sfreq (int) – The sampling frequency to resample the signal to in Hz. (default: 100)

  • online_transform (Callable, optional) – The transformation of the EEG signals. The input is a np.ndarray, and the ouput 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 ouput is used as the second value of each element in the dataset. (default: None)

  • io_path (str, optional) – 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. 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)

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