EEG Based Brain Computer Interfacing for Hand Assistant System Using Wavelet Transform

Robots have been of great use to mankind for several years. In situation where human body fails to operate as per the need robot’s functions in those situations quite efficiently. Electroencephalogram (EEG) controlled hand assistant makes use of EEG signals and Brain Computer Interface (BCI). EEG signals are obtained from the brain using Emotiv Insight headset, after which processing and features extraction of the signals is performed and then conditioning of signals is done as it is a low amplitude signal with additive noise. Signals processing is done on the analog signal by using wavelet transform. Wavelet transform will help to extract information from the analog signal. Then the signals are assigned with the signatures to perform the dedicated task Filtered signal is given to analog pins of Arduino Uno. With the help of inbuilt ADC available on Arduino Uno, Digital Data is also made available on the digital pins. Then through MATLAB access Arduino board. In near future if it gets similar kind of input it will understand exactly what operation to perform. Further the Robotic hand assistant can be operated as we want.


Introduction
The human brain begins to show the electrical activity during the embryonic period weeks. After birth, there are 1011 neurons (5*1014) synapses. The functioning and movements of all body parts is controlled by brain. After the registration of Aegean signal in all parts of the Cortex in 1943, the extensive research area started from the first year of 70th year. EEG is non-interfering and cheaper as compared to other devices. As a result, EEG is considered as most suitable one among all other. There are many things which are highly automated in this world. People who are paralyzed have to depend on others for the fulfilment of a particular task. Also there are various tasks which a scientist wants to handle but he is unable to, because of the hazards of that particular substance or chemical. Not only in such research areas, but also in areas where the human being can 't be physically present but needs to operate various important work in such areas, EEG and BCI controlled prototypes can be used. In our work, we have introduced a method in which servo motor is controlled using an EEG signal collected from the cerebral cortex area, which then artificially inserted as a biological application. The proposed project uses AF3, AF4, T7, T8, and Pz electrodes from EMOTIV INSIGHT Headset [1]. To establish this purpose, the signals from the PhysioBank ATM for EEG Motor Movements have been taken. The signals are recorded by performing various tasks out of which the selection of the first two tasks which are 1) Baseline, eyes open. 2) Baseline, eyes closed. These signals are recorded using BCI2000 system. The data is provided in EDF+ format (European Data Format) which have 64 channel output, each channel is sampled at 160 samples per second [2]. The signals are saved in .mat format for the ease of computation in MATLAB. Standard Databases undergoes the feature Extraction process which is done using Wavelet Decomposition. During Decomposition, the selection of Beta waves is done. EEG signals are often analysed in terms of the frequency bands. In terms of voluntary motor activity, 15-30 Hz range is reported which corresponds to the Alpha and Beta range. The proposed project gives the best classification in Beta range (16-31) Hz. The classified task is then sent to the Arduino via socket programming in Arduino-MATLAB interface. The task value is then mapped to the servo movement, for task 1 it rotates 90 degrees and for task 2, by 180 degrees. In this manner, the task of up and down arm movement is established.

Objective
The main and the utmost purpose of this work is to implement robotic arm that is controlled totally by the EEG signals. The Hand assistant is driven by the servo motor, which is controlled totally by the EEG signals. When the user enters any random input signal then, that signal is compared with the database using classification and the servo is then actuated according to the task classified.

Motivation
The field of EEG and BCI, widely recognized as the current challenge for Machine Learning and Neural Network, is attracting the interest of many researchers. People who are paralyzed have to depend on others for getting their work done. The proposed project makes the paralyzed people independent. The work is not limited for these people but it can be used in many areas, such as gaming, virtual reality, also in the research areas for helping scientists, to work with the hazardous materials.

Literature Survey
The Electroencephalography (EEG) is the process that records electrical activity of the brain. On the scalp with conductive gel electrodes are placed to obtain EEG signals. The electrical activity done due to ion exchange in brain cells and it is the measure of current flow from the summated activity of number of neurons in our brain. The EEG signals recorded after placing electrodes on scalp having the range from 0-200 micro-volts. EEG waves, also called as brain rhythms are classified according to the frequency, amplitude and shape of the scalp at which they are recorded. The EEG waveforms are mainly classified in five classes as alpha waves, beta waves, theta waves, delta waves and gamma waves. These waves are identified by frequency (Hz or cycles/sec) and amplitude.
Alpha waves were discovered by German neurologist Hans Berger. Alpha waves occur at frequencies between 8-13 Hz. The alpha waves are generally associated with relaxation and are originated from the occipital lobe of brain during wakeful relaxation while eyes are closed. During deep sleep, the alpha waves get disappear. Beta waves occur at frequencies between 13-30Hz. In alert state of the individual these waves occurred and also occurred during deep sleep. Beta wave represents alertness and tension with that it also associated with remembering the memories. Theta waves occur at frequencies between 4-7 Hz. These waves normally occur in children, but they also occur in some adults during emotional stress. The individuals having brain disorders and often in degenerative brain states these theta waves occur. Delta waves occur at frequencies between 0.5-4Hz and during very deep sleep these delta waves occur. Gamma waves have frequencies from 35Hz and above. They are most energetic waves and have the smallest amplitude. The higher frequency wave beta is more prominent when eyes are open and closed thus beta waves were considered for the further processing and feature extraction of the signals [3].
From past many years, the researchers are very curious in the field of BCI and EEG signal processing. In late, 1870, the Motor Cortex part of the Brain was discovered. Scientist applied electricity to this part of the dog's brain and it resulted in the movement of limbs [4]. The first Brain Machine Interface was invented in the year 1969 in University of Washington. The best part of this invention is monkeys were trained to move a dial using the nerve impulses which were recorded from their brain commands [5]. In 1982, scientists were able to predict in which direction a monkey's limb is moving. This was done by charging the motor cortex with electricity [6]. An unimaginable discovery took place in 1998, where a paralyzed man who cannot speak was able to do cursor movement and selecting messages from a computer menu. A paralyzed lady's brain was screwed in the motor cortex area of her brain, 2014. As a result of this, she was able to move a robotic hand with her brain [7]. From the last several decades, numerous studies have developed in BCIs with the goals ranging from providing means of communication to functional rehabilitation and in that EEG based BCI systems plays important role for communication and rehabilitation [8].

