Analysis of Electroencephalography Signals using Particle Swarm Optimization

Brain computer interface devices monitor the brain signals and convert them into control commands in an attempt to imitate certain human cognitive functions. Numerous studies and applications have developed, because of the researchers' interest in systems in recent years. The capacity to categorize electroencephalograms is essential for building effective braincomputer interfaces. In this paper, three experiments were performed in order to categorize the brain signals with the goal of improving a model for EEG data analysis. An investigation is carried out to detect the characteristics derived from interactions across channels that may be more accurate than features that could be taken from individuals. Many machine learning techniques were applied such as; K-Nearest Neighbors, Long Short-Term memory and Decision Tree in this paper in order to detect and analyze the EEG signals from three different datasets to determine the best accuracy results using the particle swarm optimization algorithm that obviously minimized the dimension of the feature vector and improved the accuracy results. Keywords—Electroencephalographic; k-nearest neighbors; long short-term memory; epileptic seizure recognition; decision tree


I. INTRODUCTION
Brain-Computer Interface (BCI) it is a fast-expanding scientific issue that is attracting the attention of experts from all around the world which utilizing brain activity to transmit orders to an electrical device, BCI developed a new communication channel [1]. Neurologically impaired individuals control electronic gadgets such as dementia, epilepsy and sleeping problems [2]. BCI systems are primarily intended for use by the blind. As defined by the Brain-Computer Interface, Ideally, this should be capable of recognizing human objectives and communicating them to the computer, in which appropriate measures are taken. As a result, there are two types of BCIs: invasive and non-invasive, accordance to the method through which the BCI system measures brain activity. As an example, if the measuring sensors are located in the brain or skull, consider that: The BCI system is characterized as an invasive BCI system. However, if the measuring sensors are implanted on the scalp, but not on the skull, then, it is possible that the findings will be different. The BCI system, for example, is categorized as non-invasive BCI [2] Using non-invasive BCI systems versus invasive systems has the advantage of reducing or eliminating health risks the ethical issues that arise from them, etc. Ordinary personnel are not likely to benefit from invasive approaches [1,3].
Brain signals, signal processing, signal acquisition, application execution, and output feedback are typical components of a BCI system. After being detected and monitored by signal acquisition, pre-processing stages filter electrical brain signals. Feature extraction and classification are among the operations performed in the signal processing phase, Sends necessary commands to suitable devices. while the functioning of these devices, the user may receive some form of feedback (s). The block diagram of a BCI system is shown in " Fig. 1" [3].
The following is a breakdown of the paper: Section II shows the necessary machine learning baseline knowledge, Section III provides required Electroencephalography signals background, Section IV provides detailed description of the used datasets, Section V shows the proposed model, Section VI discuss the evaluation results, lastly conclusion is providing in Section VII.

II. BACKGROUND
In order to do the given task, the BCI device collects brain waves and transfers these waves to the computer system for analysis and processing. It is therefore possible to represent a concept or operate some items using the waves that have been delivered. www.ijacsa.thesai.org

A. BCI Functions
Using Brain Computer Interface apps, users may either be informed of their current condition or provide their own opinions about it. To do the stated task, the BCI system records brainwaves and sends them through computer to a computer system. It is so possible to express an idea or operate an item using the transmitted waves. Brain Computer Interface apps work by either sensing the user's circumstances or by letting the user to express his/her feelings and ideas [4].

B. Control and Communication
Human brain-computer interface (BCI) systems establish a link with the outside world; traditional information transfer mechanisms are no longer needed. Signals from human brains are controlled, as are their silent thoughts. This allows them to communicate and record thoughts and ideas utilizing a variety of various techniques, such as in semantic categorization [5], spelling applications [6], or silent speech communication [7]. Hands-free applications may be enabled by BCIs, machine mind control for human ease and comfort. To carry out a set of orders, they just require the integration of brain impulses, and no physical movement is necessary [8,9,3]. Assistance robots using BCI technology can support individuals with disabilities in their daily and professional life, allowing them to be more involved in community building activities [10].

