Keywords

1 Introduction

Currents produced within dendrites during brain cells activation can be measured as the nonstationary electrical signal with the help of the device known as electroencephalograph [2]. Recording of such bioelectrical activity is called electroencephalogram (EEG). It was proven that certain characteristics of such signal can be changed by many kinds of mental activity [8]. Systems such as Brain-Computer Interfaces (BCI) are capable of detecting and interpreting those changes. As a result a communication channel between human mind and machine can be established [6]. Because EEG signals are characterized by very low amplitudes and bandwidth mostly located below \(100\,\mathrm{{Hz}}\), they are highly susceptible to contamination by other sources of electrical activity which can occur during their recording. Among most problematic ones are artifacts related with eye movements, muscle noise and electrical line interferences [3]. In general, limiting of their influence proves to be a great difficulty both in clinical use of EEG and in BCI applications [5]. It must be noted that because ocular artifacts tend to mix with EEG rhythms and activity, they can make analysis of those signals not only less effective but, in many cases, impossible [3, 4]. Most commonly implemented approach for dealing with contaminated segments of signal is simply removing them from further analysis [4, 5]. However, such approach leads to a significant loss of data which, is unacceptable in e.g. real-time analysis of EEG signal for BCI applications. Over the years many approaches of filtering out ocular artifacts were proposed and successfully implemented. Most commonly a regression methods are performed in time or frequency domain [5]. Although highly effective, these methods posses a potential weakness for BCI applications which is a requirement of providing at least one regressing channel. Source of the best information about noise is an electrooculogram (EOG) recording, which can serve as reference for regression-based algorithms [5]. Applied in time domain, those methods can be implemented for real-time applications and are capable of producing a very good results in attenuation of ocular artifacts. Among other techniques of detecting and filtering eye movements and blinks are methods based on blind source separation. Those include Principal Component Analysis (PCA) which rely on recorded EEG and EOG signals for calibration [1]. Another approach is to apply the Independent Component Analysis (ICA) for the task of detection and correction of ocular artifacts in EEG [5]. This method, when applied to large number of data recorded over many channels, can produce some highly satisfying results. Additionally, in theory it is possible to implement this approach for online processing but because of its complexity it may not be an effective approach [5].

One very common assumption made for algorithms used for eye movement artifacts detection or filtering is that their causality is not required. That means the output of an algorithm in any given time does not need to depend only on the current and past samples. In addition, many of those methods are not suited for online data processing. Another presumption is that the noise reference is always available. Fulfilling aforementioned assumptions can be very problematic in BCI applications. These systems are created in order to provide a communication channel between human and machines, so that they can be controlled with mental activity [6]. Such action can be considered successful only if the control command can be delivered and executed in a time which is reasonably close to the moment of its transmission. An ideal situation would be to provide a real-time control for the user. In most cases classification of mental activities requires use of data recorded from many channels over different scalp locations. Number of electrodes used for experiment has a high impact on the comfort of BCI systems. Reducing that number should be taken into consideration by any researcher and BCI system designer. Such approach will significantly improve the comfort, practicability and portability of BCI.

In this article a special approach to the correction of ocular artifacts in EEG is proposed. The general idea is to apply filtering methods only to those segments of signal which are marked as contaminated. That way modification and corruption of uncontaminated signal can be avoided. Similar approach was proposed in [7] but the requirement of causality was not fulfilled. In order to achieve said result a method of real-time eye blink and eye movement artifacts detection is presented. Special emphasis is placed on ensuring that proposed algorithms can be applied for real-time applications and that their performance is based only on recorded EEG signal, thus eliminating the need for additional EOG recording.

2 Data Description

Data used in this study was Dataset IIa provided for the BCI competition IV [9]. Database consists of recordings taken from 9 subjects. All available signals were recorded with Ag/AgCl electrodes from twenty-two different locations on scalp. Measurements were performed in monopolar setting with left mastoid serving as reference while right one was used as ground. Recordings were sampled with frequency of 250 Hz and were band pass filtered in range between 0.5 and 100 Hz. For removal of energy network interferences a notch filter at 50 Hz was enabled (for more details, see [9]). Additionally, three electrooculogram channels recordings were provided. These were referenced against left mastoid.

