=Paper= {{Paper |id=Vol-2874/paper27 |storemode=property |title=Comparison of EEG Data Processing Using Feedforward and Convolutional Neural Network |pdfUrl=https://ceur-ws.org/Vol-2874/paper27.pdf |volume=Vol-2874 |authors=Yu Xie,Stefan Oniga,Tamás Majoros }} ==Comparison of EEG Data Processing Using Feedforward and Convolutional Neural Network== https://ceur-ws.org/Vol-2874/paper27.pdf
      Comparison of EEG Data Processing
      Using Feedforward and Convolutional
                Neural Network∗

                   Yu Xiea , Stefan Onigaab , Tamás Majorosa
              a
                  Department of IT Systems and Networks, Faculty of Informatics,
                                University of Debrecen, Hungary
       b
           Techical University of Cluj-Napoca, North University Centre of Baia Mare
                                    yu.xie@inf.unideb.hu

           Proceedings of the 1st Conference on Information Technology and Data Science
                               Debrecen, Hungary, November 6–8, 2020
                                   published at http://ceur-ws.org



                                           Abstract
          EEG signals are the overall reflection of the physiological activities of brain
      nerve cells in the cerebral cortex and scalp. By classifying and processing
      EEG signals, it is possible to identify states that do not require conscious
      activity. This article mainly processes the raw data and uses the multi-layer
      perceptron (MLP) neural network to determine whether the subject’s eyes are
      open or closed and compares the results of the convolutional neural network
      (CNN) network.
      Keywords: EEG, signal processing, MLP neural network, classification, CNN


1. Introduction
Brain-Computer Interface (BCI) is a communication control system established
between the brain and external devices (computers or other electronic devices)
Copyright © 2021 for this paper by its authors. Use permitted under Creative Commons License
Attribution 4.0 International (CC BY 4.0).
    ∗ This work was supported by the Intelligent Embedded Systems research laboratories at the

Faculty of Informatics, University of Debrecen and the Faculty of Engineering, Technical Univer-
sity of Cluj-Napoca, North University Centre of Baia Mare.


                                               279
through signals generated during brain activity [10]. The aim of BCI is to create
a communication link between the human brain and the computer. It provides a
way to transform brainwaves into physical effects without using muscles [11]. In the
decades since the birth of BCI technology, the research on electroencephalogram
(EEG) signals classification methods have always been the driving force for the
continuous development of BCI technology. EEG is a non-invasive acquisition
method in the BCI system [1]. It detects weak EEG signals by placing electrodes
on the scalp and records changes in electrical signals during brain nerve activity.
However, since EEG will be greatly weakened when it travels through the cerebral
cortex to the scalp, the signal-to-noise ratio of the extracted signal is extremely low,
which increases the difficulty of subsequent feature extraction and classification [13].
It is difficult for traditional classification methods to find well distinguished and
representative features to design a classification model with excellent performance.
In recent years, however, the deep learning methods have made itself a great success
in the field of image and speech such as good generalization capabilities, and layer-
by-layer automatic learning of data features [12].
    This study created a convolution neural network that can recognize and auto-
matic extract the features of EEG signals and compare the accuracy of traditional
methods of feature extraction and classification using data from the same public
database. We used PhysioNet EEG data for this project, which are composed of
over 1500 one- and two-minute EEG recordings, received from 109 subjects. The
goal of our work is to explore Fast Fourier Transform (FFT) signal analysis tech-
niques for distinction between two states, eyes open (EO) and eyes closed (EC),
through the detection of EEG activity obtained from eight scalp channels.


2. Methods
2.1. PhysioNet EEG Database
PhysioNet EEG data set are composed of over 1500 one- and two-minute EEG
recordings, received from 109 subjects [3]. They accomplished six different mo-
tor/imagery tasks while the EEGs were recorded from 64 electrodes using the
BCI2000 system. Each volunteers completed 14 trials: two one-minute baseline
runs (one with EO, one with EC), and three two-minute trials of each of the four
following tasks:
   • An object shows on either the left or the right hand side of the screen. The
     volunteer opens and closes the matching fist until the object vanishes. Then
     the volunteer unwinds.
   • An object shows on either the left or the right hand side of the screen. The
     volunteer visions opening and closing the matching fist until the object van-
     ishes. Then the volunteer unwinds.
   • An object shows on either the top or the bottom of the screen. The volunteer
     opens and closes either both fists (if the target is on top) or both feet (if

                                          280
     the target is on the bottom) until the object vanishes. Then the volunteer
     unwinds.

   • An object shows on either the top or the bottom of the screen. The volunteer
     visions opening and closing either both fists (if the target is on top) or both
     feet (if the target is on the bottom) until the object vanishes. Then the
     volunteer unwinds.[8]

   The 64-channel EEG were recorded (each sampled at 160 samples per second) as
per the international 10-10 system (excluding electrodes Nz, F9, F10, FT9, FT10,
A1, A2, TP9, TP10, P9, and P10), as it is shown Figure 1.




                                                         FP1           FPZ        FP2
                                                                        23
                                                         22                           24

                                        AF7                                                           AF8
                                         25         AF3                AFZ            AF4              29
                                                        26              27             28

                           F7                                                                                      F8
                           30           F5         F3             F1         F2             F4         F6          38
                                        31                             FZ                               37
                                                   32             33    34   35             36

                     FT7        FC5                                                                         FC6         FT8
                     39                       FC3            FC1             FC2             FC4                        40
                                    1          2
                                                                       FCZ                       6           7
                                                              3         4         5



               T9   T7          C5            C3             C1        CZ     C2                 C4          C6           T8      T10
               43   41          8             9               10        11    12                 13           14             42   44



                                              CP3            CP1       CPZ   CP2             CP4
                                CP5                                                                         CP6
                     TP7         15           16             17         18    19                 20          21
                                                                                                                        TP8
                     45                                                                                                 46

                                                   P3             P1   PZ    P2             P4
                                        P5                              51                             P6
                           P7           48
                                                   49             50         52             53
                                                                                                        54         P8
                           47                                                                                      55

                                                    PO3                POZ            PO4
                                        PO7             57              58             59             PO8
                                         56                                                           60

                                                         O1                       O2
                                                         61            OZ             63
                                                                        62



                                                                        IZ
                                                                        64



            Figure 1. The 10-10 system with PhysioNet EEG database.


2.2. Data acquisition
A trained neural network will be planning to use to implement real-time classifica-
tion in the future by our own device, which is an Ultracortex Mark IV biosensing
headset from OpenBCI. In this case, only these eight channels were taken into
account that are C3, C4, Fp1, Fp2, P7, P8, O1, and O2.
    Since the data from eight channels original scalp are around two minutes long
with 160 samples per second sampling frequency. In order to increase the number
of samples, we expanded the data cut every 4 seconds as a segment (640 points).

                                                                       281
2.3. Signal analysis by EEGLAB
EEGLAB is an interactive MATLAB toolbox for processing continuous and event-
related EEG, MEG, and other electrophysiological signals [2].
    EEG signals can be analyzed in the frequency domain. We name 8-14 Hz for
alpha, 14-30 Hz for beta, 30-80 Hz for gamma, 1-4 Hz for delta, 4-8 Hz for theta
band, however frequency ranges are lightly dissimilar in various articles [4, 6, 11].
The Power Spectral Density (PSD) of EC and EO for the first eight seconds of the
first volunteer is shown in Figure 2 and Figure 3 respectively. Each colored trace
represents the spectrum of the activity of one data channel. The leftmost scalp
map indicates the scalp distribution of power at 10.3 Hz, which in these data is
concentrated on the occipital regions and parietal midline respectively. The other
scalp maps show the distribution of power at 15.5 Hz and 20.6 Hz. We can see
easily that the alpha wave power is significantly higher in the EC state than in the
EO state with obvious differences in frontal, parietal and occipital regions.




                    Figure 2. Eight seconds window PSD of EC.

    Figure 4 and Figure 5 respectively showed the activity spectrum at O2 position
of EC and EO state. We can see a distinct peak at 8-14hz on Figure 4 compared
to Figure 5. Alpha waves appear when people are awake, quiet and with their eyes
closed. As soon as subjects open their eyes, think, or receive other stimuli, alpha
waves disappear and turn into fast waves. It reappears when the person becomes
quiet again and closes his eyes. This phenomenon is called “alpha blocking” [5]. So
alpha waves are the main manifestation of electrical activity of the cerebral cortex
in awake, quiet and EC state.
    At the same time, alpha wave activities are unstable according to the Figure 4
and 5. When analyzing the same EEG signal, the amplitude of the beta waves are
much less than that of the alpha waves. It may be more reasonable to use beta
waves as an analytical indicator than alpha waves for identifying the EO state.

                                        282
                   Figure 3. Eight seconds window PSD of EO.




                  Figure 4. Power spectrum of EC on channel 8.



Most of the researches [7, 9] focus on the amplitude and power variation of wave in
different states. The study of alpha and beta wave does not involve the correlation
and mutual comparison between the two waves. Therefore, beta waves are added
as the features for comparison in this paper.

                                       283
                  Figure 5. Power spectrum of EO on channel 8.


2.4. Data processing by Matlab
In our case the data processing includes data import, normalization, segmentation,
feature extraction, neural network creation, training and test steps.
    To facilitate the activity classification, the raw data was divided into small
segments (windows). The main challenge in this task is the find the proper win-
dow size. In order to improve the accuracy, we made different degrees of linear
enhancement according to the correlation of each channel. In case of PSD calcula-
tion, multiple FFT window sizes were tested. Windows were overlapping, at each
sample the window contained the current sample and the previous N-10 samples.
Before classification, a 5-Fold Cross-Validation was used for randomly shuffled the
training and testing data set.




                 Figure 6. Used MLP neural network architecture.


    We tested and compared the performance of feedforward MLP networks and
CNN in this step. In case of MLP, training function was Levenberg-Marquardt
(trainlm). We achieved the best results with the two hidden layers network con-

                                       284
tained 12 and 7 neurons using log-sigmoid transfer functions (as shown in Figure 6).
Output layer had only one neurons as it is two states (EO and EC) to be recog-
nized. On the layers the initial weights came from a normal Gaussian distribution.
In the training algorithm the epoch limit was 1000 cycles.
    The advantage of deep learning algorithm classification accuracy is usually re-
flected when the number of sample sets is large enough. And the more complex
the network, the more parameters to be trained, the more training set samples are
needed. Therefore, the high complexity of the network model cannot be pursued
blindly in the design of neural networks. Layers of the used CNN is shown in
Table 1. The raw data were converted to grayscale images and these images were
used as inputs for the CNN. Image size was 64 × 1 × 8 (64 measurement points, 8
channels).

                             Table 1. Structure of CNN.

                  Layer number                Layer type
                         1           Image input layer (64x1x8)
                         2          Convolution layer (13x1 64)
                         3           Batch normalization layer
                         4                    ReLU layer
                         5          Convolution layer (13x1 128)
                         6           Batch normalization layer
                         7                    ReLU layer
                         8          Convolution layer (39x1 256)
                         9           Batch normalization layer
                        10                    ReLU layer
                        11            Fully connected layer (2)
                        12                 Softmax layer
                        13               Classification layer

    In addition to the design of network structure, many hyperparameters still
need to be determined manually in the training process of a CNN classifier. We
created a set of options for training a network using stochastic gradient descent
with momentum.
    We used a mini-batch with 64 observations at each iteration. If the batch size
is set too small, it will be difficult for the network to converge and under-fitting.
If the batch size is set too large, it will result in reduced efficiency or memory
overflow.

                                        285
    Learning rate is a very important hyperparameter in network training. On the
on hand, if the learning rate is set too small the error curve drops too slowly. On
the other hand, too large learning rate will lead to error explosion, and the network
cannot find the correct direction of gradient descent. We reduced the learning rate
by a factor of 0.1 every 10 epochs with 0.2 initial learning rate and set the maximum
number of epochs for training to 50.
    We set L2 regularization to 0.0005. It ensures that feature weights are not too
large, and the processed feature weights are relatively average.


3. Result
All the following experimental results are from the same computer(CPU: Intel Core
i5-7300HQ, RAM: 16 GB,GPU: GeForce GTX 1050 Ti) with MATLAB R2020a.
    Classification model evaluation metric was accuracy, calculated the following
way:
                                     No correct predictions
                        Accuracy =                          .
                                       No all predictions
To determine a proper window size for band power calculation, different window
sizes were used, training and testing were repeated 1000 times to decrease statistical
uncertainty. Used neural network in this case was the 2-layer MLP with 12-7
neurons in hidden layers. The Mean and best accuracy on test data using different
windows are summarized in Table 2.

                    Table 2. Accuracy at different window sizes.

             Window size(samples)      Mean accuracy      Best accuracy
                       20                  84.46%            91.92%
                       40                  84.23%            94.23%
                       60                  81.00%            90.00%
                       80                  80.87%            90.00%
                       100                 80.26%            88.85%
                       120                 79.66%            86.54%
                       140                 78.71%            84.62%
                       160                 78.94%            85.00%
                       180                 78.57%            86.54%
                       200                 78.50%            85.38%


   In case of real-time data processing, we hope to find a window small enough.

                                         286
We found window size of 40 samples a best choice as we are able to identify the
activities of the subjects from the EEG signal in approximately 0.25 second. It is
an acceptable latency and gives significantly better accuracy than other windows.
Therefore, all of the following experiments are based on this window.
    In order to further improve the accuracy of the network, we enlarged the data
set. Each segment has 40 points that overlap the previous segment.
    The best result obtained after enlargement was 96.63% for test data. The
comparison of training time and mean accuracy are showed in Table 3. In Table 3,
the suffix with A represents only alpha waves considered as feature. The suffix
with B represents only beta waves considered as feature. The suffix with A and B
represents the feature combined by alpha waves and beata waves. The suffix with L
represents using expanded data set. All the accuracy results are the average values
of 100 time 10-fold cross-validation.
                Table 3. Comparison of training time and accuracy.

               Type of Neural Network      Traing Time    Accuracy
                       MLP_A                   0.76s        81.95%
                      MLP_A_L                 14.09s        88.47%
                       MLP_B                   0.64         80.46%
                      MLP_B_L                 12.03s        92.66%
                     MLP_A_B                   1.10s        84.23%
                    MLP_A_B_L                  4.25s        94.85%
                         CNN                  4m50s         88.00%
                       CNN_L                  7m14s         91.00%



4. Conclusion
In this paper we proposed two artificial neural network approaches for EO and EC
tasks recognition from EEG data. We used data from 50 volunteers and tried to
recognize their activities with feedforward MLP network and CNN in combination
with different data processing approaches. Our results demonstrated that the de-
termination of the activity from the EEG signal is possible with high classification
accuracy.
    In the case of MLP, the results obtained show that the accuracy obtained using
only alpha or beta waves are not significantly different, but using the extended
data set makes a significant difference. So it would be more reasonable to use beta
wave as an analytical indicator than alpha wave for this this purpose. This can
provide some reference for studying the EEG signal of the subject’s eye state.

                                        287
     We reached the higher accuracy rate and shorter training time of using MLP
instead of CNN for this purpose. Compared with MLP, however, CNN combines
signal preprocessing, feature extraction and classification. It prevents the blindness
and cumbersomeness of EEG signal processing, and it also has a good accuracy rate.
It is essential to produce a CNN construction with high robustness performance
and accuracy rate for EEG signals.
     The data set in this project was subjected to a simple preprocessing (bandpass
filter and the normalized processing) without special processing for ECG, EMG
and noise. The data set itself has much room to improve, and then makes the
accuracy of the model also have great potential for ascension. Due to the limited
research time of the project, more details in parameter adjustment have not been
studied. However, the efficiency of deep neural network models such as CNN is
largely dependent on parameter adjustment. Therefore, the further improvement
of model performance needs to be further improved in parameter adjustment.


References
 [1] F. Carpi, D. De Rossi, C. Menon: Non invasive brain-machine interfaces, ESA Ariadna
     Study 5 (2006), p. 6402.
 [2] A. Delorme, S. Makeig: EEGLAB: an open source toolbox for analysis of single-trial EEG
     dynamics including independent component analysis, Journal of neuroscience methods 134.1
     (2004), pp. 9–21.
 [3] A. Goldberger, L. Amaral, L. Glass, J. Hausdorff, P. C. Ivanov, R. Mark, J.
     Mietus, G. Moody, C. Peng, H. Stanley: Components of a new research resource for
     complex physiologic signals, PhysioBank, PhysioToolkit, and Physionet (2000).
 [4] I. S. Isa, B. S. Zainuddin, Z. Hussain, S. N. Sulaiman: Preliminary study on analyz-
     ing EEG alpha brainwave signal activities based on visual stimulation, Procedia Computer
     Science 42 (2014), pp. 85–92.
 [5] N. Kawabata: Nonstationary power spectrum analysis of the photic alpha blocking, Kyber-
     netik 12.1 (1972), pp. 40–44.
 [6] D. Kučikienė, R. Praninskienė: The impact of music on the bioelectrical oscillations of
     the brain, Acta Medica Lituanica 25.2 (2018), p. 101.
 [7] A. C. Merzagora, S. Bunce, M. Izzetoglu, B. Onaral: Wavelet analysis for EEG
     feature extraction in deception detection, in: 2006 International Conference of the IEEE
     Engineering in Medicine and Biology Society, IEEE, 2006, pp. 2434–2437.
 [8] G. Schalk, D. J. McFarland, T. Hinterberger, N. Birbaumer, J. R. Wolpaw:
     BCI2000: a general-purpose brain-computer interface (BCI) system, IEEE Transactions on
     biomedical engineering 51.6 (2004), pp. 1034–1043.
 [9] G. B. Seco, G. J. Gerhardt, A. A. Biazotti, A. L. Molan, S. V. Schönwald, J. L.
     Rybarczyk-Filho: EEG alpha rhythm detection on a portable device, Biomedical Signal
     Processing and Control 52 (2019), pp. 97–102.
[10] J. J. Shih, D. J. Krusienski, J. R. Wolpaw: Brain-computer interfaces in medicine, in:
     Mayo Clinic Proceedings, vol. 87, 3, Elsevier, 2012, pp. 268–279.
[11] J. Suto, S. Oniga: Music stimuli recognition in electroencephalogram signal, Elektronika
     ir Elektrotechnika 24.4 (2018), pp. 68–71.




                                            288
[12] H. Wang, Q. Su, Z. Yan, F. Lu, Q. Zhao, Z. Liu, F. Zhou: Rehabilitation Treatment of
     Motor Dysfunction Patients Based on Deep Learning Brain–Computer Interface Technology,
     Frontiers in Neuroscience 14 (2020), p. 1038, issn: 1662-453X,
     doi: 10.3389/fnins.2020.595084,
     url: https://www.frontiersin.org/article/10.3389/fnins.2020.595084.
[13] Y. Xie, S. Oniga: A Review of Processing Methods and Classification Algorithm for EEG
     Signal, Carpathian Journal of Electronic and Computer Engineering 13.3 (2020), pp. 23–29.




                                             289