# Sleep Disorder Classification Using Convolutional Neural Networks

Chun-Cheng Peng, Chu-Yun Kou

► To cite this version:

Chun-Cheng Peng, Chu-Yun Kou. Sleep Disorder Classification Using Convolutional Neural Networks. 19th IFIP International Conference on Artificial Intelligence Applications and Innovations (AIAI), Jun 2023, León, Spain. pp.539-548, 10.1007/978-3-031-34111-3_45. hal-05449782

HAL Id: hal-05449782

https://inria.hal.science/hal-05449782v1

Submitted on 9 Jan 2026

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons CC BY 4.0 - Attribution - International License
<figure><img src="image_2.png" /></figure>

ifip

International Federation for Information Processing

This document is the original author manuscript of a paper submitted to an IFIP
conference proceedings or other IFIP publication by Springer Nature. As such, there
may be some differences in the official published version of the paper. Such
differences, if any, are usually due to reformatting during preparation for publication or
minor corrections made by the author(s) during final proofreading of the publication
manuscript.
# Sleep Disorder Classification Using
Convolutional Neural Networks

Chun-Cheng Peng and Chu-Yun Kou(✉)

Department of Information and Communication Engineering, Chaoyang University
of Technology, Taichung, Taiwan (R.O.C.)

goudapeng@cyut.edu.tw, s10930624@o365.cyut.edu.tw

**Abstract.** Sleep disorders can cause many inconveniences, such as mental fatigue, poor concentration, emotional instability, memory loss, reduced work efficiency, and increased accident rates. Among them, obstructive sleep apnea is a common sleep disorder characterized by repeated apnea and snoring during night-time, affecting sleep quality, daily life, and work. Therefore, predicting obstructive sleep apnea events can help people better identify and treat sleep disorders and improve quality of life and work efficiency. To enhance the performance of predicting obstructive apnea, we use the MIT-BIH polysomnographic database in this article. We used deep learning methods, specifically transfer learning, with the AlexNet framework to predict the outcome of OSA events. The results show that the best optimization algorithm is SGDM. The accuracy rate is 86.63%, the sensitivity is 92.20%, the precision is 90.55%, and the AUC is 91.95%. This study demonstrates the strong potential of using artificial intelligence techniques, specifically deep learning and transfer learning, to predict OSA events from ECG signals, which could provide valuable information for diagnosing and treating sleep disorders.

**Keywords:** Sleep Disorder · Classification · Deep Learning · Transfer Learning

## 1 Introduction

Being a widespread problem that affects the quality of life and productivity of human beings, it is estimated that 50 to 70 million adults in the United States suffer from sleep disturbance [1]. Lack of good sleep can lead to severe health problems. According to the World Health Organization [2], sleep disorders can lead to physical or psychological problems, such as affecting cardiovascular health, inability to concentrate, or emotional instability, increased risk of depression and anxiety, and increased likelihood of developing high blood pressure and diabetes. Therefore, getting enough quality sleep is essential for good health and mental balance.

Fortunately, deep learning in artificial intelligence can provide more precise, effective, and convenient solutions for detecting and recognizing sleep disorders [3, 4]. For example, physiological indicators and sleep data can be integrated with deep-learning
training to give patients instant feedback on their sleep qualities. Through intelligent analysis, these data can provide useful suggestions on how to improve sleep.

In general, Obstructive Sleep Apnea (OSA) events are medically detected by standard single polysomnography signals, i.e., electroencephalogram, electrocardiogram (ECG), and respiration. In this study, the frequency-domain signals of ECG data are transformed by continuous wavelets to generate time-domain images classified and predicted by the Convolutional Neural Network (CNN). In addition, the AlexNet is trained to predict the outcome of OSA events. The MIT-BIH polysomnogram is then applied in the evaluation stage, which not only reduces the number of layers of the convolutional neural network but also improves the evaluation index data compared with other papers.

The rest of this paper is organized as follows. After the OSA and the target dataset are defined, the related deep-learning models are reviewed in Sect. 2, while the proposed approach is illustrated in Sect. 3. Followed by experimental results and discussions in Sect. 4, conclusions and future works are drawn in Sect. 5.

# 2 Related Works

## 2.1 Obstructive Sleep Apnea and the Target Dataset

Sleep apnea is the repeated collapse of the upper airway (including the nasopharynx, oropharynx, and larynx) during sleep, which blocks the airway and makes breathing difficult [5-7]. In severe cases, the airway is completely blocked, making it impossible to inhale air and hold our breath (asphyxia). At a certain moment, the air cannot enter the lungs smoothly, the body's blood oxygen concentration drops, and the brain is easily awakened due to lack of oxygen, resulting in frequent interruptions of sleep.

