OmniSleep is a multimodal sleep representation pretraining project for PSG signals, including EEG, EOG, EMG, ECG, and respiratory channels. The training pipeline combines leave-one-out contrastive alignment with masked autoencoding and cross-system contrastive learning.
The original single-file script has been organized into a Python package:
src/omnisleep/config.py: default paths, model dimensions, and training hyperparameterssrc/omnisleep/data.py: HDF5 text-list dataset loadersrc/omnisleep/models.py: multimodal encoders, RoPE transformer blocks, andFiveModalSleepModelsrc/omnisleep/losses.py: contrastive learning objectivessrc/omnisleep/training.py: Phase 1 and Phase 2 training loopssrc/omnisleep/cli.py: command-line training entry pointconfigs/pretrain.yaml: documented experiment defaults
See docs/PROJECT_STRUCTURE.md for the full tree.
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .Install a CUDA-enabled PyTorch build that matches your GPU and driver when training on GPU.
By default, training reads file lists from:
dataset/splits/train_files.txt
dataset/splits/val_files.txt
Each line in train_files.txt should point to an HDF5 file. The loader expects the following groups/keys:
x/EEGx/EOGx/EMGx/ECGx/Resp_Airflowx/Resp_Thoraxx/Resp_Abdomenyfor epoch count- optional
ch_presence_maskattributes for channel availability
Run with the compatibility wrapper:
python pretrain.pyOr, after installation:
python -m omnisleep.cliMulti-GPU distributed training can be launched with torchrun:
torchrun --nproc_per_node=4 -m omnisleep.cliDefault hyperparameters live in src/omnisleep/config.py; configs/pretrain.yaml mirrors them for experiment tracking.
This project is licensed under the MIT License. See LICENSE for details.