# Automatic EOG and EMG Artifact Removal Method for Sleep Stage Classification

Ali Abdollahi Gharbali, José Manuel Fonseca, Shirin Najdi, Tohid Yousefi Rezaii

► To cite this version:

Ali Abdollahi Gharbali, José Manuel Fonseca, Shirin Najdi, Tohid Yousefi Rezaii. Automatic EOG and EMG Artifact Removal Method for Sleep Stage Classification. 7th Doctoral Conference on Computing, Electrical and Industrial Systems (DoCEIS), Apr 2016, Costa de Caparica, Portugal. pp.142-150, 10.1007/978-3-319-31165-4_15 . hal-01438238

HAL Id: hal-01438238

https://inria.hal.science/hal-01438238

Submitted on 17 Jan 2017

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
Automatic EOG and EMG Artifact Removal Method
for Sleep Stage Classification

Ali Abdollahi Gharbali¹,², José Manuel Fonseca¹,², Shirin Najdi¹,² and Tohid Yousefi Rezaii³

¹ Computational Intelligence Group of CTS/UNINOVA, 2829-516 Caparica, Portugal

² Faculdade de Ciências e Tecnologia, Universidade Nova de Lisboa Campus da Caparica, Quinta da Torre, 2829-516 Monte de Caparica, Portugal

³ Faculty of Electrical and Computer Engineering, University of Tabriz, Tabriz, Iran
{a.gharbali, s.najdi}@campus.fct.unl.pt, jmrf@fct.unl.pt, yousefi@tabrizu.ac.ir

**Abstract.** In this paper, a new algorithm is proposed for artifact removing of sleep electroencephalogram (EEG) with application in sleep stage classification. Rather than other works which used artificial noise, in this study real EEG data contaminated with electro-oculogram (EOG) and electromyogram (EMG) are used for evaluating the proposed artifact removal algorithm's efficiency using classification accuracy. The artifact detection is performed by thresholding the EEG-EOG and EEG-EMG cross correlation coefficients. Then, the segments considered contaminated are denoised by normalized least-mean squares (NLMS) adaptive filtering technique. Using a single EEG channel, four sleep stages consisting of Awake, Stage1 + REM, Stage 2 and Slow Wave Stage (SWS) are classified. A wavelet packet (WP) based feature set together with artificial neural network (ANN) are deployed for sleep stage classification purpose. Simulation results show that artifact removed EEG allows a classification accuracy improvement of around 14%.

**Keywords:** Sleep stage classification, Wavelet packet, Adaptive filtering, Artifact removing, Artifact detection.

# 1 Introduction

Sleep is an essential part of a human's daily life that significantly affects his/her health, productivity, mental and moral states. Therefore, the diagnosis of sleep related disorders is of great importance in sleep research. Sleep scoring with the use of polysomnographic (PSG) recordings is one of the principal requirements of diagnosis procedure of sleep disorders. PSG recordings include electroencephalogram (EEG), electromyogram (EMG), electro-oculogram (EOG), electrocardiogram (ECG), snoring and other physiological signals to detect body movements. Currently sleep scoring is mainly done by a domain expert who visually analyses PSG data, diagnoses and prescribes treatment. However, this process is time consuming, tedious and highly subjective. Therefore, several algorithms for automatic sleep scoring have been proposed to assist the expert and increase the reliability of the results [1].
EEG is widely adopted for the automatic detection of sleep stages and neuronal activity evaluation during sleep. However, EEG is usually contaminated with several artifacts such as power line noise, EMG, EOG and electrode movements. Removal or attenuation of the noise and unwanted signals is a prerequisite for most of the EEG signal processing applications. The presence of artifacts makes the EEG analysis difficult, since it may introduce spikes that can be confused with original EEG trend decreasing the reliability of the subsequent processing stages.

The basics for the artifact removing are diverse and are closely related to the specific application in which the algorithm is going to be used. A commonly used method for avoiding artifacts is rejecting the contaminated segments of the recorded EEG [2]. This method although simple, results in huge data loss. Instead, denoising the contaminated EEG segments would not only preserve the amount of data, but also would probably contribute to the increase of accuracy in the automatic sleep stage classification [3]. Following this idea, an extensive number of studies have tried to extract the clean EEG out of the contaminated recording in different research areas but still no optimal method is agreed upon [4].