According to the studies by the Sleep Center of Stanford University in the United States [7, 8], it is easy to cause airway obstruction due to the collapse of the base of the tongue during sleep. Obstructive sleep apnea occurs in about 4% of men and 2% of women. The most common symptom is snoring, usually very loud, followed by a sudden loud gasp in the middle of the night after a period of silence. In addition, if you feel dry mouth, tired after waking up, or have frequent headaches, daytime lethargy, and irritability, these are also common symptoms of sleep apnea.

The dataset used in this study comes from the MIT-BIH polysomnographic database and uses ECG signals [9]. The recording site was the sleep laboratory of Beth Israel Hospital in Boston, and the subjects were 16 men with an average age of 43 years and a weight of 119 kg. The dataset contains more than 80 h of polysomnographic signals. It labels these signals, including sleep stages (awake, stages 1-4, and rapid eye movement), types of apnea events (obstructive apnea and central apnea), hypopnea, and leg exercises. ECG signal for the MIT-BIH polysomnographic database. Figure 1 illustrates a 30-s signal of normal respiration and a 30-s signal during an OA event.
<figure><img src="image_3.png" /><figcaption>Fig. 1. ECG signal sample. 30 s during normal breathing and OA events, respectively.</figcaption></figure>
## 2.2 Machine Learning for OSA

Machine learning has become one of the critical auxiliary diagnostic methods in modern medicine. It can use a large amount of medical data to automatically learn and train efficient classification, prediction, and identification models and then assist doctors in diagnosing and treating diseases. For example, in medical imaging, machine learning technology can assist physicians in automatically detecting and classifying diseases such as tumors [10], pneumonia [11], and lymphoma [12], thereby improving the accuracy and efficiency of diseases. In addition, machine learning has applications in sleep disorders, such as recurrence plots and convolutional neural networks (RP-CNN) [13]. RP-CNN is a machine learning method based on recurrent graphs and convolutional neural networks for predicting obstructive sleep apnea events, in that paper, the result obtained was the architecture using Resnet18 and the Adam optimizer, this method first converted physiological signals (such as ECG, EEG, etc.) into a time-frequency representation using multi-channel multi-resolution spectral analysis techniques. Then, these time series were converted into a two-dimensional (2D) pattern formed by cycle graph technology to better capture the dynamic characteristics and complexity of the signal. Finally, the recurrent map is learned and classified using a convolutional neural network to predict sleep apnea events, especially OSA events. The study results stated that sleep apnea events could be effectively predicted using the RP-CNN method with precision, recall, and F1 values of 0.88, 0.87, and 0.87, respectively.

## 2.3 Optimizers

The optimization algorithm is used to adjust the model's parameters to minimize the cost function's value. The cost function is usually used to evaluate the model's performance, so minimizing the cost function's value can make the model's prediction more accurate [14].

The choice of optimization algorithm usually affects the model's training speed and final performance. Therefore, in order to obtain better performance, it is essential to choose a suitable optimization algorithm. The general applied optimization algorithms for deep learning include Adaptive Moment Estimation (Adam, [15]), Stochastic Gradient Descent Momentum (SGDM, [16]) and Root Mean Square Propagation (RMSprop, [17]). These three optimization algorithms are briefly introduced respectively as follows.

Adam is an optimization algorithm for adaptive moment estimation. It combines adaptive gradient descent and momentum optimization to converge to the global minimum of the cost function quickly. Adam also has some additional advantages, such as adaptive adjustment of the learning rate and resisting noise.

As a stochastic gradient descent with momentum, the momentum term of SGDM can help the optimization algorithm to pass through the local minimum and accelerate the convergence speed. There are also some variants of SGDM, such as Nesterov Accelerated Gradient, which can better solve some problems of the momentum algorithm.

RMSprop is an optimization algorithm for adaptive learning rates. It can adjust the learning rate according to the size of the gradient to adaptively adjust the update speed of different weights. This enables RMSprop to handle parameters efficiently at different scales, leading to better model optimization.
# 3 Proposed Approach

## 3.1 Data Preprocessing

In the MIT-BIH polysomnographic database, the signal is marked every 30 s. First of all, we need to cut all the signals every 30 s and mark them, accordingly, perform continuous wavelet transformation (CWT) [18] on the cut signals, and express them in a wavelet magnitude graph. The formula definition is stated as in Eq. (1).

$$F(\tau, s) = \frac{1}{\sqrt{|s|}} \int_{-\infty}^{\infty} f(t) \psi^* \left( \frac{t - \tau}{s} \right) dt, \quad (1)$$

where $F(\tau,s)$ is the converted signal, $\tau$, and $s$ are translation parameters and scaling factors, respectively, and $\psi$ is expressed as a mother wavelet. A 2D CWT mass-quality map with color changes corresponding to the ECG signal was generated by CWT, as displayed in Fig. 2.

