BSTT: A Bayesian Spatial-Temporal Transformer for Sleep Staging

Yuchen Liu, Ziyu JiaICLR 2023 · OpenReview

Overview

BSTT (Bayesian Spatial-Temporal Transformer) is a novel deep learning framework designed to improve automatic sleep staging by adaptively inferring how different brain regions and time slices relate to one another. By combining Bayesian relational inference with the representational power of Transformers, the model achieves state-of-the-art accuracy while providing biologically interpretable insights into brain connectivity during sleep.

The Challenge of Automated Sleep Staging

Sleep staging—the process of categorizing sleep into stages like REM, Light (N1, N2), and Deep (N3)—is vital for diagnosing sleep disorders. Traditionally, this is a grueling manual task performed by specialists analyzing polysomnography (PSG) recordings.

While deep learning has automated much of this process, two major hurdles remain:

  1. Spatial Dynamics: The "topology" of the brain (how different regions interact) isn't static; it changes significantly depending on the sleep stage. Most existing models use fixed spatial filters that cannot adapt to these shifts.
  2. Temporal Transitions: Sleep isn't a random sequence; it follows specific transition rules. Capturing these long-term dependencies and the inherent "uncertainty" of stage transitions is difficult for standard deterministic models.

To address this, researchers argue for a model that doesn't just process data but reasons about the underlying spatial and temporal relationships adaptively.

Methods: The BSTT Architecture

The core innovation of this paper is the Bayesian Spatial-Temporal Transformer (BSTT). It breaks the problem down into sequential spatial and temporal processing stages, unified by probabilistic reasoning.

Architecture of the Bayesian Spatial-Temporal Transformer (BSTT)

The architecture relies on three main components:

  • Bayesian Relation Inference: Instead of assuming a fixed relationship between EEG channels or time slices, this component treats these relationships as random variables. Using a method inspired by Deep Graph Random Processes (DGP), it infers a "relation intensity graph" to handle the inherent uncertainty in brain signals.
  • Spatial Transformer: This module uses the inferred Bayesian spatial relations to extract features across different EEG channels. It essentially asks: "Which parts of the brain are communicating most effectively right now?"
  • Temporal Transformer: Focusing on the sequence of sleep epochs (usually 30-second slices), this module captures the "transition rules" that define how a subject moves from one sleep stage to another.

To train the model, the authors maximize the Evidence Lower Bound (ELBO). This ensures the Bayesian components are optimized to represent the most likely relational structures given the input data.

Key Insights and Biological Alignment

  • Adaptive Connectivity: The model's high performance stems from its ability to re-evaluate connectivity for every epoch. It doesn't just learn a general "sleep graph"; it learns a "Stage N2 graph" or a "REM graph" dynamically on the fly.
  • Biological Interpretability: Visual analysis of the inferred spatial graphs revealed that brain connectivity is significantly stronger in light sleep (N1, N2) than in deep sleep (N3). This perfectly mirrors medical research showing that cerebral blood flow and metabolic rates drop significantly during deep sleep.
  • The Power of Uncertainty: By using a Bayesian approach, the model becomes significantly more robust.
Ablation study results demonstrating the impact of Bayesian inference and spatial/temporal modules

As shown in the ablation study above, removing the Bayesian relational inference component (STT) caused a larger performance drop across all metrics than removing either the spatial (BTT) or temporal (BST) modules individually. This highlights that modeling uncertainty is just as critical as modeling the spatial-temporal features themselves.

Key Results

The model was evaluated on two prominent public datasets following the AASM standard (Wake, N1, N2, N3, and REM): ISRUC (100 subjects, 6 EEG channels) and MASS-SS3 (62 subjects, 19 EEG channels).

BSTT consistently outperformed state-of-the-art baselines, including MCNN, DeepSleepNet, and GraphSleepNet:

  • ISRUC Dataset: Achieved an accuracy of 81.96% and a Kappa coefficient of 76.78%.
  • MASS Dataset: Achieved an accuracy of 89.50% and a Kappa coefficient of 84.37%.

These results were statistically significant ($p < 0.05$), proving that the Bayesian spatial-temporal approach provides a tangible edge over purely deterministic or non-adaptive graph models.

Limitations and Future Work

While the paper demonstrates strong results, a few areas remain for exploration:

  • Computational Complexity: Bayesian inference and multi-head Transformers are computationally expensive. The authors noted that certain terms in the ELBO are difficult to calculate and required approximations. Scaling this to real-time, low-power wearable devices might be a challenge.
  • Generalization: While tested on two datasets, the model's performance on subjects with specific sleep disorders (like apnea or insomnia) requires further validation.
  • Broader Applications: The authors suggest that BSTT is a "general framework." Future work could involve applying this Bayesian Transformer architecture to other EEG-based tasks, such as emotion recognition or motor imagery for brain-computer interfaces.

Summary updated

Abstract

Sleep staging is helpful in assessing sleep quality and diagnosing sleep disorders. However, how to adequately capture the temporal and spatial relations of the brain during sleep remains a challenge. In particular, existing methods cannot adaptively infer spatial-temporal relations of the brain under different sleep stages. In this paper, we propose a novel Bayesian spatial-temporal relation inference neural network, named Bayesian spatial-temporal transformer (BSTT), for sleep staging. Our model is able to adaptively infer brain spatial-temporal relations during sleep for spatial-temporal feature modeling through a well-designed Bayesian relation inference component. Meanwhile, our model also includes a spatial transformer for extracting brain spatial features and a temporal transformer for capturing temporal features. Experiments show that our BSTT outperforms state-of-the-art baselines on ISRUC and MASS datasets. In addition, the visual analysis shows that the spatial-temporal relations obtained by BSTT inference have certain interpretability for sleep staging.
BibTeX
@inproceedings{liu2023bstt,
  author = {Yuchen Liu and Ziyu Jia},
  title = {{BSTT: A Bayesian Spatial-Temporal Transformer for Sleep Staging}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=ZxdkjTgK_Dl},
}
Figure