Proposed Methodology
The block diagram shown in Fig. 1 consists of Data Acquisition of EEG signals, EEG signal overlapping, Feature Extraction, Training Dataset Creation, Classification, Arduino-MATLAB interface and Servo Motor. The Feature Extraction is performed on the EEG signal acquired from the PhysioBank, in MATLAB. The classified task obtained from KNN classifier is mapped to the servo movements.

Data Acquisition
The EEG signal dataset is collected from the PhysioBank ATM. This data set consists of over 1500 one-minute EEG recording ad it is obtained from 109 volunteers. 64 channel electrode system were used to record EEG using BC2000 while subjects performing different motor tasks. The Bank mentioned four tasks, out of which for this project we opted two tasks which are-(1) Baseline, eye open and (2) Baseline, eye close. Out of the 64 channels the 5 electrodes are taken into consideration i.e., AF3, AF4, T7, T8 and Pz. The signals are saved in .mat format for the ease of computation in MATLAB for further processing, that is performing feature extraction.

EEG Signal Overlapping and Window Size
After collecting the EEG signals these signals were overlapped with window size of 750ms. The entire windowing technique and framing is applied to all the electrodes separately [9]. The first window size is the largest and it is same as size of the EEG signal. After that subsequent steps include reducing the previous window size by half and same will be repeated until getting the smallest windows size of 1 second. This is due to 160 sample/second sampling rate. The Hamming window is selected for 50 percent overlapping so that any particular information is not lost. Since we are performing overlapping and due to the spectral plot of the Hamming window, it provides the entire signal information with the best accuracy.

Feature Extraction
The important step in this work is the feature extraction. The total accuracy, the final output will be affected if the accuracy of the dataset obtained from feature extraction is not achieved. In EEG signals essential information is present at low frequency range generally between 0 to 50 Hz so multilevel wavelet decomposition was performed on EEG signals. The decomposition is multi layered indicates the frequency element and for the next process it increases the signal information. The feature extraction is done using discrete wavelet transform with 3 level of decomposition. In discrete wavelet transform dynamic scales and positions are utilized for extracting the features and defined in Eq. (1) as follows [10]: where 2 j *k is time localization and 2 j is scale respectively, while x(t) represents the mother wavelet function. Daubechies (db4) wavelet is selected as the mother wavelet function, using sampling rate 160 sample/second EEG signals are decomposed and it provides the result into 5 bands as delta (0.5-4Hz); Theta (4-7Hz); Alpha (8-13Hz); Beta (13-30Hz); and Gamma (35-63Hz) and rest is noise. Then energy will be extracted from related frequency bands. Out of the 5 frequency band, only Beta Band is utilized. In this stage, since the work is with the Beta Waves, the selection of cd3 coefficient has been taken into consideration, which is nothing but a detailed coefficient.
where C j, k is the detail coefficients or approximation coefficients and N denotes the number of wavelet coefficients at each level of decomposition. The energy of the wavelet packet is normalized by comparing the energy of detail with total energy of the signal according to Eq.
(3) as follows: The total energy E t of the signal is calculated according to Eq. (4) as follows: This process is continued to generate the relative wavelet entropy. Wavelet entropy is used to calculate the degree of similarity between different EEG signal segments. The total wavelet entropy is calculated as per Eq. (5) as follows: To characterize, the variability and most importantly the location of the dataset, the inclusion of skewness and kurtosis has been done. The measure of symmetry or more precisely the lack of symmetry is the skewness. A symmetricity is there between distribution and dataset if it resembles the same in both left and right from the centre point and it is expressed according to Eq. (6) as follows: where µ is the mean value of x, σ is the standard deviation value of x, and E(t) shows the expected value of the quantity t and the sample version of this population value is calculated from skewness. Kurtosis is used to measure whether the data are heavy tailed or light tailed relative to a normal distribution. If lighter the tails, then lower is the Kurtosis. Similarly, if heavier the tail, then higher is the Kurtosis. The kurtosis of a distribution is calculated according to Eq. (7) as follows: The Kurtosis is used to calculate the sample version of population value.

