Discover Applied Sciences

An explainable spatial–temporal transformer framework with time-stretch encoding for cross-dataset sleep apnea detection

Ji-Jer Huang, Shih-Chung Chen, Irawan Dwi Wahyono

Key points

From the paper's conclusion
  • Conclusion CN-T with time-stretch encoding provides a generalized, interpretable, and resource-efficient approach for OSA detection across heterogeneous sleep datasets, supporting practical clinical and home-monitoring scenarios.

Abstract

Background Obstructive sleep apnea (OSA) is a prevalent respiratory disorder that disrupts sleep architecture and increases cardiometabolic risk. Despite recent progress, many deep learning detectors remain dataset-dependent and exhibit limited cross-dataset generalization. Objective To develop a lightweight and explainable framework that improves robustness for automatic OSA detection across heterogeneous sleep datasets. Methods An explainable convolutional network–Transformer (CN-T) spatial–temporal network is proposed, integrating multi-scale temporal convolutions for local pattern extraction with Transformer self-attention for long-range dependency modeling. The pipeline incorporates apnea-aware time-stretch preprocessing (S = 0.5), which temporally compresses signal duration while preserving spectral characteristics, and nonlinear relative positional encoding (RPE) to improve temporal invariance. Experiments were conducted on three public sleep datasets spanning polysomnography (PSG)-based signals and electrocardiography (ECG), using subject-wise 5-fold cross-validation and macro-averaged reporting. Results An accuracy (ACC) of 97.1 ± 0.3%, sensitivity (SEN) of 93.9 ± 0.6%, specificity (SPEC) of 97.9 ± 0.2%, and area under the receiver operating characteristic curve (AUC) of 97.8 ± 0.2% were achieved by the proposed method, with consistent outperformance of conventional CNN/RNN/LSTM and hybrid baselines while an efficient computational footprint was maintained (8.3 M parameters; 8.7 ms inference per 30-s epoch on RTX 4090). Conclusion CN-T with time-stretch encoding provides a generalized, interpretable, and resource-efficient approach for OSA detection across heterogeneous sleep datasets, supporting practical clinical and home-monitoring scenarios.

Read the paper

Discussion

Science Skim's AI key points, plus readers' public thoughts

Readers' thoughts

No reader thoughts yet.

Related papers

An explainable spatial–temporal transformer framework with time-stretch encoding for cross-dataset sleep apnea detection — Science Skim