Considering the fact that nowadays portable devices for patient monitoring and automatic sleep stage classification could be a helpful assistance for experts on the analysis of sleep signals, the main motivation for the current work is the lack of a systematic method for automatic artifact detection and cancellation which leads to an improvement in the automatic stage classification accuracy compared to the original acquired data. In view of this gap, the following research question emerges:

*What would be a suitable methodology to detect, identify and remove the EOG and EMG artifacts from EEG in EEG-based sleep analysis, so that the overall artifact level is decreased and the automatic sleep stage classification accuracy is positively influenced?*

In the rest of the paper we will try to answer this question. The paper is organized as follows: Section 2 explains how the proposed automatic artifact removal system can benefit cyber-physical systems. Section 3 gives a brief overview of how EEG artifact removal problem is treated in the literature. Section 4 provides detailed description of the proposed algorithm, and simulation results. Section 5 presents the results discussion and Section 6 finalizes the paper with the conclusions and future work directions.

## 2 Relationship to Cyber-Physical Systems

Cyber-physical systems (CPS) are an emerging technology that attracted a lot of attention in recent years. CPS can be regarded as the next generation computing systems that monitor, coordinate, control and integrate communication and computation abilities to interact with physical systems [5]. CPS are assumed to have a wide range of applications in several areas including defense, transportation, agriculture, energy, healthcare, etc.
In the healthcare area there are currently a limited number of CPS available (such as bedside monitors) and many of their components still work isolated. With the extensive use of CPS, all these components will be integrated to a networked closed loop system together with the human [6]. Wearable health monitoring systems, that allow the subject to continue normal life while his/her vital signs are recorded and analyzed, are a good example of such solutions. In most of the cases a whole night PSG signal is necessary for diagnosing a sleep related problem. This data is usually recorded in a hospital or sleep clinic while the change of sleeping environment and noise may distract the subject and induce significant alterations in the recorded data. Medical CPS like wearable sleep monitoring systems seem to be the perfect solution for recording whole night data while the subject is saved from any change in the sleeping environment. The medical data recorded this way is the main indicator of the subject's health status and its reliability is very important for further signal processing. Therefore, denoising of biological data is one of the most important requirements for improved medical CPS [7], [8]. This work is developed in such a context to support the relation between CPS and sleep monitoring.

## 3 State of the Art

EEG is mainly intended for recording cerebral activity, yet other extra electrical activities are also recorded. These extra activities are usually considered harmful artifacts that can be either physiological like EOG, EMG and ECG or extra physiological like power line interference. EOG measures are captured mainly by frontal electrodes, but they are strong enough to also affect other electrodes. About the EMG, the degree and type of contamination depends on the contracted muscle, the recording purpose and the environment [9].

Some of these artifacts are easily removed by a finite impulse response (FIR) or infinite impulse response (IIR) filter if their power spectrum doesn't have overlap with the EEG power spectrum. However, EMG and EOG, which have significant power spectrum overlap with EEG are not easy to remove requiring careful consideration [9].

The state of the art in EEG denoising is quite broad. The most classic methods used in the last years are regression (especially for ocular interferences), blind source separation or component base techniques [10] and Wiener and Bayes filtering methods [4]. Also adaptive filtering [4], wavelet denoising [11] and empirical mode decomposition (EMD) [12] are among the most widely used denoising techniques. A great range of studies pay particular attention to the improvement of existing methods or using more objective performance criteria [13].

In the context of sleep stage classification, Estrada et al. [14] proposed a denoising method based on applying a predefined threshold to the wavelet coefficients of noisy EEG with the objective of finding the best threshold defining rule and value. The noisy signal is constructed by adding white noise and 50 Hz power line sinusoidal noise. The coefficients that contribute to the noise components are zeroed out using a threshold discrimination filter. They use Mean Squared Error (MSE) and signal-to-
<figure><img src="image_2.png" /><figcaption>Fig. 1. Flowchart of the proposed algorithm.</figcaption></figure>

noise ratio (SNR) as criteria for evaluating the performance of the proposed de-noising scheme.

# 4 Materials and Methods