In this study there was used a 40 min long recording taken from subject 2. For a better evaluation of proposed method, signal from electrode position \(F_z\) of standard 10–20 system was taken. The reason for that is the fact that ocular artifacts are most present in frontal and prefrontal regions of a brain [9]. All 303 eye movement related artifacts which were present in chosen signal were manually marked and later used as reference for method’s accuracy evaluation. Exemplary EOG time course with marked ocular artifacts is presented in Fig. 1. To compare efficiency of detection performed on EOG signal with one based on EEG recording, provided central EOG channel was used as a reference [6].

Fig. 1
figure 1

Exemplary EOG time course with marked ocular artifacts

3 Artifact Detection Algorithm

Proposed in this paper method of eye movement related artifacts detection can be described as a thresholding with a varying cut-off level which adapts to changes in characteristics of signal. Conception that laid a basis for this approach is based on an assumption that there is no need for applying filtering to long intervals of EEG signal to eliminate their influence. Ocular artifacts occur randomly throughout the signal for short segments of time. Accurate detection of those time moments would allow to apply filtering only to contaminated parts of signal. That way, loss of important information can be avoided, because there would be no modification of clear recording. Such detection can be qualified as real-time, only if its output is causal, or delayed by a negligible amount of time. Rapid nature of amplitude changes, that accompany EOG artifacts, makes it hard to perfectly detect their beginning without any information about future values of the signal.

This method allows the possibility of setting a small delay \(\delta \) for the output \(y_{ {det}}\), so it is needed to substitute time index n with \(m=n+\delta \). For a given observation of y at time moment n, proposed detection algorithm can be described with following steps:

  1. 1.

    Calculate a squared value of each sample of recorded y signal: \(y_{\textit{pow}}(m)=y^2(m)\)

  2. 2.

    Calculate value of detection function as mean of \(m_1\) previous values of \(y_{\textit{pow}}(m)\): \(d_1(m)= \frac{1}{m_1+1} \sum _{i=m-m_1}^{m}y_{\textit{pow}}(i)\).

  3. 3.

    If previous sample was marked as an artifact \(y_{ {det}}(m-1)=1\) do not change the value of threshold: \(\theta (m)=\theta (m-1)\) and go to point 5.

  4. 4.

    If local maximum was detected change the cut-off level \(\theta (m)\) to its value. Otherwise do not change the threshold: \(\theta (m)=\theta (m-1)\)

  5. 5.

    If \(d_1(m)>B\theta (m)\) mark mth time index as an artifact \(y_{ {det}}(m)=1\). Otherwise \(y_{ {det}}(m)=0\). B is a input parameter of described method.

  6. 6.

    Output \(y_{ {det}}(m)=y_{ {det}}(n+\delta )\) applies for nth time index of signal y.

Detection based on the square of analyzed signal, makes proposed algorithm insusceptible to polarization of eye movement artifacts. Threshold level used in described algorithm is being adjusted on the basis of value of local maxima that occur in smoothed, squared signal. Any method that provides a real-time result can be applied here. In this paper for each sample m it was tested whether the following condition was satisfied:

$$\begin{aligned} d_1(m)<d_1(m-1) \bigwedge d_1(m-2)<d_1(m-1) \end{aligned}$$
(1)

For evaluation of described method results of detection based on EOG and EEG signal were compared with manually marked artifacts. Quality of proposed artifact detection algorithm was evaluated on the basis of two coefficients \(\varDelta _1\) and \(\varDelta _2\) (formulas (2) and (3)).

$$\begin{aligned} \varDelta _1 = n_{{ {start}}}^{{ {real}}} - n_{{ {start}}}^{{ {detected}}} \end{aligned}$$
(2)
$$\begin{aligned} \varDelta _2 = n_{{ {end}}}^{{ {detected}}} - n_{{ {end}}}^{{ {real}}} \end{aligned}$$
(3)