Training dataset Creation
For 20 subjects and for total 2 tasks, 40 samples are created in the database for total 8 features. This database is obtained automatically by running the MATLAB script, and loaded in the form of a matrix. This Dataset is used for training purpose in the classification. Any random signal is compared with this standard database.

Classification
Classification is the most important step for insuring the proper working of the system. There is a need to classify whether the task is eyes open or eyes closed. For classification of these tasks K-Nearest Neighbour classifier is used. KNN is a supervised classification method and it is a nonlinear classifier [12]. It uses class labels for training data. KNN makes prediction directly using the training dataset. It is the simple algorithm that stores training dataset of different classes or tasks and classifies new classes/tasks based on similarity measure (e.g. distance functions). In this the standard training dataset and the group matrix is provided with task labels. Further random sample is provided to the classifier and the classification is done based on distance functions. There are different types of distance functions such as Euclidean, cityblock, cosine, correlation and hamming. City block distance is used in classifier to get better accuracy of the classification. Another name for city block distance is Manhattan distance. It represents the absolute difference between co-ordinates of pair of objects. City Block distance is calculated according to Eq. (8) as follows: Based on the random input provided to the system, KNN classifier does comparison with the standard dataset and provides the output [13]. The classification between the two classes is then obtained and the information is then given as command to Arduino to control the movements of the servo motor.

Arduino MATLAB interface
The Arduino MATLAB interface is the last stage of this proposed work wherein, the computed and classified task is communicated to the Arduino via the MATLAB script. The Arduino Hardware packages are readily installed in the MATLAB R2017a. By simple connecting the Arduino board to a specific com port and mentioning the same in the MATLAB script, the servo motor is actuated according to the task. For example, for task 1 the arm rotates by 180 degrees and the wrist by 90 degrees. The rotation can be provided according to one's convenience.

Arduino Uno Board
Arduino Uno is AT-mega328 microcontroller based board. In this work, Arduino Uno receives command on one of the 14 digital input/output pin and then on the same pin servo motor is connected. This command is crucial to Rotate the servo motors accordingly. Thus based on the classifier output servo motors are being controlled with the help of Arduino.

Servo Motor
A Servo Motor is basically a rotary mover or actuator which allows user to do precision control of linear or angular position, velocity and acceleration. Servo motors work upon a feedback system and therefore they are often referred to as motors suitable for working in Closed loop system. A servo motor has inbuilt motor, feedback circuit and motor driver. To use servo motor it needs power line, ground, and control pin. Through control pin, servo motor can be made to rotate upto 180 degrees. Therefore, a high torque servo motors are used for arm and finger movements respectively.

Software Implementation
The main steps for operating the robotic arm with BCI are shown in Fig. 2. The first step is to acquire the standard database from PhysioBank. After collecting the database, the signal processing is performed on it. Matlab R2017a has been used for the processing of the EEG signal and its classification. For Matlab-Arduino interfacing Support Packages of Arduino Hardware were installed on the System. This enabled the complete access of Arduino board on Matlab.

Result
The original EEG signal collected from Emotive Insight headset from the recording electrodes as shown in Fig. 3. The Emotiv Insight headset has an inbuilt EEG amplifier and ADC converter. The digitized data of EEG signal send to a computer system via Bluetooth in 2.4 GHz band. The EEG output having the frequency range of 0.2 to 45 Hz. The digitized EEG data doesn't need to be filtered as Emotive Insight headset itself contains notch filters of frequency range 50Hz and 60Hz to reject the power supply frequency.

Fig. 3. Original Signal
To extract the features, the signal processing is performed on the collected data. The feature extraction is performed by using DWT. The features extracted from the EEG signals are Mean, Minimum, Variance, Standard Deviation, Entropy, Skewness, Kurtosis. The EEG signal corresponding to the different tasks is recorded and features are extracted from them. After that the classification among different tasks is done by using KNN classifier. The system is trained based on the signals collected from the Emotive Insight Headset. Based on the random input provided to the system, first the features are extracted from this input and then KNN classifier does comparison with the standard dataset and provides the output.
The output from the signal processing is then send to the digital input/output pin of Arduino onto which servo motors are connected. The interfacing of robotic arm is shown in Fig. 4. This output acts as a control command for the servo motors and the rotatory movement is performed according to the tasks.

Conclusion
The prototype of robotic arm using BCI has been successfully developed and tested. The objective of the proposed work was to develop such a system that would help the paralyzed person work in similar fashion to a normal human being where the arm movement done by the brain signals. This system is useful for the paralyzed person whose brain functions properly. After extracting and processing EEG signals suitably, the movement of robotic arm can be designed to move in the direction according to the user brain commands. The applications of BCI are unbounded, similarly the applications and scope of improvement of proposed system is unbounded. As the number of brain commands increases, the more degree of freedom can be taken into consideration for the robotic arm movement. The same idea can be used to develop a BCI controlled Robotic leg.