Skip to content
Open access

A Hybrid CNN–Transformer Model Integrating Raw ECG Signals and Handcrafted Features for Automated Sleep Apnea Detection

2026 · IEEE Access · Vol 14, pp. 151770-151799 · 1 citation · 62 references

Abstract

Sleep apnea is an underdiagnosed common sleep disorder with significant morbidity in the cardiovascular and neurological systems. The gold-standard diagnostic tool is polysomnography, which is costly and resource-intensive and is not available to many patients. There is a need for affordable, easy-to-use, readily available screening tools that can be used in primary care and people’s homes. This paper proposes a new hybrid deep learning model to detect sleep apnea using a single-lead electrocardiogram (ECG) signal. The proposed architecture consists of a multi-scale convolutional neural network (CNN) and a Transformer encoder for processing raw ECG signals, along with a handcrafted side branch that includes statistical, spectral, and heart rate variability (HRV) features. The model utilises both the rich temporal representations that can be learnt from raw signals and the domain knowledge captured in handcrafted features previously acquired in a clinical setting, using cross-attention and gated fusion mechanisms. The model was trained and tested on the MIT–BIH Apnea–ECG database, containing 17,068 one-minute windows from 35 recordings, partitioned into an 80/20 stratified train-test split. The proposed hybrid approach outperforms the classical machine learning baselines (XGBoost, Random forest, LightGBM, SVM-RBF, and Logistic regression) and previous deep learning-based approaches, achieving an accuracy of 96.8%, sensitivity of 94.7%, specificity of 98.1%, and an AUC-ROC of 0.980. The improvement is statistically significant, based on a bootstrapping test (p<0.001). Ablation studies reveal that the Transformer encoder and the handcrafted feature branch contribute the most, with 1.4 and 1.1 percentage points to the AUC, respectively. Five-fold cross-validation is used to assess the model’s robustness, yielding a mean AUC of $0.979~\pm ~0.002$ . Interpretability analysis (Transformer attention maps, SHAP feature importance) shows that the model focuses on clinically relevant parts of the ECG, such as the QRS complex and the T-wave, and that the most important predictors are HRV parameters, including RMSSD, heart rate standard deviation, and LF/HF ratio. This transparency enhances clinical confidence and the ease of integration into the clinical workflow. The model is computationally efficient, with about 450K trainable parameters, enabling real-time inference on edge devices and wearable platforms. These limitations are also briefly explored, including the evaluation on a single dataset, binary classification of severity, and future directions of held-out test set validation, multi-class severity classification, and multimodal integration. The hybrid model may be a viable alternative for non-invasive, easily accessible screening for sleep apnea, reducing the burden on specialised sleep laboratories, speeding up diagnosis, and ultimately improving patient outcomes. The code and pre-trained models are made publicly available to ensure transparency and reproducibility, as well as to support other studies.

Read PDF

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.