using

— One of sleep-disordered breathing (SDB) form is sleep apnea, commonly known as snoring during sleep, based on various complex mechanisms and predisposing factors. Sleep apnea is also related to various medical problems. It impacts morbidity and mortality so that it becomes a burden on public health services. Its detection needs to be done correctly through electro-cardiogram signals to detect sleep apnea more quickly and precisely. This study was conducted to detect sleep apnea based on electrocardiogram signals using multi-scale entropy analysis. Multi-scale entropy (MSE) is used in a finite length of time series for measuring the complexity of the signal. MSE can be applied to both physical and physiological data sets and. In this paper we used MSE to detect Sleep Apnea on electrocardiogram (ECG) signals. MSE was applied two classes of ECG data, normal ECG signals, and apnea ECG signals. In this paper, classification and verification were carried out using the Support Vector Machine (SVM) and N-fold cross-validation (N-fold CV). From the experimental results, the highest accuracy was 85.6% using 5-fold CV and MSE scale of 10. The result shows that the system model that can detect sleep using the multi-scale entropy method.


Introduction
Obstructive Sleep Apnea (OSA) is a disease or disorder that occurs during sleep [1]. Sleep apnea's definition is the cessation of air entry during inspiration for 10 seconds or more [1]. In OSA, apnea occurs during sleep. At the time of apnea, obstruction occurs because the body's muscles relax so that the airways collapse [2]. Closure of this airway will cause the patient to wake up during sleep or experience a sudden transition to sleep. OSA is one of the triggering factors for several diseases such as hypertension, myocardial ischemia, heart failure, and several other cardiovascular diseases [2].
The diagnosis of OSA is carried out by several methods depending on the signal to be observed. Overnight Polysomnography (PSG) became the OSA observation standard. The weakness of this PSG are expensive, takes a long time, and is not practical, so it is only done on patients with a certain level of severity [3]. OSA can be observed through patient movement using video processing [4]. The sound of snoring can also be analyzed using speech processing methods to detect the presence of OSA [5].
Respiration signals are often also used to analyze sleep apnea using speech signal analysis [6]. Algorithms that are often used to detect the presence or absence of the respiratory process during sleep include the Voice Activity Detection (VAD) algorithm [5].
Information on indications of sleep apnea can also be identified through electrocardiogram (ECG) signal analysis. This can be done because the respiratory process influences the ECG signal through changes in lung volume that affect thoracic impedance [7]. The relationship between ECG-derived respiration (EDR) and ECG signal has been studied in various studies [8]. The respiratory process can the heart vector, which caused by a shift or change in the orientation of the heart associated with the ECG electrode [9]. The autonomic nervous system associated with the respiratory system also influences the ECG signal [10]. Respiration can be measured using an ECG signal because of this mechanism.
Several studies have tried to detect OSA using ECG. Characteristics that are often used are heart-rate variability parameters such as mean, mean absolute deviation values, median, SD, pNN50, SDSD, RMSSD, NN50 variant 1, NN50 variant 2, inter-quartile, the variance of RR1, the slope of the first polynomial model of RR1, RR1max-RR2min [11,12]. Other features used for OSA analysis using ECG signals include entropy (Shannon entropy, sample entropy, fuzzy entropy, correct conditional entropy), ECG signal plots (Poincare plot feature, recurrence plot), statistical features (mean absolute deviation, standard deviation, variance, root mean square, harmonic mean, kurtosis, energy, skewness) [13,14]. OSA research using the new entropy was carried out on the ECG signal directly. Multiscale entropy (MSE) analysis has not been reported in previous studies.
In this study, we proposed MSE method to classify sleep apnea with ECG signals. The multiscale process uses a coarse-grained procedure, while entropy measurement uses sample entropy [15]. The coarse-grained procedure is used to decompose the ECG signal into a number of scales, while the sample entropy is used to characterize the complexity of the ECG signal. With the combination of these methods, it is hoped that the signal dynamics in multiscale conditions can be used to distinguish ECG signals in OSA conditions and without OSA conditions.

