Sleep states detection using Halfwave and Franklin transformation

Sleep is a physiological phenomenon and a suﬃcient amount of sleep is mandatory for a human for his/her health. Three biomedical signals namely Blood, EEG and Nasal are used to identify various sleep stages. The discrete version of these signals is piecewise linear function and applied two piecewise linear data reduction techniques namely a new Halfwave method in bf time domain and Franklin transformation in frequency domain on the discrete versions of these selected signals. As a result we obtained two piecewise linear functions with low complexity that still preserve the characteristics of the stages of the sleep in the signals. The components of the feature vector are generated from the parameters of the two reduced piece wise linear functions. Algorithm is tested on MIT-BIH Polysomnographic Database having more than 70 hours long term EEG, Blood and Nasal signals with six diﬀerent sleep classes. Proposed method shows better performance so far on such long duration data in terms of Sensitivity, Speciﬁcity, Accuracy and False Alarm Rate/hour. Algorithm achieved an average sensitivity, speciﬁcity accuracy and false alarm rate of 98.35% and 97.32%, 96.96%, 0.029 respectively for two classes, 96.62% and 97.10%, 93.94%, 0.030 for 4 classes, 96.13% and 98.33%, 93.84%, 0.016 for all (six) classes.


Introduction
Sleep is an important part of individuals life and people used to sleep one-third of their whole life. There are large number of disorders like insomnia, breathing disorders, wake-sleep disorder sleep movement disorder found in human beings . Around 24% of the adult population have regular sleep disorders. Ohayon and Smirne [1] shown 27.6% of the Italin population have sleep problem. 5 Gupta et al. [2] shown Indian population have 10-15% insomnia and 10% delayed sleep wave phase disorder. Worldwide this problem is increasing day by day and according to Oliver et al. [3] this problem costs around $100 billion USD per year. Every sleep state has different group of neurological and physiological features and correct identification of these features along with their states are important for diagnosis and the better treatment for such sleep disorders [4]. Sleep classification 10 process is not a standardized one i.e. different experts have different criteria to mark a specific period of sleep. Usually sleep scientists make classifications by using visual method to predict or decide in which state the patient is for a specific time [5].The human sleep is categorized into 3 main categorized name wake, REM and NREM. (Non Rapid Eye Movement) sleep [6]. A state is called slow wave sleep or synchronized sleep when sleep is analyzed with EEG characteristics and same 15 sleep can be known as quiet sleep when behavioral correlates are utilized. When eye movements are used such state is called as NREM. According to R&K [6] rules sleep is categorized into six categories, REM, sleep stage1, stage2, stage3, stage4 and wake state. Stage3 and stage 4 were combined as slow wave sleep (SWS) stage. Due to high nonuniform and nonlinear nature of the majority of the biomedical signals single domain analysis is not sufficient to extract the desired information 20 from the signal.Therefore there is a need to combine the features from different domains to extract comprehensive information from the signal. Generally NREM are high in magnitude as compared to REM but breathing and heart rate is more regular than REM. In the recent sleep state classification research, researcher has combined NREM3 and NREM4 as a single state and hence total number of classes remaining are 5 [7]. Later on NRME2 and NRME3 are also combined resulted as just four main classes namely light sleep, Deep sleep REM and Awake state. Most of the researcher who are involved in automatic sleep state detection research rely on PSG (Polysomnography), a multi-parametric test that look after many body activities using EEG (electroencephalography), EOG (electrooculography), EMG (Electromyography ). The implementation of Faber Schauder system with halfwave is obvious because Faber Schauder system and halfwave decomposition both 30 are linear piecewise systems and the discrete version of the biomedical signals is also piecewise linear [8] [9], [10]. Polysomnogram is a collection of various signals useful for monitoring the sleep of an individual. For accurate diagnosis of sleep phases, whole duration recordings of the selected biomedical signals needs an expert manual scoring for sleep stages using some standards. Therefore there is a need for automatic sleep phase detection to reduce cost and to increase access to diagnosis 35 sleep stages. The main challenge to automatic sleep phase detection is : Heterogeneity : people around the world have different cranial structures which demographically and physiologically effects the patterns in the signal. Example 10 percent people don't generate alpha rhythm during stage W (wake) and 10 percent generate only a limited alpha rhythm. Therefore this issue motivate us to combine the other signals with EEG to improve the results. Six EEG wave patterns are used to 40 differentiate wake and sleep states and classify sleep stages: (1) alpha activity, (2) theta activity, (3) vertex sharp waves, (4) sleep spindles, (5) K complexes, and (6) slow wave activity [6][11] [12] [4].These are summarized we believe that results would be good and more reliable as compared with the state of the art methods. Relationship between EEG rhythms and sleep states and brain states are given below. δ(1 to 4 hz) = deep sleep, NREM sleep, unconsciousness. 45 θ(4 to 8 hz) = light sleep. α81 to 13 hz) = relaxed but not sleep, calmness and conscious. β(14 to 30 hz) = consciousness of self and surroundings. According to NHTSA in USA drowsiness while driving causes around 100000 accidents per year out of which 1500 cases faces death and 71000 suffer from major injuries [13]. Polysomnography is 50 commonly used for sleep state detection, monitoring scoring for sleep related diseases [14]. Manual process of sleep states scoring is time consuming, therefore an automatic system of sleep states scoring is needed to aid sleep technologies. The proposed automatic system of sleep states uses two piecewise linear models to decompose the signals into a simple form. Features are extracted from the decomposed signals (EEG, Respiratory and Blood) and the sleep states classification is

