Dreams

bciflow.datasets.dreams.dreams_dataset(path='Data/DatabaseREMs/', subject=1, dataGroups=['EEG', 'EOG', 'EMG', 'ECG', 'Resp', 'Oxímetro', 'Outros'], dataType='raw') Dict[str, Any][source]

Description

This function loads EEG and associated biosignals from the The DREAMS REMs Database. It allows loading signals from different channel groups (EEG, EOG, EMG, ECG, respiratory, oximeter, others), and can return either continuous raw signals or windowed epochs. If available, the hypnogram labels (sleep stages) are also loaded.

The dataset can be found at: - https://zenodo.org/records/2650142

param path:

Path to the folder containing the DREAMS dataset files (EDF and hypnogram text files).

type path:

str

param subject:

Index of the subject to load (e.g., subject=1 loads excerpt1.edf).

type subject:

int

param dataGroups:

List of signal groups to include in the dataset. Options include [“EEG”,”EOG”,”EMG”,”ECG”,”Resp”,”Oxímetro”,”Outros”].

type dataGroups:

list of str

param dataType:
Type of data representation:
  • “raw” : returns continuous signals concatenated in time.

  • “epochs” : returns segmented windowed trials (default window = 5s).

type dataType:

str

returns:

A dictionary containing the following keys:

  • X: EEG data as a numpy array [trials, 1, channels, time] or [1, 1, channels, samples].

  • y: Labels corresponding to the EEG data (expanded per sample if raw, per trial if epochs).

  • sfreq: Sampling frequency of the EEG data.

  • y_dict: Mapping of labels to integers.

  • events: Dictionary describing event markers.

  • ch_names: List of channel names.

  • tmin: Start time of the EEG data.

  • data_type: Type of data returned (“raw” or “epochs”).

Dictionary with the following fields: - X : numpy array

EEG/biological data in format:
  • raw mode: (1, 1, n_channels, total_samples)

  • epochs mode: (n_trials, 1, n_channels, samples_per_window)

  • ynumpy array

    Corresponding hypnogram labels (expanded per sample if raw, per trial if epochs).

  • sfreqfloat

    Sampling frequency of the signals.

  • y_dictdict

    Mapping of sleep stage names to integers.

  • eventsNone

    Placeholder for event dictionary (not implemented).

  • ch_nameslist

    List of available channel names.

  • tminfloat

    Start time of the signals (default = 0.0).

  • data_typestr

    Type of data returned (“raw” or “epochs”).

rtype:

dict

raises FileNotFoundError:

If the EDF file for the given subject is not found.

Examples

Load subject 1 data in epochs format:

>>> from bciflow.datasets import dreams_dataset
>>> eeg_data = dreams_dataset(subject=1, dataType="epochs")
>>> print(eeg_data['X'].shape)  # Shape of the EEG data
>>> print(eeg_data['y'].shape)  # Labels aligned with epochs

Load subject 2 raw continuous data with EEG + ECG only:

>>> eeg_data = dreams_dataset(subject=2, dataGroups=["EEG","ECG"], dataType="raw")
>>> print(eeg_data['X'].shape)
>>> print(len(eeg_data['ch_names']))