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: Sect. 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 Sect. 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-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.

Fig. 1.
figure 1figure 1

Flowchart of the proposed algorithm.

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 s 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 divide 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. (1)

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

  2. (2)

    Total Energy (F7)

  3. (3)

    Mean of the absolute values of WP coefficients for all frequency bands (F8)

  4. (4)

    Standard deviation of WP coefficients for all frequency bands (F9)

  5. (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^{\prime}_{ij} = \frac{{x_{ij} - {\bar{\mathbf{x}}}_{i} }}{{\sigma_{{{\mathbf{x}}_{{\mathbf{i}}} }} }} $$
(1)

where \( {\bar{\mathbf{x}}}_{i} \) and \( \sigma_{{{\mathbf{x}}_{{\mathbf{i}}} }} \) are the mean and the standard deviation of each independent feature vector \( {\mathbf{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.

Fig. 2.
figure 2figure 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.

5 Experimental Results and Discussion

The performance of the proposed method was assessed using the six subjects selected from the dataset mentioned in Sect. 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 Fig. 2. A significant reduction in the correlation coefficients is noticeable after artifact removal.

Figures 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.

Table 1. Results of the statistical analysis for comparison of each stage and overall accuracy.

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.

Fig. 3.
figure 3figure 3

EOG artifact cancelation from contaminated EEG.

Fig. 4.
figure 4figure 4

EMG artifact cancelation from contaminated EEG.

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.