Figure 1 shows an overview of the sleep stage classification with proposed sleep EEG artifact removal scheme.

## 4.1 Data

In this study, PSG records of 22 Caucasian males and females with the duration of nine hours each were used from the Sleep EDF Database [15]. Except for a slight difficulty in falling asleep, subjects were healthy and without any medication. All EEG (from Fpz-Cz and Pz-Oz electrode locations), EOG (horizontal) and submental chin EMG recordings were performed with a sampling rate of 100 Hz. All PSGs are divided into 30-seconds epochs and annotated by well-trained technicians according to the Rechtschaffen and Kales (R&K) manual. In this study, Pz-Oz EEG channel, horizontal EOG and submental chin EMG recordings of all the subjects are used.
## 4.2 Pre-Processing

Visual inspection of the data reveals that occasionally there exist one or more consecutive epochs in which the energy of the signal is zero probably due to hardware failure. These epochs are removed in order to eliminate the confusion that they could introduce on the sleep stage classification algorithm.

Following the AASM manual [16] recommendations for the scoring of sleep, the EEG and EOG signals are filtered with a band-pass filter with lower cut-off of 0.3 Hz and higher cut-off of 35 Hz. In this work we use WP based decomposition and reconstruction as a filter for removing unwanted frequency band of physiological data [17].

## 4.3 Artifact Detection and Removal

Conventionally, it is assumed that the measured EEG is a linear combination of cerebral activity with one or more kind of artifacts. Therefore, in this paper, for detecting the EOG and EMG contamination, the filtered EEG, EOG and EMG recordings are divided into 1000-sample segments and then the cross correlation of each EEG segment is calculated with the corresponding EOG and EMG segment. If the absolute value of the EEG-EOG cross correlation coefficients or EEG-EMG cross correlation coefficients is more than threshold 1 or threshold 2 respectively, the corresponding segment will be fed to an artifact removal block which is based on NLMS adaptive filtering. Adaptive filtering [18] has been extensively used in EEG artifact removal algorithms. It uses a recorded reference of the artifact (in our case horizontal EOG and submental chin EMG) to adjust a vector of weights that models the contamination according to an optimization algorithm.

If the thresholding conditions for cross correlation coefficients are not satisfied, the relevant EEG segment will be copied to the output without any change.

## 4.4 Feature Extraction

In order to perform sleep stage classification, the output of the pre-processing block is used for feature extraction. There are five types of main brain waves that can be distinguished by their frequency range. These frequency bands are called Delta (0-3.99 Hz), Theta (4-7.99 Hz), Alpha (8-13 Hz) and Beta (>13 Hz) [16]. Therefore, EEG is conventionally analyzed in the frequency domain. Moreover, EEG is a non-stationary signal and simultaneous time-frequency analysis can be quite useful. In this study, a WP tree with 7 decomposition levels and Daubechies order 2 (db2) mother wavelet is used for feature extraction. Different frequency bands of EEG including Delta, Theta, Alpha, spindle, Beta1 and Beta 2 are extracted according to the scheme proposed in [19]. The following statistical features are calculated for each epoch using the WP coefficients:

1) Energy of the WP coefficients for each frequency band (F1-F6)

2) Total Energy (F7)

3) Mean of the absolute values of WP coefficients for all frequency bands (F8)
4) Standard deviation of WP coefficients for all frequency bands (F9)

5) Energy ratio of various frequency bands (F10 to F14)

F10 is the ratio between the energy in the Alpha band and the sum of the energy in the Delta and Theta bands. F11 is the ratio between the energy in the Delta band and the sum of the energy in the Alpha and Theta bands. F12 is the ratio between the energy in the Theta band and the sum of the energy in the Alpha and Delta bands. F13 is the ratio between the energy in the Alpha band and the energy in the Theta band and F14 is the ratio between the energy in the Delta band and the energy in the Theta band.

## 4.5 Normalization

Features are normalized to standardize their range. Since the range of values of raw EEG varies broadly, to avoid that features with larger numeric values dominate those with smaller numeric values affecting the accuracy of the classification technique, each feature ($x_{ij}$) is independently normalized by applying the following equation:

$$x'_{ij} = \frac{x_{ij} - \bar{x}_i}{\sigma_{x_i}} \qquad (1)$$