C. User State Monitoring
BCI applications were aimed towards handicapped users who had communication or mobility problems. Their intention was to supply those users with an alternate communication bridge. Then, later, BCI impacts the universe of healthy individuals as well. It functions as a physiological measurement technique, retrieving and utilizing data regarding an individual's emotional, cognitive, or effectiveness condition. In what is known as passive BCI, the goal of brain signal usage has been expanded beyond commanding an item or providing a substitute for certain functions [11].

III. ELECTROENCEPHALOGRAPHY (EEG)
When synaptic stimulation of neurons dendrites is measured with electroencephalography (EEG), electric brain activity is monitored, the properties of secondary currents, and it is very sensitive to them. EEG recording system comprises of electrodes, A/D converter, amplifiers, and a recording device. Analogue signals are amplified by the amplifiers before being sent to the A/D converter, which allows the information to be digitized more effectively. Finally, the data is recorded and displayed by the capturing device, which may be a computer or something similar. EEG signals are recorded using the electrodes. The International 10-20 system is frequently used for electrodes positioned on the scalp; tThe American Electroencephalographic Society has standardized this method. To determine the electrode placement in the 10-20 system, two reference locations in the scalp are used, the nasion is one of these points of reference, it is positioned at the same level as the eyes on the top of the nose. The inion is the second point of reference, situated in the bony hump at the skull's base. The skull is divided into two halves by the transverse and median planes. The positions of the electrodes are established by designating those sectors at 10% and 20% intervals. Each letter refers to a different area of the brain. Which that The earlobe is represented by the letter A, the central region is represented by the letter C, the nasopharyngeal is represented by Pg, the parietal is represented by letter P, the frontal is represented by letter F, the frontal polar is represented by Fp, and finally the occipital area is represented by letter O [8].
Due to the huge quantity of information collected from each electrode, Continuous EEG data or brain waves might be difficult to analyze. As a field of science, it must be accompanied with a complex collection of terms. Waves, like radio stations, are categorized based on their frequency and, in certain cases, their waveforms. Even though none of these waves are ever generated alone, an individual's state of awareness can cause one frequency range to be much more prominent than others.
In this paper, analysis of some cases to the human states will be applied to detect their mental state, and human emotional feelings and to recognize if they have Epileptic seizure or not by using EEG signals.

A. Mental State
The capability Automatic detection of a human's mental state, if they are cognitive or affective, is helpful for a variety of applications across a wide range of disciplines like robotics, medical care, education, neurology, and so forth. The significance of effective human-machine interaction mechanisms grows in direct proportion to the total number of real-world situations in which smart devices are used, autonomous robots included, can be used. Signals of surface brain activity are one way to connect with machines. These signals, known as electroencephalograms or EEGs for short, Electrode's measure voltage and communicate that information (dry or wet) positioned over a human's scalp. In addition to the standard non-invasive electroencephalography, there is many invasive options that can analyze activities in the brain by implant electrodes directly on the human's skull [11].

B. Emotional Feelings
Independent non-invasive monitoring of emotional states has the potential to be beneficial in a variety of fields, User and device engagement may be enhanced by incorporating human-robot interaction and mental healthcare, Information may be gathered that is not dependent on spoken communication by using augmented reality [12]. Electroencephalography (EEG) technology has become increasingly affordable; brainwave data is becoming more affordable for consumers and researchers alike, selfcategorization without the requirement for an expert. In the raw EEG stream, classification is challenging because of the unpredictability and non-stationary nature of brainwave data. As a result, with feature extraction of data inside a window, stationary approaches such as temporal windowing must be incorporated. Many statistics may be generated from such EEG windows, each with a different classification efficacy depending on the aim. To find important statistics and decrease the complexity of the model development process, feature selection must be done, saving both time and www.ijacsa.thesai.org computing resources throughout the training and classification procedures [12].

