Keywords

1 Introduction

The electroencephalogram (EEG) signal is originated by neurons activities recorded as fluctuations in electric differential potentials obtained from several areas and specific points on the human brain. Commonly, EEG has been used for medical research and medical applications, but in last years there has been a substantial perspective to use it for non-medical brain–computer interface applications like device control, tools for education, and entertainment industry. The raw EEG signal is usually contaminated by artifacts from different sources such as the heartbeats, eyes blinks, muscle activities, and noise from electrical equipment [1]. Detection of these artifacts is often an important subject in EEG research. Commonly, when electrodes are positioned on central scalp zones containing mainly brain activity, temporoparietal sites that may contain muscle artifacts and frontal sites that may carry strong blinks, eye movement, and other muscle artifacts [2]. Blind source separation (BSS) methods, like independent component analysis (ICA) and canonical correlation analysis (CCA), have also been proposed for EMG artifacts detection and removal [3,4,5]. Such methods, however, require multi-channel data and long data epochs to produce important results.

The computational complexity is another characteristic that difficults the choice of ICA or CCA for artifact detection in applications that require real-time implementations [6].

Artificial intelligence and machine learning methods, such as neural networks and vector support machines (SVM), are also widely used in the process of extraction and classification artifacts [7, 8]. Although these methods have been giving very good results, they require a long training process of the network and a large number of standard signals, which must be collected from accredited sources, and which will serve as a reference for their optimal operation, in addition to requiring greater computational capacity.

The proposed algorithm correctly extracts and classifies two EMG artifacts of interest (jaw clench and raising eyebrows), with an accuracy of 90%, allowing its use in real-time processing, due to its light computational load, simplicity of implementation and its use with EEG sensors of low cost and a single active channel, promoting the development of multiple applications for brain–computer interfaces (BCI) such as games, manipulation of the computer pointer for people with disabilities of upper limbs, or communication projects in people with disabilities of this faculty. The aim is to detect these two particular artifacts generated by two muscular events: the jaw clenching and eyebrows raising.

The gestures that were made to obtain the artifacts of interest are shown in Figs. 1 and 2, respectively.

Fig. 1
figure 1

Jaw clench artifact gestural

Fig. 2
figure 2

Eyebrows raising artifact gestural

2 Description of the Proposed Algorithm

It is important to indicate that the framework used in this study corresponds to the development of a computational algorithm. Thus, ethical approval for the experiment in this study was deemed unnecessary by the university, since the research was designed to develop a computational framework with the help of a commercial non-invasive sensor that does not represent any health risk. Likewise we consider that the activities undertaken in the research do not pose risks greater than those ordinarily encountered in daily life.

Figure 3 shows a block diagram of the proposed algorithm. Details of each processing stage are described in the following sections.

Fig. 3
figure 3

Block diagram of the proposed algorithm

2.1 Signal Acquisition

The signals were acquired using an economic BCI mindwave mobile headset from Neurosky. This device is composed of a headset, an ear clip, and a sensor arm. The dry electrode is on the sensor arm which is placed in frontage. According to [9] the 10–20 international system of EEG electrode placement on the human head, this position is around corresponding to the Fp1 position shown in Fig. 4. The reference and ground electrodes are on the ear clip at A1. The diadem also has a Bluetooth module that sends the signals to the computer at a sampling frequency of 512 Hz.

Fig. 4
figure 4

Position of mindwave mobile headset electrodes on the 10–20 international system of electrode placement. Fp1–A1 electrodes

2.2 Preprocessing Signal

The aim at this stage was to condition the signals to increase precision in the extraction of characteristics.

Unwanted noise components (coming mainly from the 60 Hz power grid) are removed for signal improvement. For this purpose, an infinite impulse response IIR Butterworth second-order filter with a cutoff frequency of 59 and 61 Hz is used for work like a 60 Hz band stop notch filter. The use of this filter provided the best results in terms of lowering noise and unwanted distortion. The original signal and the filtered signal are showed in Figs. 5 and 6, respectively.

Fig. 5
figure 5

Original signal

Fig. 6
figure 6

Filtered signal with a 60 Hz notch filter

2.2.1 Jaw Clench Detection

