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”).
- 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']))