SLEEP APNEA DETECTION USING DEEP LEARNING

: Sleep apnea is the cessation of airflow at least 10 seconds and it is the type of breathing disorder in which breathing stops at the time of sleeping. The proposed model uses type 4 sleep study which focuses more on portability and the reduction of the signals. The main limitations of type 1 full night polysomnography are time consuming and it requires much space for sleep recording such as sleep lab comparing to type 4 sleep studies. The detection of sleep apnea using deep convolutional neural network model based on SPO2 sensor is the valid alternative for efficient polysomnography and it is portable and cost effective. The total number of samples from SPO2 sensors of 50 patients that is used in this study is 190,000. The performance of the overall accuracy of sleep apnea detection is 91.3085% with the loss rate of 2.3 using cross entropy cost function using deep convolutional neural network.


INTRODUCTION
The type of studies used in our system is type 4 sleep studies, which also refers to continuous single bio-parameter or dual-bio parameter recording. The minimum number of signals that can be used in this type 4 studies is one or two channels such as oxygen saturation and airflow [3][4][5][6][12][13][14][15][16][17][18][19][20][21][22][23][24][25][26][27][28][29][30]. Normally type 4 studies do not have EEG and EMG signals, so scoring sleep is not possible. It can be used to identify respiratory sleep disorder during sleep time. The use of oxygen saturation and tracheal sound via acoustic sensor is another alternative to type 4 sleep studies. The primary purpose of using the deep convolutional neural network model for the detection of sleep apnea is to learn parameters or features for the model from the training dataset [7]. The performance of the model is related to the learned parameters in order to determine whether the sample of the signal contains sleep apnea event or not [7][8][9]. The relationship between the interpretability of the different parameters and the performance of the deep convolutional model is a challenging task for the detection of sleep apnea. A variety of different convolutional neural networks can be used for image classification task; however, only a smaller percentage of them is used for the detection relating to sound waves or the signal processing. The designing and testing of good convolutional neural network model is similar to the black box and needs to be done in a substantial amount of trials and errors because of the inner mechanism of the CNN model [9]. The representation of the signals from the sensor gains a lot of attention in the deep learning model. The proposed model is inspired from the image classification in which the amplitude from the sensors wave data can be seen as the digit vector figures, which can change to any dimensional shape for matrix vectorization or factorization. The main challenge of the sleep apnea detection is that the signal representation is not clear due to continuous nature of the high frequency breathing signal waves. The objective of proposing the biological signal to deep learning model is to fill the gap between the nature of deep learning and continuous nature of the biological signal from the sensors. The use of convolutional neural network model is a plausible and proper solution to interpret and learn the time series nature of the high frequency SPO2 signal [30][31][32]. After carrying out five empirical experiments for the validation and testing of sleep apnea detection, the result shows that it can provide meaningful interpretation for the clinical professional. The major contribution of the paper can be summarized as follows: • A deep learning approach using convolutional neural network is proposed for the detection of sleep apnea in order to explore the segment of the time series data whether apnea occurs or not. • The accuracy and loss rate SPO2 signal are compared with other approaches of sleep apnea detection using SPO2 signal.
The rest of this paper is organized as follows. The deep learning steps which include data collection, data preparation and segmentation, selection of deep learning model, training, testing, hyper-parameter tuning and prediction, are illustrated in section 2. The system design of the deep learning model can also be seen in Section 2. The performance evaluation results of our system are discussed in Section 3 with five empirical studies using subject validation of 50 patients. The studies contain 190,000 samples of the patients who have sleep apnea. However, the seriousness level of sleep apnea for each patient is different depending on the AHI index and the condition of the patients. Finally, Section 4 concludes and highlights the potential of future research direction for sleep apnea detection.

DEEP LEARNING STEPS
The biological neural network of human brain decision making inspires the proposed deep learning model using convolutional neural network [7,9,31,32]. It is based on the single stimulus in which a number of neurons carries messages through electrochemical process, which is required for decision making. In the real world, the identification and prediction of sleep apnea by deep learning method would TECHNICAL JOURNAL 13, 4(2019), 261-266 facilitate patients with sleep apnea disease [1]. The deep learning model allows to learn from the feature to represent the nature of the data and its patterns. There are two types of trends in deep learning known as supervised learning, in which training data includes both input and desired output, and unsupervised learning, in which training data contains input but not the desired output [31]. Fig. 1 represents the deep learning process in general such as data collection, data preparation and segmentation, deep learning model design such as deep convolutional neural network, training, testing, hyper-parameter tuning and prediction.