For the detection of the first artifact jaw clench, Cooper's algorithm was used, which extracts and classifies, combining the concepts of energy and zero crossings in a single operation. Although this algorithm correctly detects the presence of the artifact of interest, in some cases, it gives false detections, so it is combined with the zero-crossing algorithm, additionally, to rule out the erroneous detections, which are fragments confused by their similarity in features with jaw clench.

2.2.2 Cooper's Algorithm

Step 1. Signal samples are recorded for times of 10 s, and this recording time was chosen for practicality, considering that the signal sample is not so short so that it is possible to perform the gestures, and not so extensive, that it produces a very long processing time. Total samples obtained in 10 s are calculated by applying the following expression:

$$\begin{aligned} N\,{\text{samples}} & = F_{\text{s}} \times T _{\text{record}} \\ N\,{\text{samples}} & = 512\,{\text{Hz}} \times 10\,{\text{s}} \\ N\,{\text{samples}} & = 5120 \\ \end{aligned}$$
(1)

Stage 2. The signal is divided into a certain number of blocks, with a certain number of samples per block. Finally, 15 samples per block were considered, since, and according to experimental research, it provided a favorable total block density for Cooper's histogram analysis. Total epochs are calculated by applying the following expression:

$$\begin{aligned} N\,{\text{epochs}} & = \frac{{N\,{\text{samples}}}}{{{\text{samples}}\,{\text{by}}\,{\text{Epoch}}}} \\ {\text{Samples}}\,{\text{by}}\,{\text{epoch}} & = 15 \\ N\,{\text{epochs}} & = \frac{5120}{15} \approx 342 \\ \end{aligned}$$
(2)

Stage 3. The entire signal is traversed, for each of the 342 blocks, and the Cooper parameter of each block is calculated, applying the following expression with the 15 sample values of the evaluated block:

$$C = \mathop \sum \limits_{m = 0}^{L} \left| {y\left[ m \right].\left| {y\left[ m \right]} \right| - y\left[ {m - 1} \right].\left| {y\left[ {m - 1} \right]} \right|} \right|$$
(3)

where \(y\left[ m \right]\) is the actual discrete sample analyzed and \(y\left[ {m - 1} \right]\) is the precedent sample, and C is the block Cooper value.

Stage 4. Start detector. A starting threshold range of \(u_{i\hbox{min} }\) = 81,100 and \(u_{i\hbox{max} }\) = 90,000 is chosen. This threshold range was used because it was experimentally possible to minimize the error in the detection of the event of interest and avoid considering very high values of the Cooper parameter that are reached by noise or other artifacts but never by the jaw clenching. Cooper value of the current block, [blockcooper], is in this threshold range, the 15 samples of the block are saved in the output vector [clench], which will contain the extracted artifact signal, and the final sample of said block is also saved (15th sample) as the starting sample (“ki”) of the extracted artifact signal.

Stage 5. End detector. An end threshold value of uf = 5000 is chosen. This threshold value was used because it was experimentally possible to minimize the error in the detection of the event of interest considering Cooper’s histogram. It is evaluated if the Cooper value of the block is less than this threshold uf , if it is lower, it is saved as the last block and the algorithm is completed. The 15th sample of the final block is also saved as an end sample of the extracted artifact signal (“kf”). Figure 7 shows jaw clench detection using Cooper's algorithm.

Fig. 7
figure 7

Jaw clench artifact classification and Cooper's histogram

2.2.3 Zero-Crossing Density Algorithm

Stage 1. The previously extracted fragment is divided into a certain number of blocks, with a certain number of samples per block. Finally, 15 samples per block were considered, since, according to experience, it provided a favorable total block density for the analysis of the calculation of zero crossings.

Stage 2. The entire fragment is traversed, for each of the samples of the signal, and the sign of the present sample is evaluated with the sign of the previous sample, to verify if there is a change of sign between two continuous samples. If this condition exists, it is counted as zero crossing, causing the density to increase by a value of two. All this is done according to the following expression:

$$Z = \mathop \sum \limits_{m = 0}^{N - 1} \left| {{\text{sign}}\left[ {y\left( m \right)} \right] - {\text{sign}}\left[ {y\left( {m - 1} \right)} \right]} \right|$$
(4)

where \(y\left( m \right)\) is the actual discrete sample analyzed, \(y\left( {m - 1} \right)\) is the precedent sample, \(N\) is the total samples, and \(Z\) is the zero-crossing density value.

