3.2.1. Signal Acquisition

The brain signals monitored are alpha waves, which, as mentioned above, is the prominent EEG wave pattern in awake adults while having eyes closed in the frequency range of 8–13 Hz. Generally, EEG-BCIs based on rhythms like alpha waveforms are less sensitive to artifacts than other types due to the fact that signal monitoring is limited in thin frequency bands. For this reason, high signal-to-noise ratio (SNR) is achieved [12].

Gold-plated electrodes were placed on the scalp of each one of the subjects that participated in the experimental procedure, according to the 10–20 system (displayed in Figure 2) at positions O1 and O2. The specific positions were chosen because, although alpha rhythms can be also generated in other parts of the brain, they are considered to exhibit greater amplitude in the posterior part of the brain, specifically at derivations O1 and O2 [26]. The reference electrode was placed on the left earlobe (A1), while the ground electrode was placed on the right earlobe (A2). In this way it is feasible to monitor alpha brainwaves.

As it was abovementioned, the amplitude of alpha brainwaves diminishes when subjects open their eyes. This is called *alpha blocking phenomenon*. By taking advantage of this phenomenon, subjects can form n-bit binary sequences by opening or closing their eyes in 2-second intervals. Each bit interval is designated by an acoustic cue.

Moreover, since this is a synchronous BCI, a button has to be pressed for the recording procedure to start. Increased alpha activity (eyes closed) corresponds to a binary '1', while decreased activity (eyes open) corresponds to a binary '0'. As a proof of concept, 4-bit binary sequences were selected to demonstrate the e ffectiveness of this system. In total, 4 control signals were designated for 4 robotic movements as it can be seen in Table 1.



#### 3.2.2. Preprocessing and Feature Extraction

In order to extract the desired alpha brainwaves from the EEG signals, filtering was applied. More specifically, a second order IIR notch filter, having a quality factor Q equal to 35, was applied in order to remove mains frequency (50 Hz).

Consequently, the signals were further filtered by using a Butterworth IIR bandpass filter with cuto ff frequencies of 5 and 15 Hz. The maximum loss in the passband was found to be equal to 0.1 dB. Similarly, the minimum attenuation in the stopband was measured to be equal to 30 db. The SciPy Python library was used for the design and application of the filters.

A typical sample of the signal filtering process performed is indicatively depicted in Figure 5. Specifically, the top graph shows the unfiltered signal acquired from the O1 position on the scalp of a subject, which gives the command for a 'left' movement of the robotic vehicle. As aforementioned in Table 1, the corresponding binary sequence is 1100 and this is why the signal amplitude is higher during the first half of the signal duration and lower during the last half. The middle graph of Figure 5 illustrates the signal filtered via the use of the notch filter while the bottom graph shows the signal further filtered with the bandpass filter.

Since alpha wave blocking is the reduction of alpha waves' amplitude, this change can be measured by transforming the EEG signal from the time domain to the frequency domain. This is achieved by computing the Discrete Fourier Transform (DFT) of the signal using the FFT algorithm. The resulting amplitudes for the alpha wave frequency range are then summed. This process is repeated 4 times for each individual control signal; this is because control signals comprise of 4 2-second recording intervals.

**Figure 5.** From top to bottom: Unfiltered electroencephalography (EEG) signal, EEG signal after being filtered with a 50 Hz notch filter, and final EEG signal with additional 5–15 Hz bandpass filter application.

Min-Max normalization is used to scale the features in the range of [0, 1], which are then saved as a dataset. The resulting feature vector consists of 8 amplitude sums, 4 for each channel (O1, O2). A total of 256 feature vectors are contained within the dataset. A visualization of an example feature vector for the movement "left" is depicted in Figure 6, where there are 8 different values, 2 for each bit. It is fairly easy to distinguish each individual bit value; in this case '1100'.

**Figure 6.** Bar chart showing the normalized sum of the FFT amplitudes for each EEG channel.

#### 3.2.3. Classification and Translation

The classifier utilized for this research is aMultilayer Perceptron (MLP) neural network. This selection was made because MLP neural networks constitute a very popular machine learning technique and there

is an abundance of successful applications of MLP neural networks in EEG signal classification and BCI research [27,28].

The classifier built consists of an input layer with 8 neurons, since the feature vector contains 8 amplitude sums, 4 for each channel. Furthermore, there are 4 neurons in the output layer because there are 4 available classes (forward, reverse, left, and right). Moreover, there are 2 hidden layers, each one consisting of 100 neurons.

