Sleep Quality Detection Based on EEG Signals Using Transfer Support Vector Machine Algorithm

Background In recent years, with the acceleration of life rhythm and increased pressure, the problem of sleep disorders has become more and more serious. It affects people’s quality of life and reduces work efficiency, so the monitoring and evaluation of sleep quality is of great significance. Sleep staging has an important reference value in sleep quality assessment. This article starts with the study of sleep staging to detect and analyze sleep quality. For the purpose of sleep quality detection, this article proposes a sleep quality detection method based on electroencephalography (EEG) signals. Materials and Methods This method first preprocesses the EEG signals and then uses the discrete wavelet transform (DWT) for feature extraction. Finally, the transfer support vector machine (TSVM) algorithm is used to classify the feature data. Results The proposed algorithm was tested using 60 pieces of data from the National Sleep Research Resource Library of the United States, and sleep quality was evaluated using three indicators: sensitivity, specificity, and accuracy. Experimental results show that the classification performance of the TSVM classifier is significantly higher than those of other comparison algorithms. This further validated the effectiveness of the proposed sleep quality detection method.


INTRODUCTION
As an important physiological phenomenon and a necessary physiological process, sleep is considered to be a resting state with a greatly reduced response capacity (Siegel, 2005). The body eliminates fatigue through sleep, restores mental and physical strength, and maintains a good state. At present, the pace of social life is fast, and sleep disorders have become an increasingly common problem. The problem of sleep disturbance will have a negative impact on the body's alertness and attention, causing patients to have adverse consequences due to reduced alertness. Many physiological functions change during sleep, such as decreased skeletal muscle tension, slower breathing, and decreased visual, auditory, tactile, and other sensory sensitivities. These changes also vary in different sleep stages. Changes in physiological functions during sleep lead to corresponding changes in electrophysiological signals, and sleep research has also been carried out.
Sleep quality assessment is an important branch of sleep research and an integral part of sleep neurobiology research. Because sleep neurobiology is closely related to cognitive neuroscience, sleep quality assessment also helps in studying various neurocognitive functions such as learning and memory. This shows that sleep quality assessment plays an important role in sleep research. Surveys indicate that most people suffer from poor sleep quality due to physical or psychological problems. And poor sleep quality will produce further positive feedback on the original physical and psychological problems, which will continue to deteriorate. At present, the burden on doctors for the diagnosis and detection of such diseases is relatively heavy. Especially for the acquisition and processing of patients' night sleep data, the help of automation and digital technology is very much needed. Therefore, the research in this paper will have irreplaceable clinical value and practical significance. At present, the research direction of sleep quality mainly focuses on the study of sleep staging. With the continuous development of computer technology, many machine learning methods had been proposed and used in the medical applications (Bezdek, 1980(Bezdek, , 1981Hall et al., 1992;Ahmed et al., 2002;Pedrycz, 2002;Chen and Zhang, 2004;Chuang et al., 2006;Weijer and Gevers, 2006;Jing et al., 2007;Cleuziou et al., 2009;Gu and Zhou, 2009;Zhu et al., 2009;Krinidis and Chatzis, 2010;Hall and Goldgof, 2011;Ji et al., 2011;Jiang et al., 2012Jiang et al., , 2014Jiang et al., , 2020Yu et al., 2012;Chen et al., 2013;Gong et al., 2013;Thanh and Wu, 2013;Li et al., 2014;Elazab et al., 2015;Okita et al., 2015;Qian et al., 2015;Wang et al., 2015Wang et al., , 2019Zheng et al., 2015;Devi and Setty, 2018;Lee et al., 2018;Rosati et al., 2018;Cai et al., 2019;Gu et al., 2019;Chrobak et al., 2020;Kumar et al., 2020;Liu et al., 2020;Singh et al., 2020;Sunjana and Azizah, 2020;Yin et al., 2020;Zhang et al., 2020). The sleep staging method has evolved from the traditional visual observation method to the automatic staging method based on extracting physiological signal features. The accuracy and efficiency of sleep staging are greatly improved. The process of automatic sleep staging algorithm mainly includes signal preprocessing, feature extraction, sleep stage classification, and result output. The commonly used models for sleep stage classification are machine learning algorithms such as support vector machine (SVM) (Doroshenkov et al., 2007;Hsu and Yang, 2013;Qian et al., 2016aQian et al., ,b, 2017Qian et al., , 2018aQian et al., ,b, 2020Jiang et al., 2017aJiang et al., ,b, 2019Xia et al., 2019). The methods commonly used to extract the characteristic parameters of sleep staging from electroencephalography (EEG) data mainly include wavelet transform and other methods (Alessandro et al., 2001;Kannathal et al., 2005;Srinivasan et al., 2005;Mohseni et al., 2006;Subasi, 2007;Bruzzo et al., 2008;Albayrak and Koklukaya, 2009;Yuen et al., 2009;Fathima et al., 2010;Geng et al., 2011;Gandhi et al., 2012;Sen and Peker, 2013). Table 1 shows the progress of sleep staging research in recent years.
In this study, EEG signals were selected. After preprocessing and feature extraction, the signals were classified using the transfer support vector machine (TSVM) classifier. The performance of the algorithm is evaluated from the three indicators of sensitivity, specificity, and accuracy. The work of this paper is summarized as follows: (1) The transfer mechanism is introduced into the classic SVM algorithm to obtain the transfer learning SVM (TL-SVM) classification model. Since the model can use the source domain dataset to guide the classification of the target domain dataset, the accuracy of the classification is improved to a certain extent.
(2) A sleep EEG recognition method based on TL-SVM is proposed. Experiments show that this method is feasible and effective for sleep quality detection.