C. Epileptic Seizure Recognition
Epilepsy is a neurological condition marked by unexpected and recurring seizures. Epilepsy can affect awareness, perception, feeling, behavior, and physical movement by causing aberrant electrical activity in the brain. During seizures, patients suffer from some symptoms according to the position of the injured brain area. Fortunately, most epileptic seizures are momentary and seldom life-threatening. In 1981, the International League Against Epilepsy (ILAE) supposed that there are two kinds of seizures comprises: a) Seizures that affect virtually the whole brain which called generalized seizures. B) Seizures that begin in the brain in particular part and persist restricted to that region named as partial (or focal) seizures [13].
IV. DATA SETS For many scientists, the phrase "Machine Learning" is synonymous with "Artificial Intelligence," like the ability to learn which is the primary attribute of an entity termed as intelligence. Learning from the human knowledge in order to develop computer systems, is always the goal behind using the machine learning.

A. EEG Brainwave Dataset: Mental State
The Muse Headband sensor was utilized to collect data. Each of the three states -relaxed, focused, and neutral -was recorded for 60 seconds by four persons (2 males and 2 females). We used a Muse EEG headband with dry electrodes to capture the TP9, AF7, AF8, and TP10 EEG placements. To avoid electromyography signal interference, Nonverbal activities requiring little to no movement were assigned. Blinking, despite interfering with the AF7 and AF8 sensors, was neither encouraged nor discouraged from maintaining its natural nature. This was attributed to the blink rate's dynamic relationship with tasks demanding varying levels of attention [14], As a result, the categorization algorithms would take these signal spike patterns into consideration. Additionally, during any of the exercises, the individuals were not permitted to close their eyes. Three stimuli were created to cover the Muse Headband's three mental states: relaxed, neutral, and focused. The individuals were advised to relax their muscles and rest meditates while listening to low-tempo music and sound effects. A comparable test was performed for a neutral mental state, but with no stimulus at all. This test was performed before to any others to avoid the long-term consequences of a mentally calm or focused state of mind. so, during a "shell game," Under one of the three cups, there was a ball, and participants were instructed to find it, which were then exchanged, and the objective was to figure out which cup hid ball. Future work will consist of implementing a standard experiment for each stage in order to properly compare to comparable studies. As a result, erroneous data is not collected; Muse Headband EEG data was automatically recorded for 60 seconds after the stimulation began. The data was seen to be flowing at a fluctuating frequency between 150 and 270 Hz. BlueMuse [15] was employed in order to connect this device to a computer, and Muselsl [16] for converting MUSE signal into micro voltage, as well as to capture and prepare data for feature extraction. " Fig. 2" presentation of EEG data on a real time basis; The TP9 and TP10 (forehead sensors) may be seen blinking. At each point in the data stream, a UNIX timestamp was recorded. (150-270 Hzdown sampled the data to produce a stream frequency that was constant. The EEG locations may be mapped to the observed voltages on the graph. Data has been down sampled before being subjected to feature extraction. Fast Fourier transforms along a particular axis reduced the sample rate to 200 Hz. Len(x) / num * is used to sample the resampled signal, which starts at the same value as x (spacing of x). This is because the Fourier technique assumes that the signal is periodic. Although the frequency range of the EEG sensor is better, this down-sampling is practical since the main energy is focused in the 20-500Hz region.

B. EEG Brainwave Dataset: Feeling Emotions
However, they may be categorized into good and bad categories [18]. Anguish and optimism for the character's survival in a film are two examples of emotions that occur simultaneously. A positive experience shall be defined as one that does not overlap with other pleasant experiences. According to Lövheim's three-dimensional emotional model, the brain's chemical structure corresponds to generalized positive and negative valence states [19]. Each of the model's vertices is labelled A-H in " Fig. 2", further detailed in Table I. Positive and negative emotions can be linked to chemical compositions. Moreover, investigations have shown that chemical composition impacts neural oscillation and, thus, electrical brainwave production [20] because emotions are contained in chemical compositions that impact electrical brain activity directly, they may be categorized using statistical features of the brainwaves generated, according to this study.

C. Epileptic Seizure Recognition Dataset
In the research of epilepsy, either humans or animals are employed as subjects. These signals were collected from the Bonn University in Germany, which is public [21]. There are five full datasets (A-E), each of which has 100 single-channel EEG segments. During every segment's 23.6 second length, there are N=4096 sample points collected. The same 128channel amplifier configuration was used throughout and 12bit A/D resolution, all EEG signals were captured, there were 17,611 samples per second, and the acquisition system's bandwidth ranged from 0.5 to 85 cycles per second. Visual assessment for artefacts like movement of the muscles, eye blinking, etc. a multi-channel EEG recording was selected for these parts. In a waking state with their eyes open and closed, five healthy participants recorded their external surface EEGs. were used to create Sets A and B, From EEG recordings made with depth electrodes, five individuals were used to create sets C, D and E. Sets A and B were recorded in a regular condition of affairs. Recordings in sets D and C were taken from the epileptogenic zone (inter-ictal period) and the opposite hemisphere's hippocampus formation of the brain, respectively. During seizure activity, Set E was recorded (Ictal). " Fig. 3" displays Five sets A to E of electrodes of EEG data were obtained and analyzed [21]. V. PROPOSED MODEL The proposed model in this study was applied on three different datasets of the EEG brainwaves that are mental state, feeling emotions and epileptic seizure recognition datasets (Section IV). As shown in " Fig. 4", the proposed model in this paper consists of five layers; the first layer include the data input that consists of the three datasets, the second layer is the data acquisition layer in which pre-processing steps are applied after the feature extraction phase, then the feature selection layer took the third place in order to categorize and detect the effect of the Particle Swarm Optimization on the model results before and after applying it with three different classifiers which are; Decision Tree (DT), K-Nearest Neighbor (KNN) and Long Short-Term Memory (LSTM) classifiers in the fourth layer and lastly the fifth layer that checks if the evaluation methods satisfy the objective function it generates the output result, while if not, it returns back to the third layer where the PSO take place again and repeats the same steps until it reaches the optimum output.

A. Feature Extraction using Particle Swarm Optimization (PSO)
As a problem of global combinatorial optimization, feature selection decreases the number of features, eliminates noise and superfluous data, and results in classification accuracy acceptable to the user [22]. Machine learning, pattern categorization, and medical data processing, and data mining applications all rely heavily on feature selection. For this reason, a suitable feature selection technique based on the number of characteristics explored for sample classification is essential in order to increase processing speed and prediction accuracy, as well as to prevent incomprehensibility.

B. Evaluation Methods 1) K-Nearest neighbor:
The KNN classifier is a nonparametric instance-based classification algorithm [23]. Training data are merely stored, and no new information is learned because of this kind of learning [24]. During the training phase, these saved values will be needed. In this technique, the nearest-neighbor estimation method is used. As a result of the distance metric, the new instances are categorized based on similarity as shown in Fig. 5. The Euclidean distance function is the most often utilized. Power spectral density data were classified using KNN. Comparing results with the goal value in mean square error estimates. To assess the efficiency of the KNN classifier, different performance metrics were computed [25].  Vol. 12, No. 8, 2021 623 | P a g e www.ijacsa.thesai.org 2) Decision tree: The Decision Tree Classifier is one such approach for multi-stage decision making (DTC). When a complicated problem is divided into subproblems, and then this process is repeated recursively, a decision tree is generated. In a decision tree, each leaf node is given a class label, the root node non-terminal nodes, as well as additional internal nodes, distinct records with various properties based on the attribute testing criteria [26]. An example decision tree structure is shown in "Fig. 6". The decision nodes are the Xvariables. a and b indicate the borders of the attribute boundaries that divide the decision into three tree pathways, and nodes are associated with attributes, Nominal or numerical values are also acceptable. As the leaves of a tree, the Class variables allow the item under study to be classified [27].