Stage 3. Classification or discard. A decision threshold value of Uz = 150 is chosen. This threshold value was used because it was experimentally possible to minimize the error in the detection of the event of interest. If the value of zero crossings of the current fragment is greater than the “Uz” value, the start samples are saved (“Ki”) and end (“kf”) to delimit the artifact, otherwise the fragment is discarded.

2.2.4 Eyebrows Raising Detection

For the detection of the second “raising eyebrows” artifact, the algorithm of calculation of energy by blocks of the signal was used, which extracts the possible fragments that contain the artifact of interest. In the case of this detection, the characteristic is that it has very high energy values in the peaks, and a minimum value of zero crossings, unlike the first artifact that has high values of zero crossings, and low energy levels.

Figure 8 shows two original raising eyebrows artifacts registered by Neurosky mindwave headset in two different times.

Fig. 8
figure 8

Original “eyebrows raising” artifacts signal recorded with Neurosky mindwave headset

2.2.5 Energy Calculation Algorithm Per Signal Blocks

Stage 1. Steps 1 and 2 of the Cooper's algorithm are performed.

Stage 2. The entire signal is traversed for each of the 342 blocks, and the energy value of each block is calculated. This calculation is performed through the following expression:

$$E_{i} = \mathop \sum \limits_{n = iN}^{iN + N - 1} x^{2} \left( n \right)^{{}}$$
(5)

where \(x\left( n \right)\) is the discrete sample analyzed, \(i\) is the block number, \(N\) is the block total samples, and \(E_{i}\) is the energy of the block.

Stage 3. Start detector. A start threshold value of ui = 1.5e8 was chosen. This threshold value was finally used because it was experimentally possible to minimize the error in the detection of the event of interest after 10 variations, and due to the high energy value of the present artifact in the peaks. If the energy of the current block exceeds this starting threshold, the 15 samples of the block are stored in the output vector [eyebrow], which will contain the possible extracted artifact signal, in addition, the final sample of said block is saved (15th sample) as a start sample of the extracted artifact signal. The peak width counter is increased for subsequent evaluation that will serve to validate the extracted segment.

Stage 4. End detector. An end threshold value of uf = 0.3e8 was chosen. This threshold value was finally used because it was experimentally possible to minimize the error in the detection of the event of interest after 10 variations. If the energy of the block is less than this end threshold, it is saved as the last block of the extracted signal.

Stage 5. The peak width is evaluated if it is less than a threshold width of 150. This value was considered because the minimum peak width for a rapid brow lift is approximately 160 samples. If it is smaller the extracted signal is discarded, otherwise the algorithm culminates. The 15th sample of the final block is also saved as an end sample of the extracted artifact signal if the discard is not performed. Figure 9 shows eyebrows raising artifact detection.

Fig. 9
figure 9

“Eyebrows raising” artifacts detection

3 Results

To evaluate the proposed algorithms, both the eyebrow lift detection and mandibular pressure detection, independent tests were performed to validate the accuracy in detecting these events. Placing and performing the Bluetooth pairing of the Neurosky sensor with the desktop computer and the recording application, made in MATLAB, we made recordings of 10 s, time that was considered adequate to be able to perform one of the gestures with tranquility. After each recording, the recorded signal was analyzed to detect the gesture made. With the results obtained, Table 1 was carried out, and the percentage of error in the detection of each algorithm corresponding to each gestural event was calculated (Figs. 10 and 11).

Table 1 Results of the algorithms precision detection
Fig. 10
figure 10

Detection right rate in eyebrows raising artifact

Fig. 11
figure 11

Detection right rate in jaw clench artifact

The goal of this recordings was a concept and preliminary study for later applications, where tests with individuals will be regulated by the respective ethical committee.

4 Conclusion

In conclusion, the present work provides a possibility to take advantage of jaw clench and raising eyebrows artifacts, to be used as commands in any system that can be controlled, using simple digital signal processing (DSP) algorithms and of easy implementation. As a factor to take into account, it is that conductive gel should be used in the electrode, since it is very helpful in the noise filter of different frequencies that are introduced in the electrode, and that cannot be suppressed by digital filters.

As future work, these artifacts are planned to be used in a brain–interface system to control the computer mouse pointer, very useful for people with disabilities in the movement of their hands and arms to control it.