where $\bar{x}_i$ and $\sigma_{x_i}$ are the mean and the standard deviation of each independent feature vector $x_i$.

## 4.6 Classification

In this study ANN were used for the classification of sleep stages. The two-layer feed forward network consisting of 14 input neurons, 12 hidden neurons and 4 output neurons for discrimination between the four sleep stages Wake, REM+S1, S2 and SWS is used. A sigmoid transfer function in the hidden layer and a linear transfer function in the output layer were selected. Levenberg-Marquardt training algorithm is chosen.

# 5 Experimental Results and Discussion

The performance of the proposed method was assessed using the six subjects selected from the dataset mentioned in section 4.1. In our experiment for wavelet packet based filtering Daubechies order 20 (db20) was used as mother wavelet. In the artifact detection stage a threshold of 0.5 (Threshold 1) for EEG-EOG cross correlation coefficients and 0.25 (Threshold 2) for EEG-EMG cross correlation coefficients were selected. These thresholds are selected empirically considering highest classification accuracy. Three different result validation approaches including subjective and objective methods were applied.
The cross correlation coefficients for EEG-EOG and EEG-EMG which were detected by thresholding before and after applying the artifact removal algorithm are shown in Figure 2. A significant reduction in the correlation coefficients is noticeable after artifact removal.

Figure 3 and 4 illustrate the cancellation of EOG and EMG artifacts from contaminated EEG segments. It can be seen that the artifacts can be correctly eliminated without distorting the original EEG.

After the completion of the artifact removal stage, the data is fed to feature extraction algorithm. For training the ANN, unlike the more conventional approaches in the literature, which import all the existing stages to the neural network, we used a quantity of training data to be selected out of each patient. This method is suitable for large databases helping on the reduction of the computational complexity of the classifier training stage.

<figure><img src="image_3.png" /><figcaption>**Fig. 2.** Absolute Value of cross correlation coefficients, (a) EEG-EOG before artifact removal, (b) EEG-EOG after artifact removal, (c) EEG-EMG before artifact removal, (d) EEG-EMG after artifact removal algorithm.</figcaption></figure>

<table><caption>**Table 1.** Results of the statistical analysis for comparison of each stage and overall accuracy.</caption><thead><tr><th></th><th>Wake (%)</th><th>REM + S1 (%)</th><th>S2 (%)</th><th>SWS (%)</th><th>Overall (%)</th></tr></thead><tbody><tr><td>Raw</td><td>77.56</td><td>87.08</td><td>74.67</td><td>78.11</td><td>63.70</td></tr><tr><td>Filtered</td><td>79.44</td><td>78.75</td><td>83.26</td><td>90.74</td><td>70.60</td></tr><tr><td>Proposed method</td><td>87.08</td><td>87.25</td><td>87.38</td><td>90.93</td><td>77.80</td></tr></tbody></table>
<figure><img src="image_4.png" /><figcaption>Fig. 3. EOG artifact cancelation from contaminated EEG.</figcaption></figure>

<figure><img src="image_5.png" /><figcaption>Fig. 4. EMG artifact cancelation from contaminated EEG.</figcaption></figure>

In order to assess the effectiveness of our artifact removal algorithm, we studied the sleep stage classification accuracy for raw (after removing zero energy epochs), filtered and artifact removed data. Table 1 shows the results of statistical analysis for comparison of each stage and overall accuracy for all the above-mentioned data. The results are validated using repeated random sub-sampling method which is also known as Monte Carlo cross-validation technique. It is observed that there is an improvement in the performance of the classifier after filtering the data but the best performance is achieved by applying the proposed artifact removal algorithm.
# 6 Conclusions and Future Work

To the best of our knowledge there is a lack of EEG artifact removing studies in the sleep stage classification context that simultaneously removes the EOG and EMG artifact from EEG without rejecting epochs and also evaluates the performance of the classifier for de-noised data. This paper is a contribution in this regard. In conclusion our findings show that the proposed method for artifact cancelation is reliable for sleep stage classification giving a promising accuracy improvement.

Due to the database available at the moment for this research, EOG and EMG channels were utilized for cancellation of their contamination in EEG. The performance of proposed method can be improved in the future using other PSG channels like ECG.