3) Long short-term memory (LSTM):
It is a specific type of Recurrent Neural Networks called LSTM (RNN). This type of network has loops, and information is transferred from one loop to another. To utilise RNN for sequences and lists, such as time series, this chain-like character becomes apparent. Long-term dependencies, however, are an issue with conventional RNNs [28]. Information may be lost as a result of this as the distance between loops increases. A recurring module in the LSTM allows it to learn long-term dependencies. " Fig. 7" shows the construction of a typical RNN and LSTM that were employed in this research. Due to its benefit in learning long-term dependencies of time series, the LSTM algorithm was chosen; a temporal correlation analysis of EEG data is performed using this technique in this study [29].
A unique memory unit created by LSTM preserves historical information, while three gates regulate the updating and using of that knowledge: input gate, forget gate, output gate [30]. Fig. 7, an LSTM memory cell is shown in an illustration. It is implemented using the following composite function in this paper:

A. Results of EEG Brainwave Dataset: Mental State
By analyzing the KNN, DT and LSTM learning algorithms on the datasets in "Section III", it's clear that the LSTM achieved the best accuracy results of 97.0% compared to the other classifiers shown in " Fig. 8". However, when applying the PSO on the EEG brainwave dataset: mental state dataset, in " Fig. 9" it's obvious that the PSO performed higher accuracy result of 99.3%, when applied with LSTM classifier compared to the results when applied with the KNN and DT algorithms which were 96.1% and 95.3% respectively which emphasizes that the PSO enhanced the accuracy result by 2.3% than that resulted when applying the same algorithm without the PSO algorithm.

