You are on page 1of 11

IAES International Journal of Artificial Intelligence (IJ-AI)

Vol. 99, No. 1, Month 2099, pp. 1~1x


ISSN: 2252-8938, DOI: 10.11591/ijai.v99.i1.pp1-1x  1

Sleep Apnea Recognition of Electroencephalogram Signal Using


Convolutional Neural Networks

Esmeralda Contessa Djamal1, Fikri Nugraha1


1,2
Department of Informatics, Universitas Jenderal Achmad Yani, Cimahi, Indonesia

Article Info ABSTRACT


Article history: Sleep apnea is a sleep disorder characterized by temporary interruptions in
breathing airflow or periods of shallow breathing during sleep. These
Received month dd, yyyy interruptions, called apneas, last for ten seconds or more. Several devices
Revised month dd, yyyy can detect it, such as heart rate, video of respiratory movements,
Accepted month dd, yyyy Electrocardiogram (ECG) signals, or Electroencephalogram (EEG) signals.
Several studies have utilized these variables utilizing machine learning.
Identification based on respiratory videos has limitations, especially Sleep
Keywords: Apnea Central and minimal public databases in machine learning. While
Heart Rate and ECG variables, EEG signals are more widely used to detect
Sleep Apnea sleep disorders, including Sleep Apnea. This paper proposes a method for
EEG signal identifying Sleep Apnea from EEG signals using Wavelets and
CNN Convolutional Neural Networks. Testing was carried out ten-fold,
Wavelet representing the proposed the method performance. Machine learning needs
Machine learning to increase generalization capabilities. Among them, learning rate flexibility
is carried out automatically. We also tried selecting pooling techniques,
updating weights, and balancing the dataset for each class. They obtained
optimal parameters with performance from 10-Fold, which also uses
regularization to prevent overfitting and increase generalization ability. The
accuracy obtained was up to 80%.
This is an open access article under the CC BY-SA license.

Corresponding Author:

1. INTRODUCTION
Sleep Apnea is a temporary breathing disorder during sleep, characterized by ten-second or longer
periods of shallow breathing. There are some types of sleep apnea. Obstructive sleep apnea (OSA) occurs
when airways narrow or close during sleep, and it is associated with the relaxation of muscles at the back of
the neck. It leads to difficulty breathing and potentially the complete stoppage of breath. Central sleep apnea
(CSA) results from a lack of signals from the brain to muscles that control breathing, which Causes the
complete stoppage of chest movements [1]. Polysomnography (PSG) is widely considered the gold standard
for diagnosing sleep apnea and other sleep disorders. It is a comprehensive sleep study that monitors multiple
physiological parameters during sleep to assess sleep quality and patterns. PSG includes recording electrical
waves in the brain using an Electroencephalogram (EEG), heart rhythm using Electrocardiography (ECG),
oxygen saturation, and video recording [2].
Several studies are related to identifying Sleep Apnea and other sleep disorders. One of them uses
videos of respiratory movements using ROI and RNN [3] [4], and the other uses random forest [5] and
statistical analysis [6]. Sleep Apnea was detected using SVM of some EEG features [7] and some methods
[8]. Heart rate and SpO2 information provide machine learning limitations compared to ECG and EEG
signals. [9].
Electroencephalogram (EEG) signals record electrical activity in the brain. Sleep Apnea
characteristics seen in EEG signal patterns considering brain activity during apnea can provide insight into

Journal homepage: http://ijai.iaescore.com


2  ISSN: 2252-8938

brain dysfunction due to SAHS and related complications [10]. The research stated that sleep patterns
changed when OSA was discovered [1]. Previous studies used CNN to identify ischemic and no-stroke
patients by looking at EEG signals in one-dimensional objects [17, 18]. In other studies, CNN was used to
identify MI [28] and ECG [13]. The feature generated by this layer will be input into the CNN identification
layer through training first.
This research provides a sleep apnea recognition model from raw EEG signals using CNN by
providing information on the influence of architecture, configuration, and parameters that provide good
performance. CNN is an excellent tool for extracting features from complex data that other methods cannot
detect. Simplicity provides advantages for speed in automatic sleep apnea recognition applications.

2. MATERIAL AND METHODS

2.1. Data Set