**Acknowledgment.** This work was partially funded by FCT Strategic Program UID/EEA/00066/203 of UNINOVA, CTS.

# References

1. Niedermeyer, E., Silva, F.H.L. da: Electroencephalography: Basic Principles, Clinical Applications, and Related Fields. Williams & Wilkins (1999).

2. Devuyst, S., Dutoit, T., Ravet, T., Stenuit, P., Kerkhofs, M., Stanus, E.: Automatic Processing of EEG-EOG-EMG Artifacts in Sleep Stage Classification. In: IFMBE Proceedings. pp. 146–150 (2009).

3. Croft, R.J., Chandler, J.S., Barry, R.J., Cooper, N.R., Clarke, A.R.: EOG correction: A comparison of four methods. Psychophysiology. 42, 16–24 (2005).

4. Sweeney, K.T., Ward, T.E., McLoone, S.F.: Artifact removal in physiological signals-- practices and possibilities. IEEE Trans. Inf. Technol. Biomed. 16, 488–500 (2012).

5. Wang, J., Abid, H., Lee, S., Shu, L., Xia, F.: A Secured Health Care Application Architecture for Cyber-Physical Systems. 101–108 (2011).

6. Philip, A., Broman, D., Lee, E.A., Torngren, M., Sunder, S.S.: Cyber-Physical Systems - a Concept Map, http://cyberphysicalsystems.org/.

7. Milenković, A., Otto, C., Jovanov, E.: Wireless sensor networks for personal health monitoring: Issues and an implementation. Comput. Commun. 29, 2521–2533 (2006).

8. Haque, S.A., Aziz, S.M., Rahman, M.: Review of Cyber-Physical System in Healthcare. Int. J. Distrib. Sens. Networks. 1–20 (2014).

9. Urigüen, J.A., Garcia-Zapirain, B.: EEG artifact removal-state-of-the-art and guidelines. J. Neural Eng. 12, 31001 (2015).

10. Romero, S., Mañanas, M.A., Barbanoj, M.J.: Ocular Reduction in EEG Signals Based on Adaptive Filtering, Regression and Blind Source Separation. Ann. Biomed. Eng. 37, 176– 191 (2008).

11. Unser, M., Aldroubi, A.: A review of wavelets in biomedical applications. Proc. IEEE. 84, 626–638 (1996).

12. Safieddine, D., Kachenoura, A., Albera, L., Birot, G., Karfoul, A., Pasnicu, A., Biraben, A., Wendling, F., Senhadji, L., Merlet, I.: Removal of muscle artifact from EEG data: comparison between stochastic (ICA and CCA) and deterministic (EMD and wavelet-based) approaches. EURASIP J. Adv. Signal Process. 2012, 127 (2012).

13. Fatourechi, M., Bashashati, A., Ward, R.K., Birch, G.E.: EMG and EOG artifacts in brain computer interface systems: A survey. Clin. Neurophysiol. 118, 480–94 (2007).
148 A. A. Gharbali et al.

14.Estrada, E., Nazeran, H., Sierra, G., Ebrahimi, F., Setarehdan, S.K.: Wavelet-based EEG denoising for automatic sleep stage classification. CONIELECOMP 2011 - 21st Int. Conf. Electron. Commun. Comput. Proc. 295–298 (2011).

15.The Sleep-EDF Database [Expanded], http://www.physionet.org/physiobank/database/sleep-edfx/.

16.The AASM Manual for the Scoring of Sleep and Associated Events - Rules, Terminology and Technical Specifications, http://www.aasmnet.org/scoringmanual/.

17.Wiltschko, A.B., Gage, G.J., Berke, J.D.: Wavelet filtering before spike detection preserves waveform shape and enhances single-unit discrimination. J. Neurosci. Methods. 173, 34–40 (2008).

18.Haykin, S.S.: Adaptive Filter Theory. Prentice Hall (2002).

19.Ebrahimi, F., Mikaeili, M., Estrada, E., Nazeran, H.: Automatic sleep stage classification based on EEG signals by using neural networks and wavelet packet coefficients. Conf. Proc. IEEE Eng. Med. Biol. Soc. 2008, 1151–1154 (2008).