The number of hidden layers and neurons was determined by a trial and error procedure. Specifically, 1–3 hidden layers were considered. In addition, for each layer the number of neurons examined was 20–200 with a step of 20. In total, 175 different network configurations were considered. It was concluded that a2 hidden layers network with 100 neurons in each layer achieved the desired performance in terms of classification accuracy. A graphical depiction of the classifier built is illustrated in Figure 7.

**Figure 7.** Structure of the neural network built.

The activation function for the hidden layers is the Rectified Linear Unit (ReLU). The advantages of ReLU include increased training speed and less suffering from the vanishing gradient problem [28]. The formula for ReLU is

$$RelLU(\mathbf{x}) = \max(0, \mathbf{x}).$$

As for the output layers, the sigmoid function was used, which is given by the formula:

$$\sigma(\mathbf{x}) = \frac{1}{1 + e^{-\mathbf{x}'}} $$

which bounds the output of each layer in the range of [0, 1]. This means that each neuron in the output layer produces probabilities of the input being one of the 4 commands. The command with the highest probability is selected.

The loss function used to measure the prediction error of the network during training is binary cross-entropy [29], which is widely used in binary classification problems. It is defined as

$$\mathcal{L} = \frac{1}{N} \sum\_{n=1}^{N} [y\_n \cdot \log \hat{y}\_n + (1 - y\_n) \cdot \log(1 - \hat{y}\_n)].$$

where *N* is the number of samples, *yn* is the target output, and *y*ˆ*n* is the predicted output. Finally, the optimization algorithm used to minimize the prediction error by adjusting the weight of each neuron is Adam, using the default hyperparameter values, as described in [30]. All models were trained in TensorFlow [31], using the Keras API [32].

In Figure 8 the neural network model training and validation loss is displayed. It can be distinguished that training could take place for a smaller number of epochs, since the loss is at an already acceptable value at around 25 epochs. The data used for validation is 40% of the total data.

**Figure 8.** Training and validation model loss.

#### **4. Results and Discussion**

The performance of the developed system was evaluated by using both offline and online data which were gathered through a series of experimental tests performed in which 12 healthy subjects participated.

#### *4.1. Evaluation with O*ffl*ine Data*

For the offline evaluation, the system was tested by using prerecorded data gathered from the same subjects used for recording the training data. Specifically, a small testing dataset of 50 feature vectors representing different movements was used. The neural network classified all of the movements correctly.

## *4.2. Real-Time Evaluation*

After evaluating the system on offline data, a real-time performance analysis was carried out by using six female and six male subjects aged 20 to 28, and two female and two male subjects aged 32 to 40 years. The specific subjects were different from those that were used for the classifier training and offline evaluation. For this purpose, an experimental process was carried out. The subjects were instructed to move the robot in the following order: forward, reverse, left, and right consecutively.

Each one of the 12 subjects was briefed shortly on how the BCI works and how to issue each movement command to the robot. A small number of trial runs were performed for the subjects to ge<sup>t</sup> acquainted with the procedure. In total, 40 experimental tests were carried out. The total number of commands issued was 480.

The results of the experimental procedure showed that lowest classification accuracy achieved among the subjects was 85% while the highest one was 97.5%. The overall accuracy for all commands was 92.1%. The confusion matrix for the total number of commands considered for classification is illustrated in Figure 9, where green diagonal cells correspond to commands that are successfully classified, the red cells correspond to incorrectly classified commands, the gray column on the right displays the precision and false recovery rate of the classifier, the gray row in the bottom expresses the recall and the false negative rate of the classifier, and the blue cell displays the overall accuracy.

**Figure 9.** Confusion matrix for all issued subject commands.

Next, for analysis purposes, the experimental results were studied according to the gender and the age of the subjects that participated in the experimental procedure.

Specifically, the results were first grouped and analyzed separately for each gender. The confusion matrices for the female subjects and the male subjects are depicted in Figures 10 and 11, respectively, where it is shown that the female subjects had a 1.6% higher classification accuracy compared to the male subjects (92.9% to 91.3%).

**Figure 10.** Confusion matrix for female subjects.

**Figure 11.** Confusion matrix for male subjects.

Next, the experimental results were grouped and analyzed according to the age of the subjects. The first group contains the results that refer to the eight subjects aged between 20 and 28 years and the second one the results derived by the four subjects aged between 32 and 40 years. The confusion matrices for the group 20–28 and the group 32–40 are depicted in Figures 12 and 13, respectively, where it is shown that these two groups have almost the same precision accuracy (92.2% for the subjects aged 20 to 28 and 91.9% for the subjects aged 32 to 40).

**Figure 12.** Confusion matrix for ages 20 to 28.

**Figure 13.** Confusion matrix for ages 32 to 40.