B. Results of EEG Brainwave Dataset: Feeling Emotions
By analyzing the KNN, DT and LSTM learning algorithms on EEG brainwave dataset: feeling emotions in "Section IV", it's clear that the LSTM achieved the best accuracy results of 96.08% compared to the other classifiers shown in " Fig. 10". However, when applying the PSO on the EEG brainwave dataset: mental state dataset, "In Fig. 11" it's obvious that the PSO performed higher accuracy result of 98.7 %, when applied with LSTM classifier compared to the results when applied with the KNN and DT algorithms which were 93.12% and 91.98% respectively which emphasizes that the PSO enhanced the accuracy result by 2.1% than that resulted when applying the same algorithm without the PSO algorithm.

C. Epileptic Seizure Recognition Dataset
By analyzing the KNN, DT and LSTM learning algorithms on EEG brainwave dataset: feeling emotions in "Section III", it's clear that the LSTM achieved the best accuracy results of 96% compared to the other classifiers shown in " Fig. 12". However, when applying the PSO on the EEG brainwave dataset: mental state dataset, in " Fig. 13" it's obvious that the PSO performed higher accuracy result of 99.1%, when applied with LSTM classifier compared to the results when applied with the KNN and DT algorithms which were 94% and 95.3% respectively which emphasizes that the PSO enhanced the accuracy result by 3.1% than that resulted when applying the same algorithm without the PSO algorithm.
After applying PSO to the three mentioned datasets we found that using PSO in feature Extraction is improved results after classification phase, PSO-LSTM model give best accuracy results when applied in the three datasets as shown in " Fig. 14".
By comparing this study with other previous experiments that used the same datasets we proved that the proposed models (PSO-KNN, PSO-DT, PSO-LSTM) produce the best accuracy compared with other models as shown in "Table II".

D E T E C T I O N O F E E G S I G N A L S
Mental state Emotional feelings Epileptic seizure www.ijacsa.thesai.org

VII. CONCLUSION
Machine learning techniques were used to classify EEG signals. In "Section III", we examined KNN, DT, and LSTM learning algorithms on the datasets. The LSTM obtained 97% accuracy on EEG brainwave dataset: mental state, 96% accuracy on EEG brainwave dataset: experiencing emotions, and 96% accuracy on Epileptic seizure identification compared to the others. KNN obtained 93.14 % accuracy on EEG brainwave datasets for mental state, epileptic seizure detection, and experiencing emotions, respectively. DT on EEG brainwave datasets for mental state, epileptic seizure detection, and experiencing emotions, the accuracy was 93.67%. Compared to other classifiers, PSO-LSTM obtained the brainwave dataset: experiencing emotions, and Epileptic seizure identification, respectively. PSO-KNN obtained 96.1 % accuracy on EEG brainwave datasets for mental state, epileptic seizure identification, and experiencing emotions, respectively, whereas PSO-DT achieved 93.12 % accuracy on the same datasets. The PSO algorithm improved the accuracy result by 2-3% when applied to the three distinct EEG brainwave datasets: mental state, epileptic seizure identification and experiencing emotions. So suggested model PSO-LSTM outperformed other models in accuracy.