BCI-Based Robotic Arm Control Using DNN
BCI-Based Robotic Arm Control Using DNN
mixed in the signal. To remove the artefacts, Butterworth filter • The BCI task is application dependent; non-availability of
[13] and wavelet transform [14] is applied. The feature standard data set for evaluating the model.
extraction includes the usage of typical signal processing • Design of an external device which provides feedback to
methods to extract the traditional features such as energy, the subject
power spectrum, Power Spectral Density (PSD), and statistical • Finally the integration of all the above at a low cost with
features [3],[16]-[18]. Discrete Wavelet Transform (DWT) high efficacy.
based feature extraction methods are preferred [14],[17]-[19]
because of its time-spatial domain analysis and de-noising All the above challenges leave a room for research in BCI. In
ability over the Fourier Transform (FT). DWT filter bandwidths this work, we aim to propose a customized end to end a low-
are non-linear. To have linear bandwidths, Wavelet Packet cost robotic arm control framework. The end to end low-cost
Decomposition (WPD) [11], [20]-[21] is widely useful as the framework objective is achieved through multi-fold. The first
feature extraction methods. Some researchers took advantage step is to design of low-cost data acquisition EEG device. Next,
of combining both FT and DWT [22] in the feature extraction hand-collecting data for our application and finally, design of
process. Another method of extracting time-frequency low computational complexity deep learning model. Though
information other than DWT is Hilbert-Huang Transform there are BCI datasets available [30], for this particular task of
(HHT) [15], [23]. arm movement, there is no motor imagery EEG data available.
Sometimes feature engineering is done to get handcrafted We have designed a 3-channel data acquisition embedded board
features. Features such as fractal dimension [24] and fuzzy to get the data from the subject, feature engineered on the pre-
wavelet packet [20] are extracted from the EEG signal. processed data, designed a deep learning model with acceptable
Recently, Convolutional Neural Networks (CNN) are used to accuracy for the BCI task, and finally integrated the output with
generate features [25] from the EEG signal automatically a robotic arm. Overall, the proposed framework showed
without handcrafting them. significant improvement as a low-cost solution to the research
EEG signal is a high dimensional signal in nature, and thus community. We shall explain the proposed framework in detail
increases the computational complexity of the classifier it goes in the following sections.
with. To reduce the high dimension, dimensionality reduction
techniques such as Principal Component Analysis (PCA) II. METHODS
[4],[12],[18], Independent Component Analysis(ICA) [18] and
Linear Discriminative Analysis(LDA) [13],[14],[21] are widely A. Data Collection
employed. The acquisition of the EEG signal was done using a simple
Typical pattern recognition classifiers are widely employed three-channel electrode [17]. These electrodes are placed on
to classify the EEG signal. To mention a few, They are Hidden three locations namely, C3, C4, and right mastoid [31,32] on
Markov Models [HMM] [17], Support Vector Machine [SVM] the scalp of the subjects. Arduino Uno with the AD8232 sensor
[13,20], Artificial Neural Networks[ANN] [5,7,10] and kit is connected to these three electrodes. The 3-channel EEG
Machine Learning[ML] algorithms [10]. Recently, deep signal is received by the AD8232 and fed to a computer through
learning models CNN [26, 27] and Long Short Term Memory Arduino for further processing. PLX-DAQ is an add-on
(LSTM) [28] networks are employed to improve the efficacy of software in Microsoft Excel that enables smooth and direct data
the EEG signal classifier. The convolutional neural network acquisition from a microcontroller, such as the Arduino, to
architecture employed in paper [27] achieved an accuracy of compute for further processing.
71/82% (+4.2%) with a multichannel EEG signal as 2D image
input. The accuracy got much improved when the convolution
network was employed using the transfer learning technique
[26]. The pre-trained model AlexNet is adapted for the
classification of EEG signals through transfer learning [29].
Also, ResNet is adapted for MI EEG classification [26].
However, these networks improved the accuracy of the
classification at the cost of huge computational complexity
Although a lot of research has been carried out to improve
the intra-subject accuracy and inter-subject accuracy of the BCI
task, accuracy is still less than 80%. Therefore, a simplified
innovative end to end methodology is necessary for further
improvement.
There are few challenges in accomplishing the end to end
BCI task.
• Placement of electrodes on the scalp
• The effectiveness of the ionic current flow varies from Fig. 1. International 10-20 Electrode Placement System
subject to subject
• EEG signal is low SNR The International 10-20 Electrode Placement System, as
shown in Fig. 1, was followed to place the electrodes in the physiological and non-physiological artefacts, could corrupt the
proper positions to obtained clear signals during the data EEG features. Physiological artefacts originate from sources
acquisition. within the body, like the heart, eye, and muscles. In contrast,
non-physiological artefacts are associated with surroundings
Table 1. Subject details
and instrumentality. These artefacts lead to irregularities in the
Subject name Age recorded EEG data. Therefore, signal pre-processing i.e.
HM_21_M 21 cleaning the data from unwanted signal need to be performed
V_35_M 35
before using the data. Butterworth band-pass filter [13] is
used to remove the unwanted waveband and in turn minimizes
MK_37_M 37
the number of features. It has an immediate impact on reducing
CK_39_M. 39
the execution time and decreases the use of memory, which in
H_59_M 59 turn boosts the system performance. Henceforth, the EEG
signals are filtered with a bandpass filter with a frequency range
Table 2 Data set of 12 to 30 Hz, which is designed with a fourth-order
Butterworth filter, to allow beta rhythm and to get rid of
Data class No of Samples
Hand movement 125
unwanted artefacts.
No hand movement 125 Wavelet Transform (WT) is a multi-resolution analysis
compared to FT, which is a constant resolution. Therefore, WT
The EEG signals were recorded for a total of seven seconds is chosen for this research. Choosing a Mother Wavelet basis
from each subject and each class. For the class ’Hand function is a challenge because not much in literature is
Movement’, subjects were asked to lift their hand at the end of mentioned. In this research work, the Sym9 wavelet transform,
the third second in the total seven-second interval. For the class which exhibits a biorthogonal, near symmetric and orthogonal
’No Hand Movement’, the subjects did not lift or move their properties, is experimentally selected and employed to
hand and were advised to remain calm. In total, data collections eliminate ocular physical object noise, eye blinking noise, and
were taken from five different subjects belonging to different internal organ artefacts.
age groups ranging from twenty to sixty years, as listed in Table From the filtered, pre-processed EEG signal, fourteen
1. For privacy, the subject name is coded here. The subjects statistical features are extracted namely Mean, Maximum
were informed about this research and with their consent, the Amplitude, Minimum Amplitude, Standard Deviation,
data acquisition from one of the subjects is depicted in Fig. 2. Variance, RMS, Entropy, Kurtosis, Skewness, Percentile,
To keep the dataset balanced, for hand movement class 125 Median, Covariance, Centroid, and Spectral Centroid.
recordings were collected and for ‘no hand movement’ 125
recordings were collected. The hand-collected data set of 250 C. Deep Neural Network–Multi-Layer Perceptron (DNN-
MLP) Classifier
recordings were then split into 80% for training which are 202
samples and 20% for testing which are 48 samples. A Deep Neural Network (DNN) with two hidden layers is
shown in Fig. 3. DNNs are mathematical models that resemble
the neural design of the brain and work together with
interconnected neurons (nodes).
B. Signal Pre-processing
EEG Signals are always added with artefacts that introduce
changes within the recorded cerebral activity. These artefacts
could mimic the brain’s psychological feature or pathological
activity; these artefacts may additionally overlap with EEG
frequency bands with amplitudes larger than the cortical
signals. In general, many kinds of artefacts, as well as Fig. 3. Proposed Deep Neural Network architecture
(𝑇𝑃 + 𝑇𝑁)
Accuracy = (1)
(𝑇𝑃+𝑇𝑁+𝐹𝑃+𝐹𝑁)
𝑇𝑃
Precision = (2)
𝑇𝑃+𝐹𝑃
𝑇𝑃
Recall = (3)
𝑇𝑃+𝐹𝑁
𝑅𝑒𝑐𝑎𝑙𝑙∗𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛
F1 score = 2 ∗ (4)
𝑅𝑒𝑐𝑎𝑙𝑙+𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛
Fig. 5 EEG Waveforms (a) EEG waveform of hand movement and no hand movement Pre-processing on one sample of data. (b) raw EEG
signal and pre-processed EEG signal
The preprocessing of the EEG signal is shown in Fig. 5 b. The through the Butterworth filter to remove initial noises [14]. The
first waveform corresponds to the raw data extracted from a third waveform shows the final de-noised signal acquired after
human subject. The x-axis corresponds to the number of subjecting the Butterworth filtered signal to Wavelet
samples acquired for a particular amount of time at a specified Decomposition. The magnitude spectrum of Butterworth filter
baud rate and the y-axis corresponds to the voltage of the signal output is shown in Fig. 6. which confirms the signal frequency
extracted which has been amplified. The second waveform in is between 12 to 30 Hz.
Fig.7 is the signal output after the raw signal has been passed
were given as input to the DNN input layer. The network is Accuracy
trained with Adam optimizer and loss function as binary cross- Logistic Regression 72%
entropy. The network is trained for 200 epochs with a batch size Decision Tree 73%
of 5 samples. The final training accuracy obtained was 94.52% SVM 71%
and the K-Fold Cross validated accuracy was 85.41% with k as Kernel SVM 72%
The trained DNN model is tested with the test data set of 48
samples that were fed to the trained DNN classifier. Table 5 is
the confusion matrix, which summarizes the test output of the
DNN model used for classification. Here, out of 48 test
samples, 20 correct and 0 incorrect predictions were made for
the class ‘No Hand Movement’ which is represented by class
0. Also, 21 correct and 7 incorrect predictions were made of
class ‘Hand movement’ which is represented by class 1.
Predicted Value
True
Value Class 0 1 Fig.7 End to end setup for complete testing
0 20 0
1 7 21
IV. DISCUSSION
Performance metrics such as Accuracy, Precision, Recall
We presented an end to end framework for robotic arm
Sensitivity, Specificity, and F1 Score were also calculated as
control using the EEG signal in this paper. After a thorough
per the equations 1 to 4 and are listed in Table 6. Precision gives study with literature, we have chosen 3- channel [31] data
an idea about how accurate the positive predictions are. Recall acquisition because it removed the need for dimensionality
Sensitivity is the coverage of actual positive samples and
reduction in our work. Among the type of EEG signal algorithms to classify the hand movement into two classes, ’No
collection, we have gone with Motor Imagery (MI) EEG signal. Hand Movement’ and ’Hand Movement’. Further, Arduino and
As mentioned in the challenges, the standard data set of MI MATLAB are interfaced together to control the robotic arm
EEG for this robotic arm control is not available so we have based on the output predicted by the DNN model. An accuracy
done the collection of data from 5 healthy subjects, after getting of 85.41% is obtained on the test set using the ANN classifier
their consent for this research, of age ranging from 20 to 60. and the robotic arm is successfully actuated in the desired
The raw MI EEG signal is amplified to 300 to 400 mV using motion. Also, a high recall sensitivity of 100% and an F1 score
the AD8232 amplifier circuit and is further de-noised with of 85.1% was achieved.
fourth-order- Butterworth filter for power interference and Though the BCI research has been carried out for more than a
decade, applying deep learning algorithm for BCI is relatively
Sym-9 wavelet decomposition for Ocular artefacts. In total 250
new approach. Recently, researchers focus on to develop an
samples were collected with balanced data collection for both
efficient deep learning algorithm implementation which can
classes (hand movement, no-hand movement). Traditional
produce a maximum accuracy in robotic limb control. The
statistical features were extracted from the pre-processed signal proposed paper consists of a system to control a robotic arm
and applied to a custom-designed DNN-MLP classifier. Based mimicking a prosthetic arm using just the brain signals. Overall,
on past work [33], this kind of architecture design has been this paper adds a significant contribution to the end to end real-
proved to be the most efficient for classification. time BCI research.
In the future, more degrees of freedom will be added to the
The fourteen statistical features, as mentioned in the hand movement in such a way that the robotic arm can pick up
proposed work, were extracted from the de-noised signal which and drop an object. Also, transfer learning and a
was fed into the DNN model. The four-layer DNN was then hyperparameter optimization technique like Grid Search can be
trained on 80% of the data and evaluated with the k-fold cross- explored to improve the efficacy of BCI.
validation method. Next, the trained model is tested on the rest
of the 20% data. Subsequently, the performance measures References
Accuracy, Precision, Recall Sensitivity, Specificity, and F1 [1] D. J. McFarland and J. R. Wolpaw, “Brain-computer
Score and then displays as in Table 5. Here, we obtain the interface operation of robotic and prosthetic devices,”
accuracy as 85.4%, which is more than the value other literature Computer (Long. Beach. Calif)., vol. 41, no. 10, pp. 52–56,
reported. Even though we calculate the F1 score, for this 2008.
scenario of a balanced data set, an accuracy measure will suffice [2] J. Meng, S. Zhang, A. Bekyo, J. Olsoe, B. Baxter, and B.
for a balanced dataset. The challenges were getting the data He, “Noninvasive Electroencephalogram Based Control of a
from the subjects and the low SNR of the EEG signal. We have Robotic Arm for Reach and Grasp Tasks,” Sci. Rep., vol. 6, no.
custom designed our signal acquisition with a simple 3- November, pp. 1–15, 2016.
electrode system based on proven literature which reduced the [3] H. A. Shedeed, M. F. Issa, and S. M. El-Sayed, “Brain
feature dimensions. Also, to remove the ocular artefacts, all EEG signal processing for controlling a robotic arm,” Proc. -
mother wavelet basis functions were tried and it was found 2013 8th Int. Conf. Comput. Eng. Syst. ICCES 2013, no.
Sym-9 wavelet removed the artefacts effectively. We did not November, pp. 152–157, 2013.
choose other DNN algorithms such as LSTM and CNN because [4] E. Iáñez, J. M. Azorín, A. Úbeda, J. M. Ferrández, and E.
they require a lot of data, due to the non-availability of standard Fernández, “Mental tasks-based brainrobot interface,” Rob.
data set available. This sets a limitation in improving the Auton. Syst., vol. 58, no. 12, pp. 1238–1245, 2010.
accuracy of the system using other DNN approaches. We have [5] C. Guan, N. Robinson, V. S. Handiru, and V. A. Prasad,
“Detecting and tracking multiple directional movements in
trained a few of the popular machine learning models such as
EEG based Bel,” 5th Int. Winter Conf. Brain-Computer
logistic regression, Random Forest, Support Vector Machines
Interface, BCI 2017, pp. 44–45, 2017.
and Decision Tree. Their classification accuracy is shown in
[6] J. Kronegg, G. Chanel, S. Voloshynovskiy, and T. Pun,
table 8 and it was observed that the accuracy was below 75% “Eeg-based synchronized brain-computer interfaces: A model
which concludes that our proposed DNN model is superior to for optimizing the number of mental tasks,” IEEE Trans. Neural
the ML models. Syst. Rehabil. Eng., vol. 15, no. 1, pp. 50–58, 2007.
[7] D. Zhang, X., Yao, L., Wang, X., Monaghan, J. and
V. CONCLUSION Mcalpine, “A survey on deep learning based brain computer
The paper presents a BCI system that used the brain’s MI EEG interface: Recent advances and new frontiers.,” arXiv Prepr.
signal associated with hand movements to control an external arXiv1905.04149., vol. 1, no. 1, pp. 1–35, 2018.
robotic arm. The EEG signals were extracted using a 3-channel [8] C. Guger, B. Z. Allison, and N. Mrachacz-kersting, “A
electrode system with the AD8232 amplifier. Signal pre- State-of-the-Art Summary 7,” pp. 1–9.
processing was applied using Butterworth band-pass filter and [9] V. Podgorelec, “Analyzing EEG signals with machine
wavelet packet decomposition technique to obtain required beta learning for diagnosing alzheimer’s disease,” Elektron. ir
waves. Statistical features were extracted from the pre- Elektrotechnika, vol. 18, no. 8, pp. 61–64, 2012.
processed signal and were then used to train an ML algorithms. [10] T. J. Tanzi and J. Isnard, “Autonomous system for data
Logistic regression, Random Forest, Support Vector Machines, collection: Location and mapping issues in post-disaster
Decision Tree and MLP-DNN were selected as the ML
environment,” Comptes Rendus Phys., vol. 20, no. 3, pp. 204– [26] T. H. Shovon, Z. Al Nazi, S. Dash, and M. F. Hossain,
217, 2019. “Classification of motor imagery EEG signals with multi-input
[11] H. A. Akkar and F. Ali Jasim, “Optimal Mother Wavelet convolutional neural network by augmenting STFT,” 2019 5th
Function for EEG Signal Analyze Based on Packet Wavelet Int. Conf. Adv. Electr. Eng. ICAEE 2019, no. August, pp. 398–
Transform,” Int. J. Sci. Eng. Res., vol. 8, no. 2, pp. 1222–1227, 403, 2019.
2017. [27] N. Robinson, S. Lee and C. Guan, "EEG Representation in
[12] M. Balamareeswaran and D. Ebenezer, “Denoising of Deep Convolutional Neural Networks for Classification of
EEG signals using Discrete Wavelet Transform based Scalar Motor Imagery," 2019 IEEE International Conference on
Quantization,” Biomed. Pharmacol. J., vol. 8, no. 1, pp. 399– Systems, Man and Cybernetics (SMC), Bari, Italy, 2019, pp.
406, 2015. 1322-1326, doi: 10.1109/SMC.2019.8914184.
[13] A. Asadi Ghanbari, M. Nazari Kousarrizi, M. Teshnehlab, [28] J. M. Williams, “Deep Learning and Transfer Learning in
and M. Aliyari, “Wavelet and Hilbert transform-based brain the Classification of EEG Signals,” Deep Learn. Transf. Learn.
computer interface,” 2009 Int. Conf. Adv. Comput. Tools Eng. Classif. EEG Signals, pp. 1–82, 2017.
Appl. ACTEA 2009, pp. 438–442, 2009. [29] C. T. F. S. W. Zhang, “DEEP TRANSFER LEARNING
[14] G. & V. K. J. & A. S. Kaushal, “Removal of Power Line FOR EEG-BASED BRAIN COMPUTER INTERFACE,”
Interference from EEG using Wavelet-ICA,” no. Icaet, pp. 29– ICASSP, pp. 916–920, 2018.
31, 2015. [30] H. Cho, M. Ahn, S. Ahn, M. Kwon, and S. C. Jun, “EEG
[15] V. Vanitha and P. Krishnan, “Time-frequency analysis of datasets for motor imagery brain-computer interface,”
EEG for improved classification of emotion,” Int. J. Biomed. Gigascience, vol. 6, no. 7, pp. 1–8, 2017.
Eng. Technol., vol. 23, no. 2–4, pp. 191–212, 2017. [31] X. G. and S. G. Y. Wang, B. Hong, “Design of electrode
[16] L. Sun and Z. R. Feng, “Classification of imagery motor layout for motor imagery based brain–computer interface,”
EEG data with wavelet denoising and features selection,” Int. Electron. Lett., vol. 43, no. 10, pp. 10–11, 2007.
Conf. Wavelet Anal. Pattern Recognit., vol. 2016-November, [32] Martina Zabcikova, Zuzana Koudelkova, Roman Jasek,
pp. 184–188, 2016. Investigation of Emotiv Epoc+ Headset Usability by Measuring
[17] G. B. Bernardi, T. C. Pimenta, and R. L. Moreno, “A Various Stimuli, WSEAS Transactions on Applied and
Simplified Tool for Testing of Feature Selection and Theoretical Mechanics, pp. 184-191, Volume 14, 2019.
Classification Algorithms in Motor Imagery of Right and Left [33] M. A. Haque, J. S. Rani Alex, and N. Venkatesan,
Hands of EEG Signals,” 2019 IEEE 10th Lat. Am. Symp. “Evaluation of Modified Deep Neural Network Architecture
Circuits Syst. LASCAS 2019 - Proc., pp. 197–200, 2019. Performance for Speech Recognition,” Int. Conf. Intell. Adv.
[18] K. Mahajan, “Classification of EEG using PCA, ICA and Syst. ICIAS 2018, pp. 1–5, 2018.
Neural Network,” Int. J. Eng. Adv. Technol., vol. 1, no. 1, pp. [34] Robotic Arm with gripper Diy kit
80–83, 2011. [Link]
[19] I. Omerhodzic, S. Avdakovic, A. Nuhanovic, and K. Included/dp/B077YMCBWW accessed 25/8/2020
Dizdarevic, “Energy distribution of EEG signals: EEG signal
wavelet-neural network classifier,” World Acad. Sci. Eng. Creative Commons Attribution License 4.0
Technol., vol. 37, pp. 1240–1245, 2010.
[20] and G. D. Rami N. Khushaba, Sarath Kodagoda, Sara Lal, (Attribution 4.0 International, CC BY 4.0)
“Driver Drowsiness Classification Using Fuzzy Wavelet Packet
Based Feature Extraction Algorithm,” IEEE Trans. Biomed. This article is published under the terms of the Creative
Eng., vol. 6, no. 1, pp. 1–11, 2010.
Commons Attribution License 4.0
[21] M. Mumtaz, M. Afzal, and A. Mushtaq, “Sensorimotor
[Link]
Cortex EEG signal classification using Hidden Markov Models
and Wavelet Decomposition,” 2018 IEEE Int. Symp. Signal
Process. Inf. Technol. ISSPIT 2018, pp. 375–381, 2019.
[22] S. S. Devi, “Analysis of Eeg for Motor Imagery Based
Classification of Hand Activities,” vol. 2, no. 3, pp. 11–22,
2015.
[23] A. S. Al-Fahoum and A. A. Al-Fraihat, “Methods of EEG
Signal Features Extraction Using Linear Analysis in Frequency
and Time-Frequency Domains,” ISRN Neurosci., vol. 2014, pp.
1–7, 2014.
[24] E. Parvinnia, M. Sabeti, M. Zolghadri Jahromi, and R.
Boostani, “Classification of EEG Signals using adaptive
weighted distance nearest neighbor algorithm,” J. King Saud
Univ. - Comput. Inf. Sci., vol. 26, no. 1, pp. 1–6, 2014.
[25] S. U. Amin, M. Alsulaiman, G. Muhammad, M. A.
Bencherif, and M. S. Hossain, “Multilevel Weighted Feature
Fusion Using Convolutional Neural Networks for EEG Motor
Imagery Classification,” IEEE Access, vol. 7, pp. 18940–
18950, 2019.