2
Materials and method The proposed method is presented in Figure 1. The long-term ECG signal recording is cut into a minute recordings or 6000 samples. Next, a coarse-grained procedure is used to decompose the signal into a series of signals at several different scales. Next, the sample entropy (SampEn) is calculated for each of the new signals. The classification was carried out using SVM with N-fold cross-validation (N-fold CV) to avoid overfitting in classification stage. The details of the above method are explained in the following subsection.

ECG Sleep apnea dataset
In this study, we used the ECG Sleep apnea dataset available on PhysioNet [16,17]. The data consists of 70 records, divided into a training set of 35 records and a testing set of 35 records. The recordings vary in length from 7-10 hours. Each recording consists of a digital ECG signal and an expertly rendered apnea annotation based on the associated signal shape and QRS annotation generated by the ECG machine. Some recordings are supplemented by other signals such as respiration and oxygen saturation. In this study, we used only the ECG. The ECG signal is cut to every minute and entered according to the given annotation. Because the sampling frequency is 100 Hz, the signal is cut every 6000 samples. Examples of normal ECG and OSA signals are shown in Figure 2. In the ECG image with OS, it can be seen that there is one ECG signal that has drastically changed the QRS orientation so that it can be distinguished from normal conditions. In this study, only 21 datasets were used.

Multiscale entropy
Physiological signals such as ECG signals have multiple time scales characteristic. Costa, et al presented a multiscale entropy (MSE) method for time series complexity measurement [18]. This method is divided into two processes, namely a multiscale process called the coarse-grained procedure and the entropy calculation process using sample entropy. The details of MSE process is presented as follows: In general, the concept of the coarse-grained procedure is a down sampling and smoothing process [19]. Equation coarse-grained procedure as in Equation (1) [20]: where is a 1-dimensional time series, is a consecutive coarse-grained time series, is the scale factor, and N is the original time series length. The scale used in this study is 1 to 20. Scale factor of 1, it means the original signal. Graphically the coarse-grained procedure is as shown in Figure 3. The coarse-grained procedure can be described as a signal decomposition process at different scales or levels. Sample Entropy (SampEN) measures the probability that a series of m data will match another series and will remain the same when a series of m data is increased to m+1 with a tolerance of r [18]. SampEN is able to avoid self-matches, one of the weakness of approximate entropy (ApEN) [21]. SampEN is formulated by Equation (2).
where A m (r) and B m (r) are the probability that two series data will match for a number of m+1 and m respectively. Both are calculated within a tolerance of r.
In Equation (2), by estimating B and A as in Equation (3) and (4).
so that we can rewrite Equation (a) as in Equation (5). We used with series m = 2 and tolerance r = 0.15 in this paper.

Support vector machine
Support Vector Machine's (SVM) specialty is the capability to generalize by only using a few parameters [22,23]. The SVM capability can optimize and make the data more dependent. The performance of SVM is proved better and able to compete with other machine learning methods such as random forests and artificial neural networks. The algorithm developed by Vapnik is focusing on how to maximizing the minimum separating hyperplane. In other words, this algorithm detects the shortest distance between the data's decision functions [24].
In this study, linear and non-linear SVM kernels are configured with N-fold cross-validation (N-fold CV) by N = 5 and N = 10 to determine the training and testing dataset. Firstly, the dataset is split into N datasets; then, one dataset is used as testing data and the N-1 datasets are used as training data. This process is repeated until all datasets are used once as testing data. Finally, the process performance is calculated by accuracy.

