Sleep onset prediction

Name: sleep_onset
Category: sleep
Dataset: Kemp2000 (Sleep-EDF)
Objective: Regression
Split: Leave-subjects-out

Usage

neuralbench eeg sleep_onset
Show config.yaml
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.

data:
  study:
    source:
      name: Kemp2000Analysis
    annotate_sleep_onset:
      name: AddSleepOnsetTargets
      max_pre_n2_s: 1200.0
    split:
      name: SklearnSplit
      split_by: subject
      valid_split_ratio: 0.2
      test_split_ratio: 0.2
      valid_random_state: 33
      test_random_state: 33
  # Sleep-EDF (Kemp2000) recordings only expose bipolar derivations (Fpz-Cz,
  # Pz-Oz) whose MNE ch_locs are NaN, so the default ``ch_locs``-derived
  # position mapping in ``ChannelPositions`` produces all-``INVALID_VALUE``
  # positions.  Explicitly use the standard_1020 montage so the split-on-``-``
  # fallback resolves Fpz-Cz -> Fpz and Pz-Oz -> Pz to real 3D coordinates.
  channel_positions:
    layout_or_montage_name: standard_1020
  target:
    =replace=: true
    name: SleepOnsetTargetExtractor
    event_types: SleepOnsetMarker
    aggregation: trigger
    cap_s: 600.0
  trigger_event_type: SleepOnsetMarker
  start: 0.0
  duration: 5.0
  stride: 5.0
  sampler:
    name: RegressionBinSampler
    bin_edges: [0.0, 40.0, 90.0, 300.0, 600.0]
  summary_columns: [n2_onset]
brain_model_output_size: &brain_model_output_size 1
trainer_config:
  monitor: val/bmae
  mode: min
  patience: 7
  n_epochs: 40
loss:
  name: MultiLoss
  losses:
    mse:
      name: MSELoss
  weights:
    mse: 0.0001  # targets are in [0, 600] s; weight=0.0001 (0.01^2) keeps MSE <= ~36 so gradient clipping does not saturate.
metrics: !!python/object/apply:neuralbench.defaults.metrics.get_sleep_onset_metric_configs []

Description

Given a continuous EEG recording leading up to sleep, predict at every point in time how many seconds remain before the participant falls asleep. Models output a single regression value per analysis window, capped at 600 s (10 minutes pre-onset). Inference is strictly causal: predictions for window [t - 5, t] may only depend on EEG up to time t. The benchmark uses non-overlapping 5-s analysis windows – one model input per 5-s slice of EEG – so every recording yields one prediction every 5 s of pre-onset signal.

Sleep onset is defined as N2 onset: the timestamp of the first scored N2 epoch in the polysomnogram-aligned hypnogram. N2 was chosen (rather than the looser N1 or “first non-wake” definition) because it is the most reliably scored stage across raters, the most reproducible across recording nights, and corresponds to the consolidated transition into sleep that is clinically meaningful [Rechtschaffen1968]. The AddSleepOnsetTargets transform emits a single SleepOnsetMarker event per recording spanning the trainable pre-onset region, carrying the absolute n2_onset timestamp. The segmenter tiles this marker via stride to produce 5-s analysis segments, and the SleepOnsetTargetExtractor computes clip(n2_onset - segment.stop, 0, 600) at extraction time – so the target is always derived from the actual segment boundary.

Evaluation

The headline metric is bMAE (binned MAE): the mean absolute error computed inside each of four ground-truth time-to-onset bins, averaged across bins with equal weight. The bin boundaries map onto distinct physiological regimes that demand fundamentally different algorithmic capabilities.

Standard regression metrics (MAE, RMSE, Pearson r, R^2, normalized RMSE) are also logged alongside the headline bmae.

References

[Kemp2000]

B Kemp, AH Zwinderman, B Tuk, HAC Kamphuisen, JJL Oberyé. Analysis of a sleep-dependent neuronal feedback loop: the slow-wave microcontinuity of the EEG. IEEE-BME 47(9):1185-1194 (2000).

[Rechtschaffen1968]

A Rechtschaffen, AE Kales. A manual of standardized terminology, techniques and scoring systems for sleep stages of human subjects. Los Angeles, CA: UCLA Brain Information Service. Brain Research Institute 10 (1968).