Detection of EEG-Based Eye-Blinks Using A Thresholding Algorithm

— In the electroencephalography (EEG) study, eye blinks are a commonly known type of ocular artifact that appears most frequently in any EEG measurement. The artifact can be seen as spiking electrical potentials in which their time-frequency properties are varied across individuals. Their presence can negatively impact various medical or scientific research or be helpful when applying to brain-computer interface applications. Hence, detecting eye-blink signals is beneficial for determining the correlation between the human brain and eye movement in this paper. The paper presents a simple, fast, and automated eye-blink detection algorithm that did not require user training before algorithm execution. EEG signals were smoothed and filtered before eye-blink detection. We conducted experiments with ten volunteers and collected three different eye-blink datasets over three trials using Emotiv EPOC+ headset. The proposed method performed consistently and successfully detected spiking activities of eye blinks with a mean accuracy of over 96%.


I. INTRODUCTION
Electroencephalography (EEG) signals recorded from the scalp of the brain are in the form of non-stationary electrical potentials, spiking activities due to the oscillatory modulation of the field potential provides a window into the neural activity in the brain [1]. The remaining issue with EEG data analysis is the risk of bias in the findings subjected to distortions, interfering with bioelectrical and electric field signals. For instance, 50/60Hz powerline noise is an example of electrical interferences, bio-signals produced by different internal mechanisms such as Electrooculogram (EOG) generated by the movement of eyes, Electromyogram (EMG) caused by muscular signals of body parts, and Electrocardiogram (ECG) generated by electrical activities of the heart.
EEGs are an effective technology for non-invasive Brain-Computer Interface (BCI) purposes in the field of engineering. Besides, this technology is used in clinical diagnosis and neuroscience research, where the difficulty is still the signal contamination [2]- [8]. In particular, EOG produces distinguishable electric signals as the eyeballs and eyelids, or the retina and the cornea form an electric dipole [9], [10], severely affecting the signal-to-noise ratio (SNR) of the recording EEG data. With that said, eye-blink artifacts can produce false EEG interpretations in clinical diagnosis and neuroscience research. On the contrary, it can be helpful in engineering studies for BCI applications. Therefore, the detection or removal of eye-blink components is essential in any EEG application. Many algorithms for eye-blink detection have been published in the literature. Most of them focus on techniques such as manual inspection for targeted features, using a high number of EEG channels, training a user profile, and recording EOG data with the use of additional electrodes [1], [7], [8], [11]- [14].
In this paper, we aim to present the results of eye-blink identification with an optimal balance between accuracy, speed, and simplicity. In particular, the eye-blink detection algorithm focuses on the computation of correct peak threshold and peak properties. The correct peak identification in the data maximizes the availability of clean signals for analysis and can provide insights into eye-blink duration and eye blink interval for BCI purposes. Overall, we collected three different user EEG datasets containing over 720 eye blinks to test our algorithm. In researches related to EEGs, the mentioned EOG artifact can be further divided into two forms of action: natural eye blink and intentional eye blink. These eye-and-lid movements are mainly determined by the eyelid and not eye movements. During a natural blink, the eyeballs move downward and nasalwards, whereas intentional eye closure has been attributed to upward eyeball deviation (the so-called Bell's phenomenon) as shown in Fig. 1. This action is due to a net positive charge on the frontal lobe of the eye when the eyes are closed, causing a momentary positivity in the most anterior electrodes.

II. MATERIALS AND METHODS
This research has three primary modules: data acquisition, signal pre-processing, and eye blink detection. The main steps of the proposed system of blink detection as shown in Fig. 2, in which the block diagram of the system illustrates the entire process.

A. Data Acquisition
In this paper, all datasets were recorded using an international 10-20 wet EEG system, Emotiv EPOC+ headset with a mix of 16 scalp and forehead electrodes (two of which are for reference, aiding in the noise cancellation). The contact gap between the subjects' scalp and the felt-padded electrodes was bridged by topical application of a conductive saline solution, BioTrue, obtained from Bausch & Lomb. Also, EEG data were logged at a sampling rate of 128Hz with synchronized timestamps using EmotivPRO software, enabling real-time EEG signals transmission from the headset over a wireless channel.
Ten volunteers, full-time undergraduate students, including five males and females with mixed demographics and ages ranging between 18 to 22 years old, participated in our experiments. Upon arrival, an instructor explained the experimental protocols to the subjects and provided them with consent forms and a demographic questionnaire. The subjects informed and consented to the agreement after reading and understanding the EEG experiment protocol. Besides, during all sessions, the subjects were asked to sit comfortably in front of a PC monitor. They were asked to follow commands in a guided, software-instructed environment whereas wearing the headset for the experimental paradigms and the collected EEG datasets as described in Fig. 3.  For the next 24-36 seconds, subjects were asked to perform a single blink only when a green circle appears at the center of the monitor display. Each session consisted of six visual stimuli occurrences in which the subjects are required to perform eye blinks every 4-6 seconds, depending on their preference. As a result, each trial will last approximately 54-66 seconds. Each subject attempted three trials for every experiment. For some experiments and trials, videos were carefully captured and reviewed if data plots show unusual EEG patterns, and actual labels of the eye blinks were annotated to provide ground truths, ensuring unbiased evaluation.

B. EEG Signal Smooth
More often, raw EEG signals will show an overall lowfrequency fluctuation, which increases or decreases in the signal trend over the time of measurement. The contamination can occur as the technique is prone to powerline interference, drift produced at skin/electrolyte/electrode/system interface, which can affect the results of data analysis and interpretation [15]. Hence, removing a linear or polynomial trend from the data helps to focus on changes in the EEG signal about the trend. While trends can be meaningful in some types of data, it also depends on the objectives of the analysis.
In this paper, we only focus on the EOG signal and the results for eye-blink detection. Therefore, trend removal or detrending should yield better insight. De-trending removes an n th degree polynomial trend of the best straight-fit line from the original data. The best straight-fit line or the trend line is then subtracted from the original signal using the following: Eq. (1) returns the coefficients of a polynomial p(x) of degree n that fits the data x. The resulted p(x) is a row vector of length n+1 containing the polynomial coefficients, a, in descending powers. The polynomial fit of order n is then subtracted from the original data x as described in the following equation: Next, a notch filter, which is a combination of low-pass and high-pass filters over a wide bandwidth, is applied to the EEG signal for suppressing a 50 Hz or 60 Hz powerline hum in the system [16]. Notch filter prevents signal, f, only in the range of frequencies between two cut-off frequencies, 1 and 2 , from passing, 1 < < 2 . The transfer function for a standard notch filter is shown in: where ( ) is the transfer function, is the filter natural frequency, also called: central rejected frequency, where = / = 2 : width of the rejected band; ζ is damping factor; Q is the Q-factor where = 2( 1 − 2 )/( 1 + 2 ).
Smoothing is a process by which data points are averaged with their neighbors in a time series. Smoothing has the effect of suppressing high-frequency signals and enhancing lowfrequency signals. Here we used smoothing with a Gaussian kernel with a window length of 100-200 [17]. Eq. (4) shows the formula for Gaussian blur where x is the distance from the origin in the horizontal axis, σ is the standard deviation of Gaussian distribution, a is distribution mean, responsible for distribution shifting along the x-axis.

C. Eye Blink Detection
After smoothing the EEG signal, an algorithm was applied to detect eye-blink artifacts. An eye blink will result in signals with a sharp and visible peak, immediately followed by a valley, both with differently large amplitudes. Therefore, the consecutive detection of the peak and valley is equivalent to detecting a single eye blink. In most cases, many researchers applied this simple and accurate method to detect and remove the artifact. In addition, the method requires the computation of peak or valley thresholds, distances between the blink peaks and valleys. These thresholds are usually a fixed constant per dataset or individual data.
Before running the peak detection algorithm, the resolution of the preloaded data set must be enhanced through 1-D interpolation. Increased resolution helps the algorithm find the peak locations within the timeline more accurately. Moreover, with the proposed algorithm as shown in Fig. 4, a minimum amplitude threshold must be computed as followed: threshold ← datamaxstd/k When blinking either left or right eyes, both AF3, and AF4 electrodes picked up signals from the single-eyed blink at different amplitude levels. Usually, the electrode closest to the blinking eye will draw a voltage. Hence, to determine which eye is active, the differences between the peak amplitudes detected in both electrodes must be compared.
As seen in Fig. 4, we proposed a thresholding method capable of robust detection of eye blinks without training. The algorithm consists of 4 main subroutines dealing with data rejection: (1) infinite data rejection, (2) rejecting data points below minimum height, (3) rejecting data points below peak threshold, (4) rejecting data points below minimum width. The algorithm also detects and rejects negative troughs between inflection points. The resulted index positions and amplitude values of the remaining peaks are computed and compared to one another. This method finds the peaks based on the minimum vertical distance that the signal must descend on either side of the peak before climbing back to a level higher than the previous ones. The algorithm checks all data points to see if any contains values more significant than the predetermined thresholds. The algorithm does not assume the behavior of the data beyond its endpoints, independent of their height. Fig. 5 shows an example of the differences between EEG signals obtained from mentioned experimental protocols, as seen in the figure, from one subject. The figure above is plotted in the time-amplitude domain for AF3 and AF4 channels. It can be seen that the peak amplitudes of forced eye blinks are equivalently the same, all above 5,500 µV in the 1 st case. Based on the 10-20 international system, AF3 and AF4 electrodes are positioned to the left and right sides of the hemisphere, respectively. Hence, the EEG signal obtained from the AF4 channel, on average, picked up more power when only the left eye blinked. The opposite happened to the AF3 channel. Fig. 6 shows a sample of EEG signals before and after detrending. All values of the original signal are returned close to zero. Detrending could remove the linear or polynomial trend; however, it affected the amplitude level of the original signal by over -50%. The next step is to remove the common 50/60 Hz powerline noise from the signal. Fig. 7 shows two troughs at frequencies 50 and 60 Hz, where these frequencies are entirely suppressed from the frequency spectrum of the signal. Fig. 7. The frequency spectrum of EEG data of both eyes blinking at channel AF3 and AF4 after stop pass filtering at 50 and 60Hz.

B. Smoothed EEG Signals
With a Gaussian smooth filtering algorithm over a time window of 100, the sample result is shown in Fig. 8. Fig. 8. Gaussian smooth filter applied to EEG signal when both eyes blinked at channels AF3 and AF4 after signal normalization.
The stages of signal smooth as shown above are necessary to remove noises which aided the detection of peaks of EEG signal for determining states of eyes activities. Fig. 9. Peaks were detected in pre-processed EEG signals at channels AF3 and AF4 when a subject blinked both eyes. Fig. 9 displays a sample result for the blink detection algorithm where peaks representing voluntary eye blinks are circled as shown. In this example, 5 out of 6 peaks were found on each channel, AF3 and AF4, confirming left and right eye blinks t = 30, 35, 40, 45, and 50 s. The algorithm did not confirm the last two visible peaks at t = 60s due to the oneminute data cut-off. Two visible peaks representing involuntary eye blinked during the first 30 seconds when the subject was resting occurred at t = ~8 and ~16 s. The algorithm does not detect these blinks based on the predefined threshold level (shown as two dash-dotted lines on the graph). We then evaluate the algorithm's performance by testing the algorithm against all datasets obtained from the experiments and data with mixed EOG signals. The performance of this algorithm is evaluated using only one metric, accuracy. Accuracy measures the percentage of correctly detected eyeblinks out of total given eye-blinks. Fig. 10 shows the number of eye blinks detected for all ten subjects in each experiment.  Table I below:  Table I shows that the maximum error ranged between ~3-5%. In which the algorithm's performance for left and right eye-blink detections is lower than the performance when blinking both eyes. The average accuracy for the top-3 and worst-3 subjects in all experiments are shown in TABLE I. The difference between the two accuracies for the top-3 and worst-3 is relatively high, over 10%, which confirms nonuniformity within some of the data obtained from subjects. This can be due to the subjects failing to follow commands during the experiments.

C. Detected Eye Blinks with Threshold
Despite a high-performance score of the algorithm, it still failed to detect 25 out of 720 eye-blink samples (<3.5%) for all trials and experiments. The suspected cause might be due to are caused mainly by (1) variation in the asymmetry of eye blinks, (2) subjects' inability to perform independent blink, (3) excessive blinking neurological disorder, (4) subjects failing to follow commands during the experiments, (5) and the invalidity of the assumption of consistent eye-blink patterns within a subject.
In the peak thresholding approach for the detection and removal of eye-blink artifacts in EEG studies, the algorithm's accuracies for toolboxes' Blink' (by M. Agarwal and R. Sivakumar) [18] and 'BLINKER' (by K. Kleifges and colleagues) [19] are 72-93% and ~98-99%, respectively, regardless of the quantity and sizes of their tested data. For 'Blink,' M. Agarwal and R. Sivakumar used a 4 th order Butterworth low pass filter with a frequency of 10 Hz [18] without referring to the use of detrending or baseline removal technique. K. Kleifges and et al. applied a bandpass filter with the interval [1], [20] Hz before blink detection. They did not entail the threshold algorithm applied for the peak detection approach. Hence, the value for the threshold might be based on observational value only, whereas our threshold value changes depending on the imported data.
From the results of another publication, Markus, Andreas, and Tonio applied for second order low pass digital Butterworth filter at 25 Hz cut-off frequency to reduce highfrequency noise [20]; M. Benda and I. Volosyak applied a bandpass filter between 2Hz and 60Hz for range section of EEG bandwidth and notch filter between 45 Hz and 55 Hz to remove power line noise. Wiener and Savitzky-Golay filters of frame width 15 and ninth polynomial order were also applied [14]. Their result for peak detection showed an accuracy of 89.69%. In our research, removing powerline noise was done at either two ranges of cut-off frequencies, 49-51 Hz or 59-61 Hz to avoid over filtering to prevent the loss of actual EEG signals. Another research conducted by Won-Du Chang and Ho-Seung Cha applied a bandpass filter (Butterworth, first-order) with 2 Hz and 10 Hz cut-offs specifically targeting the frequency of eye blinks. In our research, we avoided considering time-frequency analysis to optimize the computation speed of our algorithm.
Next, we ran the algorithm on a dataset with mixed EOG signals to assess our logarithm's limitation. The result is shown in Fig. 11 below. In Fig. 11, as for the thresholding method, the thresholdbased algorithm cannot tell the differences between peaks of eye blinks and eye movements. The obvious limitation of this method is that it did not consider the waveform shapes of eye blinks and eye movements. Hence, this algorithm can only be used to examine EEG dataset with only eye blink artifacts.

IV. CONCLUSION
In this paper, we studied the problem of eye-blink detection in EEG data based on a thresholding approach. Specifically, we proposed an algorithm looking up EEG data for voluntary eye blinks. The algorithm can function on a single channel EEG accurately. Different EEG datasets were used to evaluate the algorithm's accuracy across various user's blink activities and showed that the algorithm performed with a mean accuracy of over approximately 96%.
The algorithm is designed to operate only in offline mode. Hence, a modification of the algorithm is necessary if an online or real-time implementation is required. This change will broaden the applicability of the proposed method for BCI-based applications. Furthermore, we will consider combining the peak thresholding approach with the classification of the shape of peaks eye movements. Hence, the improved method will be able to overcome the algorithm's current limits, distinguishing various types of eye blinks and eye saccades.