3
Results and discussion Figure 4 shows the effect of the coarse-grained procedure for = 1-5 in a normal ECG signal. Visually there is no significant difference except for the number of data samples, which decreases according to the scale used. If the initial signal is 6000 samples, then for = 1-5 successively, the number of samples will be 3000, 2000, 1500, and 1200. This value will be continued until 300 samples at = 20 to calculate sample entropy as a feature. Figure 5 displays the MSE of the ECG signal in Figure 2. It can be seen that, in general, the normal ECG signal has a higher value than the ECG signal in OSA, except when the scale is >15. The signal complexity of the biological signal characterize the dynamics of the signal and implies the ability to adapt to the environment or stimuli. In pathological conditions, signal complexity decreases due to decreased ability to change or adapt [15]. In other biological signals, the entropy value usually decreases as the scale increases, but in this case, the OSA ECG signal tends to increase. This is influenced by the repetitive nature of the ECG signal with sudden changes due to OSA.   Table 1 and Table 2 show classification accuracy using five-fold CV and 10-fold CV. The highest accuracy of 85.6% was achieved using a fine Gaussian SVM and a scale of 1-10 at five-fold CV. Meanwhile, for 10-fold CV, the highest accuracy of 85.4% was achieved under the same conditions. Accuracy tends to increase when the scale is increased except for fine Gaussian SVM. The features in Figure 5 show that on a scale of 15-20, the difference between normal EC and ECG in OSA begins to decrease. This result infers that the calculation of sample entropy in the two data classes is relatively not different. The coarse-grained procedure at a higher scale eliminates details from the signal due to a down sampling process from the average signal. Table 3 shows the same study using the same dataset. The characteristics used in previous studies are relatively many and varied. Some features measure signal statistics [14] and features that capture the heart rate variability of ECG signals [12,25]. It is different from the proposed method, where only one feature is measured (sample entropy) but is carried out at various signal scales. The proposed method is similar to the study by Zarei and Asl [13]. The characteristics used are various kinds of entropy which are measured in the subband wavelet. The resulting accuracy is higher than the proposed method, but the number of features used is more.
Some of the weaknesses in this study are as follows. Cutting data every 1 minute is considered too long because OSA can sometimes only be detected on one beat of the ECG signal. In some cases, this is not significant enough compared to other normal 60-80 beat ECGs. Cutting the duration of the ECG signal to a shorter length is likely to improve accuracy, although it will increase the difficulty in classification and data collection [28].
Using a scale on the coarse-grained procedure to 20 causes the number of sample data on a scale of 6-20 to be 1000-300. Sample entropy has inconsistencies when used in short data series. Usually, researchers use a limit of 1000 samples to ensure accurate sample entropy calculations [29]. In this case, the accuracy of the sample entropy calculation is not a problem as long as it produces high accuracy. Table 1 and Table 2 show that the highest accuracy is achieved when using a scale of 1-10 or 1-15. The signals used are mixed between one subject and another. For one recording data, the ECG signal is taken from one subject for 7-10 hours. For classification, this data is combined with data from other subjects, not classified for each subject. In different subjects, the ECG signal pattern may be different, thus opening the possibility of misclassification. Detection of ECG OSA on one subject is considered to increase the accuracy of the proposed system. In general, the proposed method is quite simple, with a relatively small number of features. The only feature taken is the entropy sample measured at various scales; thus, the computations are relatively simple. Sample entropy is affected by the number of rows of m and tolerance r. The selection of these two parameters will affect the accuracy but will increase the computation time. The measurement of multiscale entropy on the ECG signal can still be developed, for example, by using other entropy such as in the study of lung sound or other non-biological signal [30,31]. The use of various kinds of entropy is interesting to do in further research.

Conclusion
This paper discusses the use of multiscale entropy (MSE) to classify ECG signals in obstructive sleep apnea (OSA) using SVM. MSE is used to measure signal complexity at different scales. It is hoped that this information will be able to distinguish normal ECG signals and ECG signals with OSA. The highest accuracy of 85.6% was achieved using a 1-10 scale and fine Gaussian kernel SVM. This accuracy is relatively lower than similar studies on the same data set. However, the proposed method still has potential for further development, such as selecting the suitable sample entropy parameter (number of data sample series and tolerances) and selecting the signal scale used. Another use of entropy is also interesting to find out which entropy measurement produces the highest accuracy. The use of more advanced machine learning methods can be considered to improve accuracy.