In this paper it was assumed that proposed algorithm should be able to detect artifact’s beginning \(n_{{ {start}}}^{{ {detected}}}\) and ending \(n_{{ {end}}}^{{ {detected}}}\) time moments with some margin. Although a precise detection, where \(\varDelta _1=\varDelta _2=0\) may seem as the best result, in real cases there is always some margin of detection added [4, 5]. Additionally, in order to avoid situation where an interference would not be fully detected, thus resulting in high amplitude artifact around points \(n_{{ {start}}}^{{ {real}}}\) or \(n_{{ {end}}}^{{ {real}}}\), it was assumed that both \(\varDelta _1\) and \(\varDelta _2\) should be greater than 0. For better evaluation of method’s accuracy a number of undetected artifacts, as well as number algorithm’s False Positive detections were taken into consideration. Results of tests performed on both EOG and EEG signal can be found in Table 1. For testing the following parameters were selected:

  • Length of buffer for previous samples \(m_1 = 1000\,\mathrm{{ms}}\)

  • Delay introduced by method \(\delta =37\,\mathrm{{ms}}\)

  • Input parameter of method \(B=3\).

Table 1 Evaluation of artifact detection algorithm

Analysis of achieved results shows that detection of ocular artifacts in EOG signal is very accurate. All 303 artifacts were correctly marked with only one false detection. Additionally proposed method provided a safe margin of detection. On contrary, use of EEG signal produced a significantly less accurate results. With over \(14\,\%\) of undetected trials it cannot be applied for any real life solutions. The reason for such weak performance is the fact, that in EEG recordings a signal-to-noise (SNR) ratio is much higher than in EOG recording. Ocular artifacts, which are here considered to be a noise, are much more mixed into EEG signal, making them very difficult to separate. One solution to that problem would be to artificially decrease SNR of EEG signal. A time-frequency analysis of EEG segment (Fig. 2) shows that ocular artifacts are very strong in frequency band below 10 Hz. Applying a lowpass filtering with cut-off frequency at that level should significantly increase the difference between artifacts and clear EEG. For filtering of EEG signal a simple elliptic Infinite Response Filter (IIR) was used. Because of nonlinear phase characteristic such filters are not common in biomedical measurements. However, because purpose of lowpass filtering in described method is only to ensure a better separability between clear and contaminated time segments, such choice of filter type is acceptable. Amplitude and phase characteristics of used IIR lowpass filter are presented in Fig. 3. Exemplary time courses of EEG signal before and after increasing of ocular artifact’s separability are shown in Fig. 4.

Fig. 2
figure 2

Time-frequency analysis of an EEG segment contaminated with ocular artifacts

Fig. 3
figure 3

Amplitude and phase characteristics of used IIR lowpass filter

Fig. 4
figure 4

Result of lowpass filtering

Even the visual analysis of Fig. 4 confirms that proposed approach led to an improvement of artifact’s visibility. Results of detection performed with mentioned parameters are presented in Table 1. It should be noted that the number of undetected artifacts was significantly lowered to \(2.31\,\%\) with only 7 False Positives and improved detection margin. Performed tests used settings that provided best possible results while introducing the lowest possible delay to the output of algorithm. However it should be noted, that for longer buffer and delay the method is capable of almost perfect detection of ocular artifacts in EEG signal. Exemplary parameters that allow such performance are presented below:

  • Length of buffer for previous samples \(m_1 = 1500\,\mathrm{{ms}}\)

  • Delay introduced by method \(\delta =210\,\mathrm{{ms}}\)

  • Input parameter of method \(B=2.2\).

Results of detection performed with mentioned parameters presented in Table 1 show a very accurate detection witch only about \(1\,\% \) of undetected artifacts and margins \(\varDelta _1\) and \(\varDelta _2\) that are positive for every detection.

4 Artifact Filtering