The EEG data was from the MIT-BIH Polysomnographic (PSG) Database
(https://physionet.org/content/slpdb/1.0.0/). PSG recorded this dataset from 16 subjects, male, 32-56 years
old (mean 40) without sleep apnea syndrome [14]. Before recording, EEG data are crucial for obtaining
accurate and reliable results in sleep studies. Avoid alcohol and Caffeine because it might initially make a
person feel drowsy and disrupt sleep quality.
Each file was saved for 16 subjects with 72 hours of recording, each file recording for 4-5 hours.
After being segmented for observations every 30 seconds, there are 8640 files. As much as 80% is used as
training data, while model testing uses 20%. By avoiding alcohol, the recorded EEG data is more likely to
represent the natural sleep stages and transitions without the confounding effects of alcohol-induced sleep
disturbances. This preparation likely helps ensure that the recorded EEG data is representative of their sleep
patterns [10].
The wireless EEG system has two channels: C4-A1, O2-A1, and C3-O1, as shown in Figure 1. The
EEG signals are sampled at a frequency of 250 Hz. Two hundred fifty data points (samples) are collected per
second. The collected EEG data is segmented into segments, each spanning 30 seconds, resulting in 7500.

Figure 1. Sleep Apnea recognition of EEG signals

2.2 Sleep Apnea Recognizing Model


The EEG signal is processed every 30 seconds. It is recorded from C4, O2, and C3 channels with
A1 as ground. In pattern recognition, Convolutional Neural Networks (CNN) potentially process data in the
time domain, such as an EEG signal [15]. CNN is deep learning, which is quite simple and can also be
applied to sequence data with certain segments besides Recurrent Neural Networks. The algorithm has been
evaluated in previous studies, such as EEG signals of post-stroke patients [16], sleep levels [17], and sleep
apnea detection [18].
Some researchers have extracted EEG signals into frequency bands. However, pay attention to the
access time based on the reviewed variable, particularly sleep apnea. Previous studies used raw EEG signals
to identify attention deficit hyperactivity disorder [19]. This paper proposed Sleep Apnea recognition using
convolutional neural networks of EEG signals, as shown in Figure 2.

Int J Artif Intell, Vol. 99, No. 1, Month 2099: 1-1x


Int J Artif Intell ISSN: 2252-8938  3

CNN

Feature Extraction

Convolution
Pre- processing
Segmentation
30 Second ELU activation
No Apnea
6,912 Training Data
C4, O2, C3 channels Pooling dan
Dropout
Fully connected
Backpropagation
Training

Feature Extraction Sleep Apnea


Weight
Convolution
Sleep
Patient Fully connected
Pre- processing
ELU activation Identification
Segmentation
30 Second

Max Pooling

Figure 2. Sleep Apnea recognition using CNN

CNN consists of a convolution layer that extracts features and a fully connected classification layer
for learning and identification. as in Figure 2. The classification or identification layer mostly uses a multi-
layer perceptron (MLP) architecture with backpropagation learning [19]. Meanwhile, other research used a
support vector machine [20].
The architecture of CNN is shown in Figure 3. The convolution layer intends to extract features
from the input data and process them in the next convolutional or fully-connected layers. This layer
calculation uses the dot product between the signal and kernel as convolution. This model uses exponential
linear unit (ELU) activation. ELU and Rectified Linear Unit (ReLU) are both activation functions used in
neural networks. While ReLU is widely popular, ELU offers some advantages that can be beneficial in
certain situations [21]. For example, ELU speeds up learning in deep neural networks and leads to higher
classification accuracy [22].
ELU can handle negative values more smoothly than ReLU and avoids the "dying ReLU" problem,
where neurons might become inactive during training. ELU provides a smooth transition for negative inputs,
which can help in gradient-based optimization methods. The smoothness of the activation function may result
in more stable training. ELU smoothness can mitigate the vanishing gradient problem, which occurs when
gradients become extremely small during backpropagation. It makes it challenging for the network to learn.
Pooling and dropout were used at the end convolutional layer. Pooling intends to downsampling to
shorten the feature maps. Max Pooling and Average Pooling are often used in machine learning. The choice
between max pooling and average pooling is often considered a hyperparameter in the design of CNN
architectures. Max Pooling emphasizes the most prominent feature in the region. It provides translation
invariance, making the network more robust to small translations in the input. Average pooling provides a
smoothed representation of the input. It helps reduce the impact of outliers and noise in the data, so it is
useful when absolute presence is more important than its exact location. It may be less sensitive to small,
localized features than max Pooling. Dropout was used as a regularizer to improve model generalization and
avoid overfitting. The final layer is a fully connected layer whose objective is to categorize the label targets
of the map features from the layer beneath it. This layer employs the softmax activation function as the
probability value, as shown in Figure 3.

Sleep Apnea Recognition of Electroencephalogram Signal Using Convolutional Neural Networks


4  ISSN: 2252-8938

Figure 3. The architecture of CNN for Sleep Apnea recognition

CNN consists of one, two, and three dimensions. This research uses a one-dimensional CNN
architecture, as in Figure 3. CNN input size is 7500 from sampling results, with two convolutions and an
ELU function. Pooling size 5, using the max function, and testing the average function. Dropout measures
0.3. Fully connected uses a multilayer perceptron (MLP) architecture with two hidden layers measuring ten
neurons. Meanwhile, the output consists of two neurons according to the number of classes with the Softmax
function for identification.
Machine learning models are trained using optimization algorithms that adjust the parameters to
minimize a loss function. Various optimization algorithms exist, each with its characteristics and advantages.
This research used Stochastic Gradient Descent (SGD), Adaptive Delta/learning rate (AdaDelta), Adaptive
Moment Estimation (Adam), Adamax, and Nesterov-accelerated Adaptive Moment Estimation (Nadam).
SGD is a gradient descent method in which the model parameters are updated in the opposite
direction of the gradient. It is simple, easy to implement, and computationally efficient. AdaDelta adapts the
learning rates for each parameter individually, eliminating the need to specify a global learning rate
manually. AdaDelta maintains a running average of the squared gradients similar to RMSprop. However,
AdaDelta also tracks the running average of parameter updates, which is the Adam uses an exponentially
weighted average of past gradients. It combines ideas from momentum and RMSprop. It maintains the
moving average of past gradients and the moving average of past squared. Nadam is an optimization
algorithm that combines Nesterov Accelerated Gradient (NAG) and Adam. It incorporates the advantages of
both algorithms and aims to provide efficient and robust optimization for training deep neural networks.
Nadam includes the Nesterov momentum term, which allows the optimizer to account for the future gradient
when updating the weights. It can lead to faster convergence and better handling of the learning path,
especially in regions with high curvature.
Regularization is a strategy used in machine learning to prevent overfitting and improve the
generalization ability of a model. Overfitting occurs when a model learns the training data too well, including
its noise and outliers, and performs poorly on new, unseen data. Regularization introduces a penalty term to
the model's objective function, discouraging overly complex models.

3. RESULTS AND DISCUSSION


This research proposes recognizing Sleep Apnea from EEG signals, which consist of two classes,
namely Sleep Apnea and No Sleep Apnea. Experiments were carried out to look for the influence of
parameters and techniques that can improve performance: balanced data set, the influence of learning rate
following the Loss value, weight correction techniques, Pooling variations, and the influence of
regularization to prevent overfitting. The research also compares the performance of the proposed method
with previous research that used the same dataset.

3.1. Balance vs unbalanced dataset


Despite having a larger dataset and similar performance, unbalanced data can lead to instability in machine
learning models. The significant disparity in the Accuracy and Loss results is shown in Table 1 and Figure 4.

Table 1. Balanced Dataset


Dataset Accuracy (%) Loss
Balanced 75.10 0.587
Unbalanced 72.46 0.646

Int J Artif Intell, Vol. 99, No. 1, Month 2099: 1-1x


Int J Artif Intell ISSN: 2252-8938  5

(a)

(b)

Figure 4. Performance toward balanced dataset (a) Accuracy (b) Loss

The variety and number of datasets influence generalization efforts in learning. Experiments show
that balancing the data increases accuracy by up to 3% and reduces Loss value. As seen in Figure 4, data
balance also provides shorter transient times, is more stable, and reduces overfitting.

3.2. Optimization of Learning Technique


In machine learning, especially in tasks like EEG signal classification, convolutional neural
networks (CNNs) are widely used. However, the effectiveness of a CNN relies not only on its architecture
but also on various optimization techniques, including pooling and weight correction techniques. The
discussion is divided into comparing Pooling methods such as maximum and average. And secondly, a
comparison of the use of weight correction techniques.

3.2.1. Pooling Comparison


Max pooling and average pooling are common techniques used in convolutional neural networks
(CNNs) for down-sampling or pooling layers. Both have their characteristics and can impact the performance
of the network differently. Max pooling preserves more detailed features, while average pooling provides a
more generalized and smoothed representation. Max Pooling emphasizes the most prominent feature in the
region. It provides a form of translation invariance, making the network more robust to small translations in
the input. Average pooling provides a smoothed representation of the input and reduces the impact of outliers
and noise in the data. It may be less sensitive to small, localized features than max Pooling. Max pooling
preserves more detailed features, while average pooling provides a more generalized and smoothed
representation. A comparison between pooling techniques is shown in Table 2 and Figure 5.

Sleep Apnea Recognition of Electroencephalogram Signal Using Convolutional Neural Networks


6  ISSN: 2252-8938

Table 2. Pooling Comparison


Pooling Accuracy (%) Loss
Average 70.66 0.608
Maximum 72.46 0.646

Both pooling methods can overcome overfitting. Although slightly, Max Pooling is better than
Average Pooling. It suggests that the characteristics of the EEG signal from Sleep Apnea provide prominence
that Max Pooling can better capture. However, average pooling provides a more stable performance
regarding accuracy and loss values, as shown in Figure 5.

(a)

(b)

Figure 5. Performance comparison Max Pooling and Average Pooling (a) Accuracy (b) Loss

3.2.2. Weight Correction Technique

Machine learning models are trained using optimization algorithms that adjust the parameters to
minimize a loss function. There are various optimization algorithms, each with its characteristics and
advantages. This research used SGD, AdaDelta, Adam, Adamax, and Nadam, as shown in Table 3 and Figure
6.

Table 3. Comparison Weight Correction Technique


Optimizer Accuracy (%) Loss
SGD 55.99 0.769
AdaDelta 53.59 0.783
Adam 67.66 0.786
Adamax 68.00 0.730
Nadam 72.46 0.646

Int J Artif Intell, Vol. 99, No. 1, Month 2099: 1-1x


Int J Artif Intell ISSN: 2252-8938  7

No single optimizer provides the best accuracy for every task and dataset. The choice of optimizer
depends on several things, such as the task, model, dataset characteristics, and model architecture used. From
the experiments, the performance of the five weight correction techniques only stands out a little, though
Nadam is the most optimal Table 3 and Figure 6.

(a)

(b)

Figure 6. Optimization of weight correction technique (a) Accuracy (b) Loss

Adam is generally considered a good and efficient optimizer. Often provides good results on a
variety of tasks and datasets. Nadam is a variant of Adam that combines Nesterov momentum to give good
results. The experimental results show that choosing the right weight correction technique is important.

3.3. Influence of Auto learning rate


A cyclical Learning Rate gives more flexibility and stability to adapt and change the learning rate,
little by little, instead of a static learning rate that can cause fluctuation in looking for global optimal.

Table 4. Influence of Auto learning rate


Auto Learning Rate Accuracy (%) Loss
with 72.46 0. 687
without 69.16 0.702

Sleep Apnea Recognition of Electroencephalogram Signal Using Convolutional Neural Networks


8  ISSN: 2252-8938

(a)

(b)
Figure 7. Auto learning rate optimization (a) Accuracy (b) Loss

3.4. Regularization comparison


The final simulation tests the effect of regularization on model performance. You can see an
increase in accuracy of around 4% and a decrease in Loss. Even though initially, without regularization, it
provides good performance, it tends to fluctuate and is less stable. It can be seen that Loss with regularization
provides better Loss reduction, as in Figure 7 and Table 5.

Table 5. Influence of Regularization


Regularization Accuracy (%) Loss
with 77.10 0.493
without 72.46 0.646

Int J Artif Intell, Vol. 99, No. 1, Month 2099: 1-1x


Int J Artif Intell ISSN: 2252-8938  9

(a)

(b)
Figure 7. Regularization (a) Accuracy (b) Loss

3.4. Comparison of Other Research


With the same data set, the accuracy performance using other methods from previous research is
compared as in Table 6.
Table 6. Comparison with other research
Methods Accuracy (%)
..
..
1D CNN 77.10

4. CONCLUSION
Provide a statement that what is expected, as stated in the "INTRODUCTION" section can
ultimately result in "RESULTS AND DISCUSSION" section, so there is compatibility. Moreover, it can also
be added the prospect of the development of research results and application prospects of further studies into
the next (based on result and discussion).

ACKNOWLEDGEMENTS
This research is funded by ‘Penelitian Terapan Nasional’ from the Directorate General of Higher
Education, Research and Technology, Ministry of Education, Culture, Research, and Technology, Republic
of Indonesia in 2022.

REFERENCES
[1] G. Zhou, Y. Pan, J. Yang, X. Zhang, X. Guo, and Y. Luo, “Sleep Electroencephalographic Response to Respiratory Events in
Patients With Moderate Sleep Apnea–Hypopnea Syndrome,” Frontiers in Neuroscience, vol. 14, no. April, pp. 1–12, 2020,
doi: 10.3389/fnins.2020.00310.
[2] L. C. Markun and A. Sampat, “Clinician-Focused Overview and Developments in Polysomnography,” Current Sleep Medicine
Reports, vol. 6, no. 4, pp. 309–321, 2020, doi: 10.1007/s40675-020-00197-5.
[3] E. Fadliansyah, E. C. Djamal, D. Djajasasmita, and F. Kasyidi, “Sleep Apnea Identification Through Vertical Respiratory
Movement Using Region of Interest and Recurrent Neural Networks,” in 23rd International Seminar on Intelligent
Technology and Its Applications (ISITIA) 2022, 2022, pp. 30–35.
[4] E. C. Djamal, H. Syaukani, and F. Kasyidi, “Sleep Apnea Detection Based on Respiratory Movement Using Harris Corner and
Recurrent Neural Networks,” in Proceedings - 2023 10th International Conference on Computer, Control, Informatics and its
Applications, 2023, pp. 440–445, doi: 10.1109/IC3INA60834.2023.10285748.
[5] K. Zhu, A. Yadollahi, and B. Taati, “Non - contact Apnea - Hypopnea Index Estimation using Near Infrared Video *,” in 2019
41st Annual International Conference of the IEEE Engineering in Medicine & Biology Society (EMBC), 2019, pp. 792–795.
[6] H. Ammar and S. Lashkar, “Obstructive sleep apnea diagnosis based on a statistical analysis of the optical flow in video
recordings,” 2016 International Symposium on Signal, Image, Video and Communications, ISIVC 2016, pp. 18–23, 2017, doi:
10.1109/ISIVC.2016.7893955.
[7] L. Almazaydeh, K. Elleithy, and M. Faezipour, “Obstructive sleep apnea detection using SVM-based classification of ECG
signal features,” Proceedings of the Annual International Conference of the IEEE Engineering in Medicine and Biology
Society, EMBS, pp. 4938–4941, 2012, doi: 10.1109/EMBC.2012.6347100.
[8] A. S. J, “Review on Obstructive Sleep Apnea Detection using ECG Signals,” in 2022 4th International Conference on Smart
Systems and Inventive Technology (ICSSIT), 2022, pp. 680–684, doi: 10.1109/ICSSIT53264.2022.9716342.
Sleep Apnea Recognition of Electroencephalogram Signal Using Convolutional Neural Networks
10  ISSN: 2252-8938

[9] D. Padovano, A. Martinez-Rodrigo, J. M. Pastor, J. J. Rieta, and R. Alcaraz, “On the Generalization of Sleep Apnea Detection
Methods Based on Heart Rate Variability and Machine Learning,” IEEE Access, vol. 10, no. July, pp. 92710–92725, 2022,
doi: 10.1109/ACCESS.2022.3201911.
[10] L. Sun, X. Zhang, S. Huang, J. Liang, and Y. Luo, “Respiratory Physiology & Neurobiology K-complex morphological
features in male obstructive sleep apnea- hypopnea syndrome patients,” Respiratory Physiology & Neurobiology, vol. 248, no.
November 2017, pp. 10–16, 2018, doi: 10.1016/j.resp.2017.11.004.
[11] E. P. Giri, M. I. Fanany, A. M. Aryrnurthy, and S. K. Wijaya, “Ischemic Stroke Identification Based on EEG and EOG using
1D Convolutional Neural Network and Batch Normalization,” in 2016 International Conference on Advanced Computer
Science and Information Systems (ICACSIS), 2016, pp. 484–491.
[12] E. C. Djamal, W. I. Furi, and F. Nugraha, “Detection of EEG Signal Post-Stroke Using FFT and Convolutional Neural
Networkle,” in 2019 6th International Conference on Electrical Engineering, Computer Science and Informatics (EECSI),
2019, pp. 18–23.
[13] Q. Zhang, D. Zhou, and S. Member, “HeartID : A Multiresolution Convolutional Neural Network for ECG-Based Biometric
Human Identification in Smart Health Applications,” IEEE Access, vol. 5, pp. 11805–11816, 2017.
[14] Y. Ichimaru and G. B. Moody, “Development of the polysomnographic database on,” Psychiatry and Clinical Neurosciences,
no. 53, pp. 175–177, 1999.
[15] M. Zhou et al., “Epileptic Seizure Detection Based on EEG Signals and CNN,” Front. Neuroinform, vol. 12, no. December,
pp. 1–14, 2018, doi: 10.3389/fninf.2018.00095.
[16] E. C. Djamal, R. I. Ramadhan, M. I. Mandasari, and D. Djajasasmita, “Identification of post-stroke EEG signal using wavelet
and convolutional neural networks,” vol. 9, no. 5, pp. 1890–1898, 2020, doi: 10.11591/eei.v9i5.2005.
[17] I. A. Begawan, E. C. Djamal, D. Djajasasmita, F. Nugraha, and F. Kasyidi, “Sleep Stage Identification Based on EEG Signals
Using Parallel Convolutional Neural Network and Recurrent Neural Network,” in 2022 International Conference on Advanced
Computer Science and Information Systems (ICACSIS), 2022, pp. 39–44.
[18] L. D. Barnes, K. Lee, A. W. Kempa-Liehr, and L. E. Hallum, “Detection of sleep apnea from single-channel
electroencephalogram (EEG) using an explainable convolutional neural network (CNN),” PLoS ONE, vol. 17, no. 9
September, pp. 1–18, 2022, doi: 10.1371/journal.pone.0272167.
[19] B. TaghiBeyglou, A. Shahbazi, F. Bagheri, S. Akbarian, and M. Jahed, “Detection of ADHD cases using CNN and classical
classifiers of raw EEG,” Computer Methods and Programs in Biomedicine Update, vol. 2, no. August 2021, p. 100080, 2022,
doi: 10.1016/j.cmpbup.2022.100080.
[20] A. Saidi, S. Ben Othman, and S. Ben Saoud, “A novel epileptic seizure detection system using scalp EEG signals based on
hybrid CNN-SVM classifier,” 2021 IEEE Symposium on Industrial Electronics and Applications, ISIEA 2021, pp. 1–6, 2021,
doi: 10.1109/ISIEA51897.2021.9510002.
[21] D. Kim, J. Kim, and J. Kim, “Elastic exponential linear units for convolutional neural networks,” Neurocomputing, vol. 406,
pp. 253–266, 2020, doi: 10.1016/j.neucom.2020.03.051.
[22] D. A. Clevert, T. Unterthiner, and S. Hochreiter, “Fast and accurate deep network learning by exponential linear units
(ELUs),” 4th International Conference on Learning Representations, ICLR 2016 - Conference Track Proceedings, pp. 1–14,
2016.
[23] E. C. Djamal, Suprijanto, and S. J. Setiadi, “Classification of EEG-Based Hand Grasping Imagination Using Autoregressive
and Neural Networks,” Jurnal Teknologi, vol. 78, no. 6–6, pp. 105–110, 2016, doi: 10.11113/jt.v78.9035.

Int J Artif Intell, Vol. 99, No. 1, Month 2099: 1-1x


Int J Artif Intell ISSN: 2252-8938  11

Sleep Apnea Recognition of Electroencephalogram Signal Using Convolutional Neural Networks

You might also like