Introduction to Sleep Staging
This article selects EEG signals for the study of sleep quality; therefore, here, we focus on analyzing the role of EEG in sleep staging. We mainly describe sleep staging and the relationship between EEG and sleep. According to the American Academy of Sleep Medicine (AASM) staging criteria, a normal sleep cycle can be divided into two stages, namely, the non-rapid eye movement (NREM) period and the rapid eye movement (REM) period. According to the depth of sleep, NREM is further divided into stages I-III. The above-mentioned stages recur periodically during sleep of normal people all night. When going to sleep, a normal person's sleep stage first enters the NREM stage, gradually transitioning from stage I to III, and then enters the REM stage at stage II or III of NREM. The sleep stage enters the REM stage from the NREM stage, representing a complete sleep cycle. Normal adults have about four to six sleep cycles all night. Under normal circumstances, the sleep time of stage I in normal adults accounts for about 5% of a whole night's sleep, stage III in NRE accounts for about 50%, stage II in NRE accounts for 20%, and the REM stage accounts for 25%. Figure 1 is a normal adult sleep structure diagram.
The red area in Figure 1 represents the NREMIII stage, which is the stage of deep sleep. The yellow area is the REM period where "dreams" often appear. As the black line drops, it means deeper sleep. The higher the position of the black line, the lighter the sleep. During the sleep cycle, EEG will change correspondingly with the change of sleep stage.

Sleep EEG Signal
During sleep, the brain often has rhythm, amplitude, frequency, and other EEG rhythms. The thalamus is the generating part of the EEG rhythm. Its main function is to receive excitement from the brain stem to form a thalamus cortical circuit, thereby regulating the level of neuron excitement. Thalamic neurons have low-threshold calcium channels. During human sleep, thalamic afferent stimulation is low and membrane potential is low, causing calcium channel opening, a large amount of calcium ion influx, forming a short excitatory postsynaptic potential (EPSP). Because a large number of inhibitory neurons in the thalamus block the afferent stimulation, a series of longer inhibitory postsynaptic potentials (IPSP) will follow the EPSP to form a group of EPSP-IPSP. This goes on repeatedly to form the EEG rhythm. The EEG rhythm with typical characteristics during sleep can be used as a basis for judging the sleep stage and diagnosing sleep diseases. Taking adults as an example, Table 2 shows five typical rhythms. It can be seen from these five types of rhythms that different EEG rhythms have large differences in frequency, amplitude, shape, etc., which is a good electrophysiological basis for sleep staging.

Sleep Quality Testing Process
The core of sleep quality detection lies in sleep staging. Being able to design a highly accurate sleep staging algorithm can effectively promote the inspection of sleep quality. The flow of the sleep staging method is shown in Figure 2. In this study, EEG signals were selected as the input signal source, and preprocessing and feature extraction were performed on the EEG signals. Finally, the TSVM classifier and preliminary staging results were corrected to complete the sleep staging.

Brainwave Pretreatment
EEG is an electrophysiological signal with weak amplitude and is extremely susceptible to noise interference. Therefore, before signal analysis, it needs to be preprocessed to reduce high-frequency noise, baseline drift, and artifact interference. The signal preprocessing process is shown in Figure 3.