In this paper a method of filtering eye movement related artifacts from EEG signal was proposed. Its performance was compared to classical approach based on adaptive filtering with EOG signal used as noise reference. A structure of an adaptive filter based on a Recursive Least Squares (RLS) algorithm is shown in Fig. 5. This algorithm requires a primary signal y(n) and secondary signal z(n) to be provided. In this research y(n) was a contaminated EEG recording and z(n) (reference signal) carried the information about unwanted noise. For typical EEG filtering applications an additional EOG channel is used for that purpose. The goal of an adaptive filter is to change coefficients of linear filter so that the reference z(n) will be transformed to resemble primary signal. It is assumed that the corrupted signal \(y(n) = s(n) + z_0(n)\) can be described with two components: desired s(n) and uncorrelated with it noise \(z_0(n)\). Because of said uncorrelation linear filter’s output h(n) will adapt to the noise \(z_0(n)\) present in y(n), so that \(h(n)\simeq z_0(n)\). Subtracting h(n) from y(n) allows to achieve the estimate of uncorrupted signal \(y_f(n) = y(n)- h(n) = [s(n) + z_0(n]- h(n) \simeq s(n) \).

Fig. 5
figure 5

Block diagram of filtration method based on adaptive filtering

Proposed method of ocular artifact filtration is based on adaptive filtering algorithm described above. However, a crucial innovation lays behind a fact that an external EOG reference signal is replaced by lowpass filtered EEG. In Fig. 6 there is a general structure of proposed algorithm. It was shown in this paper that information about ocular artifacts is strongest in bandwidth below 10 Hz. Because in proposed approach artifact filtering is applied only to time segments of signal marked as contaminated, it can be assumed that reference \(y_{ {LP}}(n)\) is not correlated with desired component s(n) of recorded y(n). It must be noted that use of lowpass filter will introduce some latency to the signal. To ensure a reliable filtering signal y(n) should thereby be delayed for d samples. This delay can be, however, covered in \(\delta \) parameter of detection algorithm described in this paper.

Fig. 6
figure 6

Block diagram of filtration method based on adaptive filtering with filtered signal as reference

Performance of proposed methods was tested on modified data used for detector’s evaluation. Firstly, all manually marked artifacts were removed from EEG and EOG signals. That way a two 30 min long time series of uncontaminated signals were acquired, as well as, 303 single ocular artifacts. Then, for each artifact a randomly selected \(20\,\mathrm {s}\) long segment of clear EEG and EOG was selected. For EOG channel, artifact samples replaced original signal. Artifacts inserted to EEG were first downscaled 3.3 times and then added to the original data. Effectiveness of described filtering algorithms was evaluated using Mean Squared Error (MSE) and Pearson’s Correlation (\(\rho \)) coefficients. Because idea behind proposed approach was to apply filtering only to parts of signal marked as artifacts, both MSE and \(\rho \) were calculated only for those time moments. Comparison of proposed algorithm with classical approach is presented in Table 2.

Table 2 Evaluation of artifact filtering algorithms

Analysis of achieved results shows that both methods are capable of reconstructing EEG signal satisfyingly. It should be noted that use of EOG recording as reference signal allowed almost perfect artifact correction. However, although noticeably weaker in performance, proposed approach with filtered EEG signal used as reference produced a satisfactory results while, in the same time, eliminating the need for providing an additional EOG recording.

5 Conclusions

Method of detecting artifacts proposed in this research allowed to achieve a highly satisfying results. It was shown that the detector is capable of detecting ocular artifacts both in EOG and EEG signal. Achieved results are characterized by a small number of undetected artifacts and False Positives. Additionally, for EOG and filtered EEG signals, algorithm ensured a safe margin of detection. That way avoided is situation were artifact is not fully detected, resulting in some high-amplitude peaks being still present in signal. Proposed approach of filtering eye movement related artifacts and reconstructing EEG signal performed satisfactorily during evaluation. It must be noted that in general MSE and Pearson’s Correlation scores of this method were lower than for approach with EOG channel used as reference. However, based on the experience of this paper’s authors, use of as few as even one additional electrode required for EOG measurements may highly decrease the comfort of the BCI system usage. Taking that into consideration, steps of eliminating that problem should be taken by all BCI system designers. Solutions proposed in this paper allowed to deal with that inconvenience while, at the same time, maintaining a very satisfactory accuracy of artifact detection. Although methods described in this research focus on a single channel applications, it is possible to apply them to a multichannel EEG recordings. However, as the influence of eye movement related signals tend to decrease with the increase of the distance from their source, it is suggested to perform a detection on a recordings acquired from locations closer to a frontal and prefrontal regions of brain such as \(F_{z}\), \(F_{p1}\) or \(F_{p2}\) of standard 10–20 system. Because those signals contain more information about noise than others, such approach will ensure a more accurate performance of proposed method. Results of such detection will apply to all EEG signals, recorded from different scalp locations. In order to provide a more efficient detection of ocular artifacts beginning, proposed method needed to introduce a delay to signal’s output. Importantly, as that delay does not exceed \(37\,\mathrm {ms}\) (apart from one proposed setup) it can be considered as negligible. Considering that most of the commonly used detection algorithms rely on an offline processing, this feature is a huge improvement and holds a significant advantage for real time BCI applications.