SleepFMStager / README.md
adammnrr's picture
Mirror the SleepFM sleep stager in braindecode format
8681fba verified
|
Raw
History Blame Contribute Delete
2.47 kB
metadata
license: cc-by-nc-4.0
library_name: braindecode
tags:
  - eeg
  - polysomnography
  - sleep-staging
  - foundation-model
  - braindecode

SleepFMStager — pretrained sleep stager

Mirror of the official SleepFM sleep-staging model, re-hosted for stable loading from Braindecode.

SleepFM is a multimodal polysomnography (PSG) foundation model introduced in:

R. Thapa et al., "A multimodal sleep foundation model for disease prediction," Nature Medicine (2026). https://doi.org/10.1038/s41591-025-04133-4

Files

File Description
model.safetensors The full stager, with the parameter names of braindecode.models.SleepFMStager
config.json Architecture of the checkpoint, read by from_pretrained()

Upstream ships the stager in two pieces: the channel-agnostic tokenizer lives in the encoder checkpoint (model_base/best.pt) and the staging head in model_sleep_staging/best.pth. This file merges both, so a single call returns a model that is pretrained end to end, its five-class output layer included. The tensors are those of the upstream artifacts; only the keys were rewritten to the library's parameter names. Loading this file or the two upstream ones gives bit-identical outputs.

The upstream artifacts themselves are kept, byte-for-byte, in braindecode/SleepFM.

Usage

from braindecode.models import SleepFMStager

# Defaults to this repository.
model = SleepFMStager.from_pretrained(n_chans=4, n_outputs=5, n_times=3840, sfreq=128)
model.eval()

The output has shape (batch, n_outputs, n_patches): one prediction per 5-second patch, not per 30-second scoring epoch, so six predictions cover one scored epoch. For this checkpoint the five classes are Wake, N1, N2, N3 and REM. Input must be sampled at 128 Hz. Pass n_outputs different from 5 to reinitialise the output layer for another label set.

License & attribution

These weights are not covered by Braindecode's BSD-3 license and inherit the upstream noncommercial terms. Re-hosted for reproducibility and stable availability only; attribution and the CC BY-NC 4.0 restriction are preserved.