System Design
The design of the detection of sleep apnea can be seen in three layers in which the first layer, second layer and third layer are data collection layer, analysis layer and diagnosis layer respectively and can be seen in Fig. 2.

Figure 2 System Design of Sleep Apnea Detection
The first layer is for collecting the data on the oxygen saturation from the patient in order to detect sleep apnea. The second layer is for analysis of the detection of sleep apnea. In the third diagnosis layer, the number of events of sleep apnea occurrence can be identified together with how serious the sleep breathing disorder is for the patients. The third layer is called the diagnosis layer in which health care professional identifies whether the identification of sleep apnea is correct or not.
For one-dimensional feature vector as shown in Fig. 3, the segmented signal will be labelled before being put in the system. For example, if X is assumed as one segmented SPO2 signal, Xa = {x 1 , x 2 , x 3 ,…, x n } in which n = sampling rate * one epoch (30 sec) and x n ∈ X a and X a ∈ X, where x is a random variable representing the signal data per second. Before putting it into the deep learning model, each segmented signal is stored in the feature vector as follow. According to Fig. 4, the figure illustrates how the sleep apnea event occur. There are three consecutive time events known as t 1 , t 2 , and t 3 . When breathing stops, the brain sends some signals to the muscle in order to do breathing. This kind of arousal event can be seen in the EEG electrodes' signal that are attached to the patients' head. This event can be seen and is marked in t 2 time segment. The arousal event from the EEG electrode, respiratory signals flat event can be seen in the following Fig. 5 and Fig. 6. As for the event relating to the time t 1 from Fig. 4, it is significant that the signals coming from the nasal pressure, thermistor, thoracic and abdomen decreased and the signals become flat compared to the normal trend line. This kind of event can be seen in Fig. 5. In other words, these four signals drop significantly compared to the normal breathing condition. The first four signals highlighted in blue are thermistor, nasal pressure, thoracic and abdominal signal.
After occurrence of the signal drop in these four signals, the oxygen desaturation occurs in SPO2 signal highlighted in red. The abrupt shift of the brain signal from the electrodes with the frequency of less than 16% which does not include spindle and it can last for at least 3 sec. When the sleep apnea occurs, this event is highlighted using green and a red box in Fig. 6. As a result of the lung stop breathing, the occurrences of oxygen desaturation can be seen in the t 3 time event of SPO2 signals relating to Fig. 6. The C3-M2 means the central electrode on the left side of the brain is referenced to the right pre-auricular electrode near the right ear. The C4-M1 means the central electrode on the right side of the brain is referenced to the left pre-auricular electrode near the left ear. The F3-M2 means the frontal electrode on the left front side of the brain is referenced to the right pre-auricular electrode near the right ear. The F4-M1 means the frontal electrode on the right side of the brain is referenced to the left preauricular electrode near the left ear. The O1-M2 means the occipital electrode on the left front side of the brain is referenced to the right pre-auricular electrode near the right ear. The O2-M1 means the occipital electrode on the right side of the brain is referenced to the left pre-auricular electrode near the left ear. One of the findings is that the heart rate began to increase after the oxygen desaturation event happened in time t3.

Apnea/Hypopnea Event Detection
The flat signals do not mean that the signal is very flat because the up and down can be seen according to minute, second and hour view. The baseline amplitude for the apnea is the preceding 3 to 6 breaths in which time segment before and after the event is represented as t1 and t 3 respectively, and the amplitude before and after the apnea event is represented as A 1 and A 2 respectively in which t 1 < t 2 < t 3 . If the maximum relative amplitude for the apnea threshold is set to 10 percent, it means that A 2 divided by A 1 should be less than 10 percent and the apnea event is detected if the amplitude of the event is twenty percent or below of preceding data according to Fig, 7. For the hypopnea event the maximum threshold is less than 70 percent according to AASM manual scoring 2017. The following Fig. 8, illustrates that the minimum duration of the event that can be identified as apnea or hypopnea is ten seconds. It is highlighted in red bounding box in which T is equal to ten seconds.

Deep Convolutional Neural Network
The simplified version of the convolutional neural network is portrayed in Fig. 9 in which the first layer is the input layer, the last layer is the output layer which can b e identified whether certain segment from the sensor has apnea or not, and the layers between the first and last layer are the hidden layers. The following Tab. 1 represents the summary of the design of the deep convolutional neural network in which ten layers are used. Moreover, it includes three two-dimensional convolutional layers and three max pooling layers. After running the deep convolutional neural network model for each empirical study, there will be 32,614 trainable parameters for the convolutional neural network and 794 samples are used for training and 3,178 samples are used for testing. Each sample has 484 data points of SPO2 signal with the frequency of 16 Hz. The proposed model includes pooling and two-dimensional convolutional layers, the flatten layer, dense layer and dropout layer. There are 320 parameters for the first convolutional layer, 9,248 parameters for the second convolutional layer and 18,496 parameters for the third convolutional layer. In addition, there are 4,160 parameters for the first dense layer and 390 parameters for the third dense layer. The nature of the convolutional layer is to extract features, and to learn the special characteristic of the input signal. The pooling layer that takes the maximum value reduces the dimensionality of the model without losing the features or pattern. In addition, the fully connected layer is also known as the dense layer, which can be used as a final layer for prediction.