Slow wave
During the transition period from just falling asleep to light sleep, slow-wave activity repeatedly bursts. And, often adjacent to the top wave, there is no specific shape standard. The average frequency is generally 5-7 Hz, and it appears more in the center of the head and in the top area.

Top wave
The top wave is a sign of the N1 phase, which can be extended to the N2 phase. The maximum amplitude often appears in the cranial region, and the frequency is generally 3-8 Hz. A typical top wave is symmetrically synchronized on both sides and has a sharp shape.
σ rhythm The σ rhythm is a sign of the N2 period and can be continued to the N3 period, which lasts more than 0.5 s. Its maximum amplitude often appears in the cranial area and can reach the frontal area, central area, and apical area on both sides of the head. The σ rhythm is generally a 12-to 14-Hz spindle-shaped wave, so it is also called a spindle wave.
κ synthetic wave κ synthetic waves often appear in the N2 phase and can continue to the N3 phase, mainly distributed in the apical or frontal area of the head. The waveform is similar to the top wave, but is wider. It is a steep negative wave followed by a positive wave, often followed by a series of 12-to 14-Hz σ rhythms. Synthetic waves are often induced by external stimuli such as sound and touch.
α rhythm The α rhythm is a symbolic rhythm of awake state. It often appears in the back of the head and can spread to the central region, the middle temporal region, or the troubled roof. The α rhythm is generally 9-11 Hz.

Brain Wave Feature Extraction
This study uses discrete wavelet transform (DWT) for feature extraction. When extracting, the artificial sleep staging results obtained according to the AASM rules are used as the reference standards. When DWT analyzes the EEG signals, the main problem to be solved is the choice of decomposition layers and wavelet basis, where the decomposition layers are determined by the original signal frequency. The power of the EEG signal is mainly concentrated in the range of 0-30 Hz, so the decomposition frequency is set to 4 to extract all the characteristic frequency bands of the EEG signal. The signal is decomposed into D1-D4 components with detailed information and A4 components with low-frequency information. Figure 4 shows the frequency range of the sub-band obtained by a four-layer DWT decomposition of the EEG signal. It can be seen from the figure that the A4 component contains the δ frequency band (0-4 Hz), the D4 component contains the θ frequency band (4-8 Hz), the D3 component contains the α frequency band (8-13 Hz) and part of the β frequency band, and the D2 component contains the β frequency band (13-30 Hz). The D1 component has frequency information higher than 30 Hz, which basically contains no information about the EEG signal. Therefore, in this study, the D2-D4 detailed component and the low-frequency component A4 are used.
In this paper, the db4 wavelet is used to decompose the EEG signal into four layers, and the mean and standard deviation of the absolute values of the D2-D4 and A4 components are counted. Because of the particularity of wavelet decomposition, first calculate the wavelet coefficients on the 25-s timescale and then use the sliding window to obtain the parameters of 80, 140, and 200 s by calculating the mean. In this paper, the four-layer wavelet decomposition of the db4 wavelet is used to process the EEG signals, and the wavelet coefficients of the four frequency bands shown in Table 3 are extracted.

Sleep Brain Wave Classifier Training
The classifier used in this paper is TSVM. It uses relevant knowledge of the source domain to assist the target domain in establishing a classification model. Among them, a large number of labeled sample sets (T s ) in the source domain are similar to the Frontiers in Neuroscience | www.frontiersin.org , and a small number of the labeled sample sets in the target domain (T t ) are the same as the Test. By "transferring" T s 's knowledge, w s , to T t , a classification model was obtained, f :X → Y, so that f could correctly classify Test. The SVM classifier consists of (w, b), the discriminant function is f (x) = wT x +b, and the classification decision function is L(x) = sign(f (x)). The theoretical basis of the algorithm in this paper is that, if the two domains are related, the respective values of the two domain classifiers should be similar. By adding µ w t − w s 2 to the SVM objective formula, transfer learning between the two domains can be achieved, where w t − w s 2 represents the degree of difference between the two-domain classifiers. The larger the value, the greater the difference between the classifiers. Parameter µ controls the penalty level. The principle of TSVM can be expressed in Figure 5.
There is a source domain SVM classifier (w s , b s ). Use the source domain classifier knowledge, w s , to carry out transfer learning on the target domain. The optimization goal problem is as follows: (1) where β = (β 1 , β 2 ,..., β n ) T and γ = (γ 1 , γ 2 ,..., γ n ) T are the Lagrange multiplier column vectors. Find the partial derivatives of the original variables w t , ξ t i , and b t and set to 0.
Substituting Equations (3, 4) into the objective function (1), the dual form of the original problem is The specific algorithm of the transfer learning target domain classifier is as follows:  (1) Gain knowledge of the source domain w s , choose the appropriate penalty parameters C t , µ.