<figure><img src="image_4.png" /><figcaption>Fig. 2. ECG signal converts 2D CWT. (a) normal event (b) OA events</figcaption></figure>

## 3.2 Transfer Learning—Alexnet

Transfer Learning is mainly to modify the output layer and hyperparameters of the existing model architecture so that it can be used for new image classification, and migration learning can reduce the time we need to rebuild the CNN model [14].

In the experiment, the well-known Alexnet [19] is applied and adjusted the final classification into 2 classes for the corresponding ECG classification, as exhibited in Fig. 3, whereas represents the stride size.
<figure><img src="image_5.png" /><figcaption>Fig. 3. Constructed architecture of the Alexnet</figcaption></figure>

## 4 Experimental Results and Discussions

The experiments of this paper are simulated on a Windows platform, with an Intel(R) Core (TW) i9-10900K CPU @ 3.70 GHz and NVIDIA GeForce RTX 2080 SUPER 8G. All processing steps were performed in MATLAB 2020a. By randomly dividing 80% and 20% of the whole dataset for training and testing, i.e., there are 5486 normal and 1702 OA events in the training set and 1371 and 425 normal and OA patterns in the testing set. The Alexnet framework is applied to training by the previously mentioned three different optimization algorithms. Each of these three optimizers performs 10 specific training runs and then averages to find the best algorithm. The training initial learning rate, maximum epoch, and mini-batch size are set to 10⁻⁴, 30, and 32, respectively. Other optimizers mainly apply MATLAB preset parameters and only the adjusted parameter values are explained.

In addition, the testing results are evaluated by the five commonly considered performance indicators, namely accuracy, sensitivity, specificity, precision, and AUC [20]. The specific formula are defined as follows:

$$ Accuracy = \frac{TP + TN}{TP + TN + FP + FN}, \qquad (2) $$

$$ Sensitivity = \frac{TP}{TP + FN}, \qquad (3) $$
<figure><img src="image_6.png" /><figcaption>(a) SGDM</figcaption></figure>

<figure><img src="image_7.png" /><figcaption>Fig. 4. Confusion matrices of the test results</figcaption></figure>
$$Specificity = \frac{TN}{TN + FP}, \qquad (4)$$

$$Precision = \frac{TP}{TP + FP} \text{ and} \qquad (5)$$

$$AUC = \frac{1}{2} \left( \frac{TP}{TP + FN} + \frac{TN}{TN + FP} \right), \qquad (6)$$

where true positive (TP) is the number correctly predicted as normal breathing, false positive (FP) the number wrongly predicted as normal breathing, true negative (TN) the number of OA events correctly predicted, false negative (FN) the number of OA event mispredictions (Fig. 4).

Table 1 summarizes the evaluation indicators of each applied optimization algorithm, while the SGDM optimizer achieves the best performance, except for about 0.4% of precision lagging behind. Compared with RP-CNN [13], the proposed approach outperforms, in terms of better accuracy, sensitivity, precision, and AUC, with fewer adjustable parameters.

<table><caption>**Table 1.** Evaluation metrics for predicting ECG signals (in %)</caption><thead><tr><th>Method</th><th>Accuracy</th><th>Sensitivity</th><th>Specificity</th><th>Precision</th><th>AUC</th></tr></thead><tbody><tr><td>Alexnet with SGDM</td><td>86.63</td><td>92.20</td><td>68.68</td><td>90.55</td><td>91.95</td></tr><tr><td>Alexnet with Adam</td><td>85.69</td><td>92.05</td><td>65.18</td><td>89.59</td><td>89.39</td></tr><tr><td>Alexnet with RMSprop</td><td>84.67</td><td>89.53</td><td>69.01</td><td>90.92</td><td>91.15</td></tr><tr><td>ResNet18 with RP-CNN [15]</td><td>77.71</td><td>77.59</td><td>77.36</td><td>77.25</td><td>77.24</td></tr></tbody></table>

# 5 Conclusions and Future Works

Sleep disorders may cause various troubles in people's lives, such as mental fatigue during the day, inability to concentrate, mood swings, memory loss, decreased work efficiency and increased accident rates. Among them, OSA is a common sleep disorder characterized by repeated apnea and snoring during night sleep, which may affect sleep quality and daytime life and work. Therefore, predicting OSA events can help people better identify and treat sleep disorders, improving their quality of life and work efficiency.

In this paper, aiming to tackle the OSA classification issue, the MIT-BIH polysomnographic dataset is firstly transformed to 2D CWT maps and then fed into the AlexNet architecture, in order to verify the corresponding recognizing capability of the constructed system. Via the optimization by SGDM, Adam and RMSprop algorithms, experimental evidence shows that the best test accuracy of our proposed approach has reached 86.63%, and with strong potential to be further enhanced.
In the future, hyperparameter optimization schemes, such as Bayesian optimization, and Sparrow Search algorithm will be implemented, in order to advance the system performance for the recognition of sleep disorders.