PERFORMANCE EVALUATION
It can be seen that five empirical studies are made using the accuracy metrics of the proposed deep convolutional neural network model using fifty patients and each empirical study includes 3,700 to 4,000 sample data of ten patients. Each empirical study is illustrated in two figures: one for accuracy and the other for loss. The cross entropy is used for calculating the loss rate. The overall performance of the proposed model is 91.3085 percent. The comparison between proposed convolutional neural network model and the other models can also be found in this performance evaluation section. It contains the comparison different classifier such as linear discriminant analysis (LDA), support vector machine (SVM), bagging representation tree, artificial neural network using SPO2 signal and the proposed convolutional neural network of deep learning model.
The summary of the comparison of five empirical studies regarding training accuracy can be seen in Fig. 10 in which scenario 1, scenario 2, scenario 3, scenario 4 and scenario 5 are illustrated using orange, red, green, purple and blue trend line respectively. Each scenario includes ten patients with difference age, BMI, weight, AHI index. All of the trend lines fluctuated and gradually increased between 1 percent and 20 iterations. The percentage of accuracy starts to stabilize after twenty iterations; they become more stable after 40 iterations with the accuracy around 90 percent. It can be concluded that the stable condition for training the data is between 40 iterations to 100 iterations. The summary of the comparison of five empirical studies regarding training prediction loss can be seen in Fig. 11 in which scenario 1, scenario 2, scenario 3, scenario 4 and scenario 5 are illustrated using blue, orange, green, purple and cyan trend line respectively. In this paper, the total number of patients that participated in the detection of sleep apnea is fifty patients and subject specific scenario validation is used with the split rate of 0.2. Each of the scenarios had ten different patients of different age, BMI, weight, AHI index. All of the trend lines relating to training loss were going down until the number of twenty iterations and at the same time, they fluctuated and were unstable until twenty iterations. They became more stable after 20 iterations. The stable condition for training prediction loss was between 20 iterations to 100 iterations.  According to Tab. 2, the SPO2 signals are used for the comparison between the proposed model and other classifiers. The proposed model outperformed the other models with the accuracy of 91.3085 percent with the split rate of 0.2 in which the training data is 20 percent (794 samples) and testing data is 80 percent (3178 data samples).
The following Tab. 2 illustrates the comparison between different types of classifier such as LDA, SVM, Bagging representation tree, artificial neural network for sleep apnea detection. It can be seen that deep convolutional neural network has the accuracy of 91.3085 percent. In other word, the model can predict very well for 913085 data out of 100,0000 data. The other model use only a few percentage data for testing and a huge percentage of data for training. However, the twenty percent of data are used for the training and 80 percent of data are used for testing in order to avoid overfitting in the proposed model for detection of sleep apnea. Actually, the twenty percent used for training is not small enough for the proposed model because of 8 hours of sleep recording for each patient. Fifty patients involve in this five empirical studies. The other model uses the standard database with a few amount of data, however proposed model use own database after collecting data of fifty patients who have sleep apnea with the help of health care professionals from the sleep lab.

CONCLUSION
As a summary, the preparation and segmentation the data model is a crucial step before feeding into the deep learning. The experiment of deep learning using deep CNN (convolutional neural network) model is tested using SPO2 using subject validation with the split rate of 0.2 in order to avoiding overfitting problem. The overall accuracy for the entire sample using subject validation is 91.3085 in which the trend line for testing is better than the trend line for training

Acknowledgement
This work was supported by Thailand's Education Hub for Southern Region of ASEAN Countries (TEH-AC), Prince of Songkla University Graduate Studies Grant as well as by Department of Computer Engineering, Prince of Songkla University. The authors would like to express the gratitude for our supervisor, co-supervisor and sleep technicians from Songklanagarind Hospital, Thailand for guiding in my research work and supporting access to the respiratory signals acquired in Sleep Disorders Service and Research Center.

Remark
The article was orally presented at the 23 rd International Computer Science and Engineering Conference (ICSEC2019).