Experimental Data
The experimental data for this study come from the National Sleep Research Resource Library (NSRR). The resource library provides a large number of physiological signal data of clinical trials. The collected physiological signal data from The Sleep Heart Health Study (SHHS) implemented by the National Heart Lung & Blood Institute (NHLBI) of the United States are shared by the resource library. The samples of the polysomnography (PSG) experiment in the Sleep Heart Health Study (SHHS) dataset originated from 6, 441 individuals collected from 1995 to 1998. The subjects were all over 40 years old and in good health. In this paper, the first 60 sets of samples in the Sleep Heart Health Study (SHHS) dataset will be used as the experimental test data. We randomly selected 40 as the training set and the remaining 20 as the test set.

Evaluation Index
The evaluation indicators used in this article are shown in Table 4.

Experimental Results and Analysis
In order to verify the effectiveness of the sleep staging method proposed in this paper, we used the DWT feature extraction method. The comparative classifiers used are SVM (Melgani and Bruzzone, 2004), Bayes classifier (BC) (Moraes et al., 2020), decision tree (DT) classifier (Friedl and Brodley, 1997), transfer component analysis (TCA) (Abid et al., 2016), and joint distribution adaptation (JDA) (Xie et al., 2018). An algorithm with excellent performance should have higher TPR, TNR, and precision. As can be seen from the data in Tables 5-7, on the indicator TPR, the TSVM algorithm improves the traditional SVM, BC, and DT by 4.7, 13.8, and 11.0%, respectively. On the indicator TNR, it increased by 3.6, 4.6, and 4.1%, respectively. On the indicator precision, it increased by 2.2, 7.9, and 5.2%, respectively. The performance of the SVM algorithm is more stable and better than those of the BC and DT algorithms, which is why we chose SVM as the basic algorithm. The performance of the TSVM algorithm used in this article is ahead of the comparison algorithm in all three evaluation indicators. This is because the introduction of the transfer mechanism can effectively utilize useful information from the source domain data and improve the classification performance.
Comparing the three migration learning algorithms TCA, JDA, and TSVM, the performance gap of each algorithm is not big. Among them, the performance of the JDA algorithm is the best, the TSVM used in this article is the second, and TCA is the worst. The reasons for choosing TSVM in this article are as follows: firstly, the TSVM algorithm is more widely used, and the mathematical principles and implementation process are relatively simple. Secondly, compared with other migration algorithms, TSVM has little performance gap, and the recognition results based on TSVM can fully meet the needs of reality. Thirdly, TSVM needs to optimize and set a few parameters, but JDA, which has the best classification effect, needs to optimize and set many parameters. If the parameters are selected differently, the final operation effect of the algorithm will be very different. Based on the above reasons, it is feasible to choose TSVM as the final classifier in this paper.

CONCLUSION
In order to check the quality of sleep, this paper mainly carried out research work on sleep staging. The innovation of this research lies in the introduction of a transfer learning classifier, which can effectively improve the classification performance of the data. The transfer learning classifier introduces the transfer learning mechanism based on the traditional SVM classifier. The introduction of the transfer learning mechanism can effectively use the knowledge of the source domain to guide the classification task of the target domain. In sleep staging research work, the EEG signal is first preprocessed, then DWT is used for feature extraction, and, finally, the TSVM with transfer learning mechanism is used to classify the feature data. The experimental results on the public dataset show that the method in this paper has greatly improved the performance of classification and can achieve the detection of sleep quality to a certain extent. However, this article only uses EEG signals for research, which has limitations. The research on sleep quality based on multimodal physiological signals can be expanded in the future.

DATA AVAILABILITY STATEMENT
The original contributions presented in the study are included in the article/supplementary material, further inquiries can be directed to the corresponding author/s.

AUTHOR CONTRIBUTIONS
WW independently conceived and designed the framework of the manuscript. From the determination of the research problem, the selection and implementation of the solution are all done independently by WW. During the implementation of the solution, the main tasks include model training, experimental data evaluation and analysis, and manuscript preparation. WW was independently responsible for the entire process from conception to the completion of the manuscript.