## References

1. How to Diagnose & Treat the 5 Most Common Sleep Disorders. American Association of Sleep Technologists. https://www.aastweb.org/blog/how-to-diagnose-treat-the-5-most-common-sleep-disorders. Accessed 25 Jan 2023

2. Regional Office for Europe, European Centre for Environment and Health Bonn Office, World Health Organization. WHO Technical Meeting on Sleep and Health: Bonn Germany, 14–17 (2004). https://apps.who.int/iris/handle/10665/349782. Accessed 26 Jan 2023

3. Goldstein, C., Berry, R., et al.: Artificial intelligence in sleep medicine: An American Academy of sleep medicine position statement. J. Clin. Sleep Med. **16**(4), 605–607 (2020). https://doi.org/10.5664/jcsm.8288

4. Hepsiba, D., Vijay Anand, L., Princy, J.: Deep learning for sleep disorders: A review. In: Proceedings of 2021 Seventh International Conference on Bio Signals, Images, and Instrumentation (ICBSII) (2021). https://doi.org/10.1109/ICBSII51839.2021.9445159

5. Malhotra, A., White, D.: Obstructive sleep apnea. The Lancet **360**(9328), 237–254 (2002). https://doi.org/10.1016/S0140-6736(02)09464-3

6. Kribbs, B., Pack, I., Kline, R., et al.: Objective measurement of patterns of nasal CPAP use by patients with obstructive sleep apnea. ATS Journals **147**(4), 887–895 (2012). https://doi.org/10.1164/ajrccm/147.4.887

7. Epstein, L., et al.: Adult obstructive sleep apnea task force of the American Academy of sleep medicine. Clinical Guideline for the Evaluation, Management and Long-Term Care of Obstructive Sleep Apnea in Adults. J. Clin. Sleep Med. **5**(3), 263–276 (2000). https://doi.org/10.5664/jcsm.27497

8. Moore, K.: Site-specific versus diffuse treatment presenting severity of obstructive sleep apnea. Sleep Breath. **4**(04), 145–146 (2000). https://doi.org/10.1055/s-2000-19520

9. Ichimaru, Y., Moody, B.: Development of the polysomnographic database on CD-ROM. Psychiat. Clin. Neurosci. **53**(2), 175–177 (1999). https://doi.org/10.1046/j.1440-1819.1999.00527

10. Esteva, A., Kuprel, B., Novoa, A., et al.: Dermatologist-level classification of skin cancer with deep neural networks. Nature **542**(7639), 115–118 (2017). https://doi.org/10.1038/nature21056

11. Rajpurkar, P., et al.: Chexnet: Radiologist-level Pneumonia detection on chest X-rays with deep learning. arXiv preprint arXiv:1711.05225 (2017). https://doi.org/10.48550/arXiv.1711.05225

12. Bejnordi, E., et al.: Diagnostic assessment of deep learning algorithms for detection of lymph node metastases in women with breast cancer. JAMA **318**(22), 2199–2210 (2017). https://doi.org/10.1001/jama.2017.14585

13. Taghizadegan, Y., Dabanloo, N.J., Maghooli, K., Sheikhani, A.: Obstructive sleep apnea event prediction using recurrence plots and convolutional neural networks (RP-CNNs) from polysomnographic signals. Biomed. Signal Process. Control **69**, 102928 (2021). https://doi.org/10.1016/j.bspc.2021.102928

14. Abd Almisreb, A., Jamil, N., Din, M.: Utilizing AlexNet deep transfer learning for ear recognition. In: Proceedings of 2018 Fourth International Conference on Information Retrieval and Knowledge Management (CAMP), pp. 1–5. IEEE (2018). https://doi.org/10.1109/INFRKM.2018.8464769
15. Diederik, K., Jimmy, B.: Adam: A method for stochastic optimization. arXiv preprint. arXiv: 1412.6980 (2014)

16. Rumelhart, E., Hinton, E., Williams, J.: Learning representations by Back-Propagating errors. Nature **323**(6088), 533–536 (1986). https://doi.org/10.1038/323533a0

17. Hinton, G., Srivastava, N., Swersky, K.: Neural networks for machine learning lecture 6a overview of Mini-Batch Gradient Descent. Cited on **14**(8), 2 (2012)

18. Mallat, S.: A Wavelet Tour of Signal Processing. Academic Press (1999)

19. Krizhevsky, A., Sutskever, I., Hinton, E.: ImageNet classification with deep convolutional neural networks. Commun. ACM **60**(6), 84–90 (2017). https://doi.org/10.1145/3065386

20. Sokolova, M., Lapalme, G.: A systematic analysis of performance measures for classification tasks. Inf. Process. Manag. **45**(4), 427–437 (2009). https://doi.org/10.1016/j.ipm.2009.03.002