Abstract
Automated classification of sleep stages is in demand to overcome the limitations of manual sleep stage classification. Analyzing sleep stages manually using neurophysiological signals and inspecting visually is very difficult, time-consuming process. Many techniques have been proposed already in the past two decades. Sleep experts, physicians do not have assurance with such techniques concerned with accuracy, specificity and sensitivity. The aim of the paper is to propose an efficient technique for sleep stage classification based on Electroencephalogram (EEG) signals analysis using machine learning algorithms by considering 10 s of epochs. EEG signals have played significant role in automatic sleep stage classification. EEG signals are filtered and decomposed into frequency sub-bands using band-pass filter. Statistical features are extracted and trained with Decision Tree, Support Vector Machine and Random Forest algorithms with different testing dataset percentage. Results show Random Forest algorithm achieves 97.8% of accuracy.
Similar content being viewed by others
Explore related subjects
Discover the latest articles, news and stories from top researchers in related subjects.Avoid common mistakes on your manuscript.
1 Introduction
Sleep is a naturally occurring biological phenomenon which impacts the human body. People spend one-third of their life in sleeping [1]. Sleep is an important phenomenon in human life which plays vital role in individual performance, learning ability and day-to-day life activities. Few of the sleep-related problems like insomnia and obstructive sleep apnea have major impact over the physical health of an individual [2]. As per National Sleep Foundation (NSF), sleep disorders are found in 60% of the adults [3]. It is estimated from American Sleep Association (ASA) that around 50–70 million adults in USA are suffering from sleep-related problems [4]. Sleep apnea is found among 2–4% of the adults and 1–3% children [3, 4]. World’s 33% population is suffering from sleep issues [3, 4]. As per National Highway Traffic Safety Administration (NHTSA) in the United States, more than 100,000 automobiles have crashed annually while falling asleep during driving [4]. 20% of road accidents in United Kingdom and one out of four accidents in Germany are due to sleep-related issues [4]. Approximately, 3% of road traffic accidents are caused by sleep-related problems [4, 5].
Sleep experts suggest EEG gives better result for sleep stage classification by reducing disturbances of Polysomnography (PSG) wire recordings and other equipments [4]. PSG signals are acquired from the patients during sleep in the night time at hospitals. Recordings of PSG signals include Electrooculogram (EOG), Electrocardiogram (ECG), Electromyogram (EMG) and Electroencephalogram (EEG) [4, 6, 7]. These signals are divided into epochs, analyzed visually by sleep experts and physicians as per American Academy of Sleep Medicine (AASM) sleep scoring standard [6]. Classifying sleep stages using PSG signals based on visual inspection is a time-consuming and more problematic process [4, 6]. EEG signals recorded from multiple channels and visually examined by experts make sleep scoring phenomenon expensive, more tedious and subjected to human errors. EEG signals consist of more significant and prominent information compared to ECG, EMG and EOG signals [4, 6].
Sleep stages are divided into Rapid Eye Movement (REM) and Non-Rapid Eye Movement (NREM). NREM is further divided into stage 1, stage 2, stage 3 and stage 4 as per the guidelines of Rechtschaffen and Kales method [4, 6, 8, 9]. Recently, American Academy of Sleep Medicine (AASM) has come up with the modified sleep stages which involves stage 1 as N1, stage 2 as N2, and stage 3 and stage 4 combined together as N3 [4, 6]. Most of the previous work which were carried out on sleep classification using different feature extraction methods are listed in Table 1 [4].
Some of the machine learning techniques are listed in Table 2 [4] which are commonly used for sleep stage classification. Single channel of EEG and multi-class SVM-based sleep classification has achieved an accuracy of 87.5% [4]. An accuracy of 92.7% was achieved using Fuzzy C means algorithm [4], whereas 93.13% is obtained using single-channel EEG signal [4].
In this paper, EEG signals are obtained from Sleep-EDF database from physionet website and from Dr. Chandrashekhar’s clinic. EEG dataset is processed to extract statistical features from each epoch of 10 s by representing EEG signals in time–frequency domain. Decision Tree (DT), Support Vector Machine (SVM) and Random Forest (RF) algorithms are trained with extracted features using different testing data set percentages. Sleep stages are classified into three stages viz. stage 1 (8 Hz and above), stage 2 (4–8 Hz) and stage 3 (0–4 Hz), which will help to identify and treat issues like fatigue, drowsiness, sleep apnea, insomnia and other sleep-related disorders. Table 3 represents three different EEG signal frequency bands and corresponding amplitude ranges are used in sleep stage classification of the proposed work.
2 Proposed Method and Procedure
The proposed method includes technique for identification of sleep stages to understand the sleep-related problems. Figure 1 represents the flow chart of the proposed study of sleep stage classification.
2.1 EEG Data Set
EEG dataset used in this proposed work is obtained from Sleep-EDF database and from Dr. Chandrasekhar’s clinic. The dataset of 125 patients is collected from all the age groups between 20 to 50. EEG signals are composed of overnight sleep scoring without any medication. Collected EEG signals are sampled with 128 Hz. These signals are processed and divided into epochs of 10 s to produce total of 68,956 epochs for classification of sleep stages.
2.2 Preprocessing
EEG de-noising is performed using wavelet transform method which localizes the features and preserves during filtering of noise signals. Original signal contains many high-frequency and noise components. De-noising is essential to filter high-frequency signals and noise components.
Detailed information of EEG is determined using filtering functions. Figure 2 depicts the de-noised EEG signal.
Infinite Impulse Response (IIR) filters are considered to be the most simple and realizable on any digital signal processors and embedded systems [4]. Higher-order filters result in better accuracy. EEG dataset is processed using 12th order IIR digital butterworth filter with cutoff frequency 0–15 Hz. There are no ripples present in the frequency response of the butterworth filter and the pass band remains almost flat [4]. Fourier Transform is used to decompose EEG signals into frequency sub-bands namely delta, theta, alpha and beta using IIR butterworth band-pass filters as shown in Fig. 3.
2.3 Feature Extraction
Significant amount of information is obtained by extracting features of EEG signals. Time–Frequency examination of EEG signals provide right perception to extract features by removing different rhythms of frequencies [13]. These signals are further processed and its time–frequency representation is obtained which is shown in Fig. 4 [22]
Statistical features are extracted from each frequency sub-bands [4]. These extracted features play vital role in classification of sleep stages, which yields good accuracy and improves system performance. Extracted features from each of these frequency sub-bands are explained below.
2.3.1 Mean
Mean determines the central discrete value of set of numbers. It indicates the probability of distribution of random variables.
where µ is mean, x is random variable and p is probability
2.3.2 Entropy
Ascertaining data and entropy is helpful in machine learning. Accordingly, machine learning professional requires solid comprehension and instinct for data and entropy. While assessing a model from the information, one needs to expect specific information for creating process. Entropy is average information content of a given dataset. For a given dataset X, entropy is calculated as using:
where pi indicates the probability of samples in data set.
2.3.3 Power Spectral Density (PSD) and Event-Related Potential (ERP)
PSD and ERP are considered to be one of the well-established methods for analyzing EEG signals to classify sleep stages. In this paper, PSD and ERP plots are derived using EEGLAB. It gives a graphical user interface and permits users to intuitively process the data for better sleep stage classification.
Figure 5 represents the PSD of the selected EEG channel. ERPs provide insight about EEG and timing of neuronal events. ERPs extracted from EEG have received more attention in the recent years [10]. ERPs have both positive and negative voltage deflections as indicated in Fig. 6. The averaging of overall signal is performed. Information content in the epochs and random activity in EEG signal is canceled out. It slowly starts approaching towards zero as the number of samples increases. EEG signals that survive during this averaging process are ERP components. These components play significant role in the sleep stage classification.
2.3.4 Energy sis (Esis)
Esis is the most effective technique for analyzing EEG signals with 10 s of epoch. In the automatic sleep stage classification, systems are more affected by channel redundancy and noisy data which reduces the accuracy of the classification phenomenon. Determining and analysis of Esis parameters is certainly possible to find discriminative features, which increases the performance and boosts classification accuracy. Energy sis is a time domain feature which determines the speed and energy of EEG signals. It is another method of extracting EEG signal features by the analysis of speed (velocity) and energy of EEG signals, it is calculated using the below-mentioned formula (3). The speed and energy is calculated using v = f λ, where f is frequency and λ is wavelength [4]. Esis is measured using the following equation.
3 Machine Learning Algorithms for Sleep Stage Classification
Machine learning is a technique in which a model is trained to generate an outcome by training the algorithm with input dataset. In this proposed study, we have considered EEG data samples for sleep stage analysis. Various machine learning algorithms have been proposed to classify sleep stages in the past few years [3, 4]. In the proposed study, extracted features are fed to the training model with different testing data set percentages and classified using the Decision Tree, Support Vector Machine and Random Forest algorithms.
3.1 Decision Tree (DT) for Sleep Stage Classification
Decision Tree involves the separation of EEG signals into subset such that it contains similar information content. Each sleep stage is easily distinguished by nodes. In decision tree, each node is at the top and other nodes are connected to root node through branches or links [11]. In the decision tree, one link or branch is followed and the remaining nodes are root nodes of next sub-tree until any further decision is made. For the training dataset X which includes N samples, namely X = {x1, x2,…, xN}, each sample xi includes q features which are given by xi = {vi1, vi2,…, viq}, i = 1,2,…,N. Each attribute Ak consists of N values given by Ak = {v1k, v2k,…., vNk}, k = 1,2,…,q. In decision tree, the process of tree formation starts with training dataset X, whereas the internal nodes contain different test attributes. Split attributes are the ones which divide the samples into their classes. Consider At is split attribute which divides the internal node t into w sub-branches and is given by {X1, X2,…., Xw). For the given attribute Ak, the information gain of dataset X is given by Eq. (4) and the information gain ratio is computed using Eq. (5).
3.2 Support Vector Machine (SVM) for Sleep Stage Classification
Sleep stage classification model is developed by training EEG data set, which helps in predicting the target values of the test data. Leave-one-out training method is used, in which one element is removed from EEG dataset. Using these datasets, predicative model is defined. Defined model is used to predict and assign the elements to the class and this procedure repeats for all the elements.
Most of the times, SVM is used as kernel for classification techniques [12]. Different kernel functions are used in the implementation of algorithm such as Linear, Polynomial, Radial Basic Function (RBF) and Sigmoid. RBF is the most commonly used kernel function for EEG processing [13]. Extracted EEG features are linearly separated using RBF kernel function. This separation of data is called decision hyper-plane. SVM is used to find the optimal hyperplane which results in better generalization of the classifier. SVM is generally used for both linear and non-linear classification problems [11, 14].
3.3 Random Forest (RF) for Sleep Stage Classification
Bootstrap aggregating is used while training the data set using RF algorithm to classify sleep stages. The overall prediction is made based on the average values of individual regression tree-predicted values. RF algorithm is formed by considering the various decision trees which constitute to forest by randomly selecting data. It sums of all the votes of various decision trees and decides final class of an object.
Random forest is an ensemble learning technique which operates and combines the uncorrelated decision trees. Step-by-step RF working model is explained below and described in Fig. 7
-
(i)
The randomly available data are collected from data set.
-
(ii)
Decision tree is built for each of the sample data set.
-
(iii)
Prediction is obtained from each decision tree.
-
(iv)
Vote is obtained for each predicted results.
-
(v)
Final decision is made by selecting the maximum voted results.
4 Results and Discussions
In the proposed study, based on the entropy of the determined values, sleep stages are classified into stage 1, stage 2 and stage 3 as represented in Fig. 8. Stage 1 is REM sleep stage which consists of frequencies 8 Hz and above whereas, stage 2 and stage 3 are parts of NREM with frequency range 4–8 Hz for stage 2 and 0–4 Hz for stage 3.
Proposed study makes use of 125 patients EEG recordings with 68,956 epochs each of 10 s duration. Statistical features are extracted from EEG signals by representing in time frequency domain and these features are used to train RF, SVM and DT algorithms to classify sleep stages with ten-fold cross-validation technique. Evaluation matrix is determined, which helps in analyzing and evaluating the performance parameters such as sensitivity, specificity, accuracy of classification phenomenon.
where TP = True Positive, TN = True Negative, FP = False Positive and FN = False Negative.
In the process of training and testing the EEG data to classify sleep stages using three different algorithms, it is preferred to consider 10% testing data and 90% training data. Then, it is continued with 20% of testing and 80% of training data, later 30% of testing and 70% of training and finally 50–50% of testing and training data are used.
It is evident from the analysis carried out as shown in Table 4, Random Forest algorithm achieves the highest accuracy of 97.80% compared to SVM and DT algorithms.
5 Conclusion
In the proposed method to classify sleep stages, RF provides better accuracy in comparison with SVM and DT algorithms. The proposed method is also compared with the techniques implemented by other researchers as shown in comparison Table 5.
It is inferred that most of these techniques have considered limited number of subjects for determining the accuracy of sleep stages whereas, our method is feasible and renders easy implementation. The proposed method certainly has advantage in terms of accuracy and feasibility in comparison with the recently available studies on classification of sleep stages [21, 23,24,25,26].
Abbreviations
- EEG:
-
Electroencephalogram
- PSG:
-
Polysomnography
- ECG:
-
Electrocardiogram
- EOG:
-
Electrooculogram
- EMG:
-
Electromyogram
- REM:
-
Rapid eye movement
- NREM:
-
Non rapid eye movement
References
Pruncnal M, Polak AG. Effect of feature extraction on automobile sleep stage classification by artificial neural network. Metrol Meas Syst. 2017;24(2):229–40. https://doi.org/10.1515/mms-2017-2017-0036.
Vadala R, Deenadayalan H, Ranganathan L, et al. Appropriate BMI criteria for Indian population does it help stratify obstructive sleep apnea (OSA) patients better? Sleep Vigil. 2019;3:139–42. https://doi.org/10.1007/s41782-019-00069-1.
Almuhammadi WS, Aboalayon KAI, Faezipour M. Efficient obstructive sleep apnea classification based on EEG signals. Long Isl Syst Appl Technol. 2015. https://doi.org/10.1109/LISAT.2015.7160186.
Aboalayon KAI, Faezipour M, Almuhammadi WS, Moslehpour S. Sleep stage classification using EEG signal analysis: a comparative survey and new investigations. Entropy. 2016;18:272. https://doi.org/10.3390/e18090272.
Komada Y, Asaoka S, Abe T, Inoue Y. Short sleep duration, sleep disorders and traffic accidents. IATASS Res. 2013;37(1):1–7. https://doi.org/10.1016/j.iatssr.2013.06.001.
Yildrim O, Baloglu UB, Acharya R. A deep learning model for automated sleep stage classification using PSG signals. Int J Environ Res Public Health. 2019;16(4):559. https://doi.org/10.3390/ijerph16040599.
Supratak A, Dong H, Wu C, Guo Y. DeepSleepNet: a model for automated sleep stage scoring based on raw single-channel EEG. IEEE Trans Neural Syst Rehabil Eng. 2017. https://doi.org/10.1109/TNSRE.2017.2721116.
Liu G-R, Lo Y-L, Malik J, Sheu Y-C, Wu H-T. Diffuse to fuse EEG spectra-intrensic geometry of sleep dynamics for classification. Biomed Signal Process Control. 2020;55:101576. https://doi.org/10.1016/j.bspc.2019.101576.
Chambon S, Galtier MN, Arnal PJ, Wainri G, Gramfort A. A deep learning architecture for temporal sleep stage classification using multivariate and multimodla time series. IEEE Trans Neural Syst Rahabil Eng. 2018. https://doi.org/10.1109/TNSRE.2018.2813138.
Delorme A, Makeig S. EEGLAB: an open source tool box for analysis of single-trial EEG dynamics including independent component analysis. J Neurosci Methods. 2004;134:9–21.
Tzimourta KD, Tsimbaris A, Tzioukalia K, Tzallas AT, Tsipouras MG, Asktrakas LG, Giannakeas N. EEG based automatic sleep stage classification. Biomed J Sci Tech Res. 2018. https://doi.org/10.26717/BJSTR.2018.07.001535.
Qureshi S, Vanichayobon S. Evaluate different machine learning techniques for classifying sleep stages on single-channel EEG. In: IEEE 2017 Computer science and software engineering international joint conference, 12–14 July 2017, Nakhon Si Thammarat, Thailand. pp. 1–6. https://doi.org/10.1109/JCSSE.2017.8025949.
Saccá V, Campolo M, Mirarchi D, Gambardella A, Veltri P, Morabito FC. On the classification of EEG signal by using an SVM based algorithm. In: Esposito A, Faudez-Zanuy M, Morabito FC, Pasero E, editors. Multidisciplinary approaches to neural computing, vol. 69. Cham, Switzerland: Springer; 2018. pp. 271–278. https://doi.org/10.1007/978-3-319-56904-8_26.
Torse D, Desai V, Khanai R. Classification of EEG signals in a seizure detection system using dual tree complex wavelet transform and least squares support vector machine. Int J Image Graph Signal Process. 2018;10(1):56–64. https://doi.org/10.5815/ijigsp.2018.01.07.
Chen X, Wang B, Wang X. Automatic sleep stage classification for daytime nap based on hopfieldneural network. In Proceedings of the Chinese control and decision conference (CCDC), Guiyang, China, 25–27 May 2013. pp. 2671–2674. https://doi.org/10.1109/CCDC.2013.6561393.
Obayya M, Abou-Chadi F. Automatic classification of sleep stages using EEG records based on Fuzzy c-means (FCM) algorithm. In: Radio Science Conference (NRSC), 2014 31st National. 2014. pp. 265–272. https://doi.org/10.1109/NRSC.2014.6835085.
Guohun Z, Yan L, Wen PP. Analysis and classification of sleep stages based on difference visibility graphs from a single-channel EEG signal. IEEE J Biomed Health Inform. 2014;18(6):1813–21. https://doi.org/10.1109/JBHI.2014.2303991.
Liang S-F, Kuo C-E, Hu Y-H, Cheng Y-S. A rule-based automatic sleep staging method. J. Neurosci. Methods. 2012;205(1):169–76. https://doi.org/10.1016/j.jneumeth.2011.12.022.
Ebrahimi F, Mikaeili M, Estrada E, Nazeran H. Automatic sleep stage classification based on EEG signals by using neural networks and wavelet packet coefficients. In: Proceeding of IEEE EMBC. 2008. pp. 1151–1154. https://doi.org/10.1109/IEMBS.2008.4649365.
Aboalayon KAI, Almuhammadi WS, Faeziour M. A comparison of different machine learning algorithms using single channel EEG signal for classifying human sleep stages. Long Isl Syst Appl Technol. 2015. https://doi.org/10.1109/LISAT.2015.7160185.
Karimzadeh F, Boostani R, Seraj E, Sameni R. A distributed classification procedure for automatic sleep stage scoring based on instantaneous electroencephalogram phase and envelope features. IEEE Trans Neural Syst Rehabil Eng. 2018. https://doi.org/10.1109/TNSRE.2017.2775058.
Maeda M, Takajyo A, Inoue K, Kumamaru K, Matsuoka S. Time-Frequency analysis of human sleep EEG and its application to feature extraction about biological rhythm. In: Proceedings of the SICE annual conference, Takamastu, Japan, 17–20 September 2007. pp. 1939–1944. https://doi.org/10.1109/SICE.007.4421304.
Memar P, Faradji F. A novel multi-class eeg-based sleep stage classification system. IEEE Trans Neural Syst Rehabil Eng. 2018. https://doi.org/10.1109/TNSRE.2017.2776149.
Tripathy RK, Acharya UR. Use of features from RR-time series and EEG signals for automated classification of sleep stages in deep neural network framework. Elseivier Biocybern Biomed Eng. 2018. https://doi.org/10.1016/j.bbe.2018.05.005.
Koch H, Jennum P, Christensen JAE. Automatic sleep classification using adaptive segmentation reveals an increased number of rapid eye movement sleep transitions. J Res Pap. 2018. https://doi.org/10.1111/jsr.12780.
Fraiwan L, Lweesy K, Khasawneh N, Fraiwan M, Wenz H, Dickhaus H. Time frequency analysis for automated sleep stage identification in full term and preterm neonates. J Med Syst. 2011;35:693–702. https://doi.org/10.1007/s10916-009-946-2.
Acknowledgements
We thank Dr. D. A. Torse and Dr. Anil B. Gavade for their valuable guidance and inputs.
Funding
No funding been considered for this research work
Author information
Authors and Affiliations
Contributions
Analysis of EEG data is carried out using preprocessing and extracting features. EEG data is classified using machine learning algorithms.
Corresponding author
Ethics declarations
Ethical statement
Clinical data referred to carryout the analysis of sleep stages is collected by consulting Dr.Chandrashekhar, Assosciate Professor, Belgaum Institute of Medical Sciences, Belagavi, Karnataka, India.
Additional information
Publisher's Note
Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Rights and permissions
About this article
Cite this article
Santaji, S., Desai, V. Analysis of EEG Signal to Classify Sleep Stages Using Machine Learning. Sleep Vigilance 4, 145–152 (2020). https://doi.org/10.1007/s41782-020-00101-9
Received:
Revised:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s41782-020-00101-9