Dataset
MIT-BIH Polysomnographic Database (Physionet,https://www.physionet.org /physiobank/database/slpdb/), collected and described by Ichimaru Y, Moody GB et al. [15] [16] at Boston's Beth Israel Hospital Sleep Laboratory. It is a data collection from 16 subjects whose average weight and age are 119kg and 43 years respectively.The database contains over 80 hours' long data of four(C3-O1), six (C3-A1), and seven(O2-A1)-channel polysomnographic recordings, each with an ECG signal annotated beat-by-beat, and EEG and respiration signals annotated with sleep states and apnea. Each signal is divided into 20 and 30 sec long epoch and each epoch 65 belongs to the one of the sleep stages.The sampling rate of the measured signal is 250 Hz and 30 seconds duration of the EEG and other signals are labeled by associated experts. Available standard databases usually contains data of one type of signal like EEG, ECG (ECG=ElectroCardioGram) etc. or combination of EEG, ECG. We used blood, nasal and EEG signal in proposed method and we found that this is standard and long enough database which containing blood, nasal and EEG 70 signal, where we can test our proposed method. In our research, due to some technical problem we are not able to read 3 records out of 18 therefore we performed our tests only on remaining 15 records (patients)

Channel Selection
The channel selection is one of the most challenging tasks in sleep state detection and prediction 75 algorithms. Considering of large number of channels will make signal processing system computationally slow. In proposed method we used data from only one channel given by the database experts, but our method least dependent on some specific number or set of channels. We believed and saw that our method gives comparatively equally good results when channel number along with patient has been changed (as per the expert of the database) i.e. any randomly selected channel can 80 be used in proposed method which hardely reduces the performance of the algorithm and this is one of the main advantages of our proposed method (channel independent) . Our algorithm does not require any mechanism for channel selection and we require only one channel that can be random.

Methodologies Used
In proposed method we developed two piecewise linear time domain and frequency domain 85 models called new halfwave decomposition [8] and Faber-Schauder (Franklin) [9], [10] system to extract the best discriminatory features from three biomedical signals. The reason for developing two piecewise liner models in different domains is to make the system fast and accurate. These two models of piecewise linear funtions make the signals simple and short by discarding the irrelevant information but retain important sleep stage properties in the original signals. Thus, after applying 90 the models on the signal we have a simple, reduced but more assertive signal for analysis, which gives best insight into the signal. In literature survey we have found that recent research in signal processing is surrounding around very famous transformations like wavelets, EMD, Fourier, Hilbert and Fast Fourier etc [17]. Therefore there is a need of adaptive methods and transformations which can solve the signal processing problems efficiently and we believe that using adaptive methods 95 and transformations on these selected signals can perform better than all other existing methods.
We have chosen piecewise models because the nature of the discrete version of selected biomedical signal is also piecewise linear and piecewise functions have low computational cost and hence fast. The framework of the proposed algorithm is shown in figure 1.  Traditionally, from mid of 20th century to end of 20th century, halfwave was very popular method to detect epileptic activities (seizures) form the long EEG signals where the terms spikes and sharp waves also called SSWs [8] were the representative or interpretations of seizure and non seizure segments. Different methods to detect seizure by using halfwave have been proposed and some of them are reviewed here. Traditionally authors detect seizures by knowing the number and nature 105 of the waves called spikes or sharps waves and if sharp and spikes waves are found at a particular instant, they conclude that epileptiform activity is found at that instance. But traditional methods based on spikes and sharps were not reliable and therefore, Jasper and Kershman [18] divided focal epileptic activity into spikes i.e. 10 to 50 ms and sharp waves i.e. 50 to 500 ms. Chatrain et al. [19] gave different duration for spikes (20 to 70 ms) and sharp waves (70 to 200ms). In coming methods 110 definitions of sharp and spikes waves are purely qualitative, and the method of measurement of the duration of spikes and sharp waves was never mentioned. Koo et al. [20] conclude that epileptic activity can be identified in a signal by segmental velocities of more than 2 uv/msec. Walter et al. [21]. From the above methods authors conclude that systems were efficient for spike detection but sharp waves are not detected accurately and the muscle artifacts largely degrade the performance of the of the system. Saltzberg et al. [22] used a matched filtering technique to detect a particular wave shape in the scalp of monkey. This methods is very power when we know the shape of the wave in advance. But this method is not useful for EEG signal of human because subjects have different shapes of wave at different times which is not east to know in advance. Lopes da Silva et al.
[23] all used auto-regressive model to find non-stationeries in the signal and the method 120 is powerful because reveal epileptic activity which cannot be seen by the expert. But the model ( Gotman et al) has the disadvantage that it requires lot of computations. Apart from above mentioned methods Gotman et al. [8][24][25] studied other existing methods of halfwave too and they incorporate the above ideas into their original idea to generate an efficient halfwave which is more reliable and not misleading the results as compared to existing halfwave methods. In the classical or traditional method of wave generation, they broken down the EEG signal into segments and a segment is the section between two consecutive extrema of amplitude and it has duration, amplitude and direction. This method of analysis has drawback that when noise is superimposed on wave (beta, muscle) there are large number of small segments instead of single long segment. Gevins et al. [26] used digital filter at 20c/sec to eliminate the fast activity. Now Gotman et 130 al. [8] all have designed a new way of developing wave from original signal where segments are regrouped into sequences, generating slow frequency wave in the presence of low amplitude fast activity. According to Gotman a wave is defined as a set of two segments, two sequences or a segment and a sequence, where both the elements (segments or sequences) must be adjacent and of opposite direction. As it becomes a part of wave a segment or sequence is called a Half wave.

135
The main advantage of halfwave is that normal and abnormal patters of very long signals can be examined and identified easily. Halfwaves are easily implemented in small computers. Another 4   1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64 advantage of halfwave is that the most common artifacts like EMG and eye movements are usually not distributed in halfwave. In 2005 Runarsson and Sigurdsson used half-wave method given in [8] and halfwave's features are classified with support vector machine and they achieved an accuracy 140 of 90 percent. From the history of the halfwave method we have seen that the the scope of this method was restricted to seizure detection only and was not applied in other problems available in signal processing. We proposed a new, simple and fast method to construct halfwave decomposition which can act as filter itself in the signal processing and can be used for better analysis of the signal in various areas like sleep states, seizure detection etc.

145
Mathematical formalization of proposed Halfwave method: Let us suppose, that the f : [a, b] → R signal is continuous on the [a, b] compact interval, and suppose that f has finitely many extrema on [a, b]. Let us first collect the extrema points in two sets: f has a local maximum in x}, And let us denote the set of all extremal points by such that minimum and maximum points are alternating.
In the kth step of the proposed algorithm (k = 1, 2, 3, . . . ) we delete some extremal points from M k , m k and X k , and we will keep only the important extremal points to get the new sets M k+1 , m k+1 and X k+1 = M k+1 ∪ m k+1 . The algorithm will converge, i.e. ∃K ∈ N : ∀k ≥ K : M k = M K , m k = M K , but we will stop at a suitable iteration number k * .
One step of the proposed algorithm (deleting unwanted extrema) can be formulated as follows. We start with M k , m k and X k = M k ∪ m k , with the elements of X k indexed in ascending order, as above. Now define the extremal function values, the differences between two consecutive extreme values (a minimum and a maximum), and the set of indexes of segments with not significant difference (less than both neighboring segments).
To formulate the set of important extremal points we will use the strictly increasing index function  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64 defined by ν(0) = 0 and (It will turn out that ν(N ) = n). And then the set of important extremal points can be written as As a consequence of the definition the values in X k+1 are alternatingly minimum and maximum points. Furthermore we can also formulate the sets of the new maximum and minimum values. After the completion of first level, we will repeat the same procedure for the outcome (M k+1 , m k+1 150 and X k+1 ) of the first level to ge signal at next level (level 2 ) and so on untill required level is found.

Piece-wise linear transform
Haar wavelet is the simplest possible wavelet which is a sequence of re scaled square shaped functions which 155 together form a wavelet family or basis [27].
Haar system On the real line is the set of functions. ψ n,k (t); n ∈ Z, k ∈ Z. It is complete in L 2 (R); The Haar system on the line is an orthonormal basis in L 2 (R).  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62 63 64 s n,k (t) = 2 1+n/2 t 0 ψ n,k (u)du , t ∈ [0, 1], 0 ≤ k < 2 n . These functions s n,k are continuous, piecewise linear supported by by the interval I n,k that also supports ψ n,k .The function s n,k is equal to 1 at the mid point X n,k of the interval I n,k , linear on both halves of that interval . It takes values between 0 and 1 everywhere. The Faber Schauder system is the Schauder basis for The series expression of f in the Faber Schauder System is the continuous piecewise linear function [28] that agrees with f at a n + 1 points k=0 a n,k s n,k .

Franklin System
A Franklin system is an orthogonal system of basis which is derived from Faber Schauder system of basis by applying Gram-Schmidt orthogonal procedure [29] 3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62 63 64 work and support vector machines are commonly used classifiers for the classification of the features extracted from biomedical signals [17] [33], [34]. KNN is non parametric, instance-based simple, robust, versatile, fast and supervised learning algorithm and in many applications it performs better than other modern classifiers like Artificial Neural Networks (ANN) and Support Vector Machines (SVM) [17]. Let x to denote a feature vector and y is class label, KNN Categorizing query points 215 based on their distance (Euclidean distance, Minkowski distance, Chebychev distance etc) to points in a training data set. It chooses K-most nearest or similar tuples to the query tuple and uses majority voting, weighted average of the K similar tuples to find the new class label for the query point. Similarity between two data points is calculated by means of a distance metric. A popular choice is the Euclidean distance. d(x, x 1 ) = ( (x 1 − x 1 ) 2 + (x 2 − x 2 ) 2 + · · · + (x n − x n ) 2 [33], [34].

220
Usually the given sleep states databases are not balanced i.e the number of tuples of different classes are not almost same. Therefore before applying any classifier, the class imbalance problem needs to be addressed otherwise results would be biased. There are two popular methods [35] address this problem and are given below:  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64 examples. This technique is designed to handle two class problem but we have used it for multiclass problem where each and every class is balanced with respect to the class having highest training tuples.

Related Work
In the literature survey we studied number of sleep states detection techniques and we found that recent research is focusing on dynamic parameters like correlation dimension, Lyponov exponent, 240 approximate entropy etc to extract comprehensive information from non linear signals like EEG, blood and respiratory [39]. Originally the halfwave was used in seizure detection but new halfwave method proposed by us can be used with Franklin transformation (a hybrid approach) [40] to detect epileptic seizures and sleep states classifications in an efficent way by using different biomedical signals. We believe that this method with slight modification in the parameters if needed can be vs non-rapid eye movement (NREM)' sleep stages. Silverira et al. [44] proposed a single channel method where EEG signal is decomposed using wavelet transform. The features such as kurtosis, skewness and variance of the wavelet coefficients are classified using random forest classifier and they obtained an over all accuracy for 2 to 6 classes is 90%. Budak et al. [45] they proposed new method to detect driver drowsiness.They decompose the signal using Q-factor wavelet transform Learning Method) their detection rate for alert and drowsiness are 95.45% and 87.92%. The over all accuracy was 92.28%. A subject specific approach [47] where 12 features are extracted by three methods namely, the heart rate variability (HRV), detrended fluctuation analysis (DFA) and windowed DFA (WDFA). They reported an average accuracy of 79.99 and kappa coefficient 0.43. Another subject specific approach is mentioned in [48] where average accuracy are using EEG is 270 76% and using ECG signals is 75%.

280
where TP is true positive, TN is true negative, FN is false negative . The study done by Shayan et al. [55] suggests various disadvantages of the existing studies. The study motivate the researcher to do research by using some adaptive methods. Our focus is to increase the speed as well as accuracy of sleep states detection process as compared to the existing methods. We have applied KNN classifier because it is faster as compared to other classifier but 285 cannot work fine when data is large. We found that our method works well when data is not very large to process. In near future work we plan to work on two biomedical signals instead of three signal with different set of features from different domains. The various results obtained are shown in table I, II, III, IV and table V. The table I help us to choose best set of discriminatory features among large number of features and we found that the combination in row number 12 and 13 can 290 be consider as best combination to detect various sleep states. Table II and table III shows the comparison with state of the art methods and we found that proposed method is performing better than other existing methods in terms of accuracy. 10   1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63

Conclusion and future work
A novel hybrid approach of two piecewise linear models has been developed to extract the features from the biomedical signals. The main idea behind the two piecewise linear models is to morph the signals in such a way that signal should become simple and smooth but at the same it must retain the important characteristics of the sleep states in it. Different time domain and 320 frequency domain features are extracted, and these features are combined to construct final feature vector. Features are classified by using KNN classifier on long data of CHB-MIT polysomnography database. Proposed algorithm achieved an average sensitivity, specificity, accuracy and false alarm rate of 98.35% and 97.32%, 96.96%, 0.029 respectively for two randomly picked classes, 96.62% and 97.10%, 93.94%, 0.030 for randomly picked any 4 classes, 96.13% and 98.33%, 93.84%, 0.016 for all 325 six classes, which is higher so far than state of the art methods. In future algorithm will be tested on very long data of different databases. In this algorithm we have used three biomedical signals which may slow down the speed of the system instead of two or less signal being used under this method. Therefore in near future we will try to use only two or less signals with different set of features from different signals so that further results can be improved in an more efficient way. In 330 future, we plan to use EEG and blood signal where Franklin system may be used on EEG and some time domain features can be extracted from blood signal.