Online Adaptive Filters to Classify Left and Right Hand Motor Imagery
Kais Belwafi
, Ridha Djemal
, Fakhreddine Ghaffari
, Olivier Romain
, Bouraoui Ouni
and Sofien Gannouni
ENISo of Sousse, University of Sousse, Erriyadh 4023, Sousse, Tunisia
Electrical Engineering, King Saud University, Riyadh, Saudi Arabia
ETIS Laboratory-UMR8051, University of Cergy-Pontoise ENSEA, 6 avenue du Ponceau 95014 Cergy-Pontoise, France
College of Computer and Information Sciences, King Saud University, Riyadh, Saudi Arabia
Brain Computer Interface (BCI), EEG Filters, Motor Imagery (MI).
Sensorimotor rhythms (SMRs) caused by motor imagery are key issues for subject with severe disabilities
when controlling home devices. However, the development of such EEG-based control system requires a
great effort to reach a high accuracy in real-time. Furthermore, BCIs have to confront with inter-individual
variability, imposing to the parameters of the methods to be adapted to each subjects. In this paper, we
propose a novel EEG-based solution to classify right and left hands(RH and LH) thoughts. Our approach
integrates adaptive filtering techniques customized for each subject during the training phase to increase the
accuracy of the proposed system. The validation of the proposed architecture is conducted using existing data
sets provided by BCI-competition and then using our own on-line validation platform experienced with four
subjects. Common Spatial Pattern (CSP) is used for feature extraction to extract features vector from µ and
β bands. These features are classified by the Linear Discriminant Analysis (LDA) algorithm. Our prototype
integrates the Open-BCI acquisition system with 8 channels connected to Matlab environment in which we
integrated all EEG signal processing including the adaptive filtering. The proposed system achieves 80.5% of
classification accuracy, which makes approach a promising method to control an external devices based on the
thought of LH and RH movement.
Today, the number of patients suffering from Cere-
broVascular Accident (CVA), Spinal Cord Injury
(SCI) and other similar illnesses is growing ev-
ery day. Improving the life quality of these per-
sons is one of the most challenging task in front
of the Brain Computer Interface (BCI) technolo-
gies. These technologies are used according to the
non-invasive mode (Hajimani et al., 2013), which
is based on capturing directly the Electroencephalo-
gram (EEG) signals from the scalp using the Ag/cl
electrode and without any surgery operation. EEG-
based control system can be conducted by different
SMRs Rhythm such as: Event Related Desynchro-
nization/Synchronization (ERD/ERS) (Duan et al.,
2014), Event Related Potential (ERP) (Cai et al.,
2013), P300 speller (Koo et al., 2014), etc. By using
these techniques, many applications can be developed
to control home equipments, bed nursing, multimedia
devices, games, driving assistance cars, etc.
A typical EEG chain is used in online approach
as depicted in Figure 1. According to the 10-20 sys-
tem standard, the eight electrodes of the OpenBCI ac-
quisition system are fixed on the scalp on these po-
sition: (C1, C2, C3, C4, FC2, CPZ, CZ, FCZ, CPZ,
OZ, Ground electrodes are placed on the ear). EEG
signals are registered using an OpenBCI 32-bit ac-
quisition board based on the ADS1299 Analog front
end device. EEG digital signals are then sent to the
host through RFduino module allowing users to in-
teract freely without any discomfort. The acquired
EEG signal are processed to remove all unwanted sig-
nals. These undesired frequencies are removed based
on adaptive filters due to the intrinsic variability of
EEG signals in each subject (Belwafi et al., 2014).
Once the EEG signals is well filtered, we proceed to
the extraction of the main characteristic of each trials
by applying the Common Spatial Pattern algorithm;
which is the most effective spatial filter algorithm to
extract ERD/ERS effects (Kais et al., 2014). The ob-
tained feature is then classified using the Linear Dis-
Belwafi, K., Djemal, R., Ghaffari, F., Romain, O., Ouni, B. and Gannouni, S.
Online Adaptive Filters to Classify Left and Right Hand Motor Imagery.
DOI: 10.5220/0005846503350339
In Proceedings of the 9th International Joint Conference on Biomedical Engineering Systems and Technologies (BIOSTEC 2016) - Volume 4: BIOSIGNALS, pages 335-339
ISBN: 978-989-758-170-0
2016 by SCITEPRESS – Science and Technology Publications, Lda. All rights reserved
criminant Analysis (LDA) classifier, which uses lin-
ear function to distinguish between LH and RH tasks
(Lotte et al., 2007).
Even if the off-line validation of the proposed
EEG-based architecture is very interesting using ex-
isting data sets, the on-line validation remains the best
validation one providing a real-time interaction which
represents the feedback aspect in the BCI-chain (Yu
et al., 2015). To proceed for classification of LH and
RH movements using the on-line approach, we pro-
posed to use the headset of OpenBCI with eight chan-
nels connected to Matlab environment in which we
developed all EEG signal processing including adap-
tive pre-processing.
EEG Filter
Figure 1: Brain computer interface chain.
The remainder of this paper is organized as fol-
lows. In Section 2, the fundamentals of BCI theory
is described. The data recording and processing ex-
plained in section 3. Section 4 presents the results and
realization of the system. The conclusion and future
research plans are discussed in Section 5.
The block diagram of the proposed EEG-based sys-
tem is depicted in Figure 2. Eight EEG channels are
used and placed on the scalp according to the 10-
20 system. The spatial distribution of the electrodes
is depicted in Figure 3. As above mentioned, EEG
signals are acquired using an openBCI32 bit board.
The conversion from analog to digital is done by the
ADS1299, followed by an amplification stage with a
factor of 24. The sampling frequency is fixed to 250
Hz. Notch filters are configured and applied to all
eight channels as a first pre-processing action. The
acquisition board will send continuously EEG data
through the RFduino module to the Matlab environ-
ment via a USB interface (see Figure 4). An auto-
matically script will be launched to check the frames
permanently, converts it to the corresponding value
and stores them into a matrix to be subsequently pro-
cessed. Four volunteers participated in this experi-
Figure 2: Experimental setup.
Figure 3: Electrode positioning.
ment whereas two of them are familiarized with these
experiments. The participants are informed by the
recording scenario to avoid the risk of suffering due
to the long time of recording (Onishi and Natsume,
2013), which can exceed half hour. In total, 260 tri-
als are recorded during these experiments (140: for
training and 120 for test). After launching the process
by press start button, the participant has to imagine
the left hand or the right hand movement according to
the picture appearing on the bottom of the interface as
illustrated in Figure 4.
Figure 4: The interface of the proposed system.
Smart-BIODEV 2016 - Special Session on Smart Embedded Biomedical Devices for In Situ Physiological Signal Processing
Signal processing was performed to keep just the fre-
quencies related to left and right hand motor imagery
which are represented by µ-rhythm and β-rhythm
(Lotte and Guan, 2011). Recently, a new approach
is proposed to select automatically the best filters pa-
rameters that guarantee the removal of all unwanted
signals, and adapts to the intrinsic individual char-
acteristics of EEG signals for each person (Belwafi
et al., 2014). This method is based on the variation of
the Signal-to-Noise Ratio (SNR) on the stop band that
has an explicitly effect on the pass band frequencies.
Increasing the SNR will increase the filter order lead-
ing to a modification of the transition band to be close
to the cut-off frequency where the signal becomes
very well filtered. Furthermore, the applied adaptive
filtering techniques are based on the Finite Impulse
Response (FIR) and Infinite Impulse Rate (IIR).
Once the EEG signals are filtered, their size
should be minimized as much as possible keep-
ing only useful information contained in each trials.
Many techniques are reported in literature including
power spectral density, Short-Time Fourier transform
STFT, CSP and wavelet analysis (Duan et al., 2014),
etc. The CSP algorithm is strongly recommended for
feature extraction of EEG signal in motor imagery.
This algorithm computes the discrimination between
features of two classes according to the distribution
of their topographic patterns (Robinson et al., 2011).
Formally, CSP computes the normalized covariance
matrices by applying the following equation (Equa-
tion 1):
where trace(x) is the sum of diagonal elements of x,
’i’ is the index of class (LH, RH) and E is data of
each trials of dimension given by Number of channel
x Number of samples. Then, the overall composite
spatial covariance matrices is calculated by adding the
covariance matrices of each classes. In the next step,
the composite matrices (C
) is decomposed according
to the following equation(Equation 2):
= U
where U
is the matrix containing eigenvector and
is the diagonal matrix containing the eigenvalue
sorted in the ascending order. According to the equa-
tion (Equation 3), the whitening transform will be
computed to equalize the variances in the space that
is created by U
P =
A simple test can be done to check that all above op-
erations are done successfully. The multiplication of
of P, (U
) and P transpose respectively, should give
one. The transformed covariance matrices S
obtained according to the equation (Equation 4):
= PC
= Bλ
Then, the projection matrix W is obtained according
to the following equation:
W = B
P (5)
The feature vector which optimally discriminate the
two classes are the (N/2) smallest and (N/2) largest
eigenvector of Z (see Equation 7), where N is the
number of feature that should be retained. In our case,
the number of feature is fixed to six.
Z = W E (6)
Finally, the returned feature vectors is calculated
based on the following equation:
= log(
) + var(Z
) (7)
To predict the class of each trials, LDA classifier is
applied on the extracted features. The goal of LDA is
to separate the data representing the two classes by an
hyper-planes as depicted in Figure 5. The equation of
the hyper-plane (L) is mentioned on the same figure,
where Q and b are the hyper-plane coefficients which
will be estimated during the training phase.
Figure 5: A Hyper plane separating LH and RH.
Depending on the sign of L, the classifier will as-
sort each feature. If the hyper plane (L) of an action is
strictly negative, then the action should be a RH. Sim-
ilarly the corresponding actions strictly positive then
is LH.
Two sessions are recorded during the evaluation of the
system. One recording session is used for training,
Online Adaptive Filters to Classify Left and Right Hand Motor Imagery
and the other one for testing. As depicted in Figure
6, the accuracy of the two class motor imagery ac-
tions increases when we integrate the adaptive filter-
ing techniques for all subjects. In fact, the proposed
BCI chain is able to discriminate RH and LH EEG
signals with a high accuracy reaching 92% for subject
4 for example. The mean performance of all subjects
is close to 80% using adaptive filtering techniques.
Figure 6 shows clearly a significant improvement in
the system accuracy by just tuning the filters parame-
ters. The adaptive filter is done automatically during
the training phase for each subject and the best param-
eters were fixed during the test phase. Furthermore,
the enhancement of classification accuracy over tra-
ditional classifiers based on one fixed filter is signifi-
cant and can reach u;p 25%. The filters parameters are
heterogeneous among subject. For example for sub-
ject one the best filters is Chebyschev1 with an SNR
of 50 dB, that implies motor imagery frequencies of
this subject are inside µ and β bands. In others cases
for example, for subject two the LH and RH frequen-
cies are outside these theoretical bands. Information
Transfer Rate (ITR) is used to evaluate the proposed
system according to the following equation:
IT R = L[plog
(p) + log
(N) + (1 p)log
1 p
N 1
)] (8)
Let consider L is the number of decisions in one
minute, and p is the accuracy of the subject in making
decisions among N targets.
Figure 6: Classification accuracy for four subjects.
The ITR for all subjects is 8.64 bits/min which
is very interesting result compared to a similar work.
For example, in (Sannelli et al., 2010), the ITR com-
puted for three subjects is 3.56 bits/min. The system
proposed in (McFarland et al., 2003) dedicated for
controlling the mouse using two motor imagery ac-
tions reaches 7.4 bits/min as ITR for eight subjects.
For comparison purpose with the offline approach,
the same algorithms are used in the off-line context
and a small increase of only 1% of accuracy. Our re-
sults show that adapting filtering is very interesting to
be integrated into the on-line validation of the EEG-
based motor imagery application to reach a high ac-
The proposed EEG chain shows a clear improvement
of the performance of the system leading to good dis-
crimination between LH and RH motor imagery tasks
for online validation. In order to improve the per-
formance of the proposed system, adaptive filter was
used to remove the maximum of the unwanted sig-
nals, and to tune the pass band which contain µ and β
band. The proposed method shows that the combina-
tion of the adaptive filter with CSP as features extrac-
tion and LDA as classifier improves the classification
accuracy using the online approach. Furthermore, the
ITR of the system is very interesting comparing with
those obtained from equivalent existing systems.
Our future work target is to extend the proposed
procedure to a multiclass paradigm in order to classify
three tasks that will be used with a state machine to
control home devices equipment. In addition, it will
be interesting to implement the proposed procedure in
real time embedded system.
This project was funded by the National Plan
for Science, Technology and Innovation (MAARI-
FAH), King Abdulaziz City for Science and Tech-
nology, Kingdom of Saudi Arabia, Award Number
Belwafi, K., Djemal, R., Ghaffari, F., and Romain, O.
(2014). An adaptive EEG filtering approach to max-
imize the classification accuracy in motor imagery.
In Computational Intelligence, Cognitive Algorithms,
Mind, and Brain (CCMB), 2014 IEEE Symposium on,
pages 121–126.
Cai, B., Xiao, S., Jiang, L., Wang, Y., and Zheng, X. (2013).
A rapid face recognition bci system using single-trial
erp. In Neural Engineering (NER), 2013 6th Interna-
tional IEEE/EMBS Conference on, pages 89–92.
Duan, S., Xu, T., Zhuang, W., and Mao, D. (2014). The fea-
ture extraction of erd/ers signals based on the wavelet
Smart-BIODEV 2016 - Special Session on Smart Embedded Biomedical Devices for In Situ Physiological Signal Processing
package and ICA. In Intelligent Control and Automa-
tion (WCICA), 2014 11th World Congress on, pages
Hajimani, E., Ruano, C., Graca Ruano, M., and Ruano, A.
(2013). A software tool for intelligent cva diagno-
sis by cerebral computerized tomography. In Intelli-
gent Signal Processing (WISP), 2013 IEEE 8th Inter-
national Symposium on, pages 103–108.
Kais, B., Ghaffari, F., Romain, O., and Djemal, R. (2014).
An embedded implementation of home devices con-
trol system based on brain computer interface. In Mi-
croelectronics (ICM), 2014 26th International Confer-
ence on, pages 140–143.
Koo, B., Nam, Y., and Choi, S. (2014). A hybrid eog-
p300 Bci with dual monitors. In Brain-Computer
Interface (BCI), 2014 International Winter Workshop
on, pages 1–4.
Lotte, F., Congedo, M., Lcuyer, A., Lamarche, F., and Ar-
naldi, B. (2007). A review of classification algorithms
for eeg-based braincomputer interfaces. Journal of
Neural Engineering, 4(2):R1.
Lotte, F. and Guan, C. (2011). Regularizing common spa-
tial patterns to improve bci designs: Unified theory
and new algorithms. Biomedical Engineering, IEEE
Transactions on, 58(2):355–362.
McFarland, D. J., Sarnacki, W. A., and Wolpaw, J. R.
(2003). Braincomputer interface (bci) operation: opti-
mizing information transfer rates. Biological Psychol-
ogy, 63(3):237 – 251.
Onishi, A. and Natsume, K. (2013). A new online event re-
lated potential based brain-computer interfaces using
an ensemble classifier. In Neural Engineering (NER),
2013 6th International IEEE/EMBS Conference on,
pages 1033–1036.
Robinson, N., Vinod, A., Guan, C., Ang, K. K., and Peng,
T. K. (2011). A wavelet-csp method to classify hand
movement directions in eeg based bci system. In
Information, Communications and Signal Processing
(ICICS) 2011 8th International Conference on, pages
Sannelli, C., Vidaurre, C., Muller, K., and Blankertz, B.
(2010). Common spatial pattern patches - an opti-
mized filter ensemble for adaptive brain-computer in-
terfaces. In Engineering in Medicine and Biology So-
ciety (EMBC), 2010 Annual International Conference
of the IEEE, pages 4351–4354.
Yu, T., Xiao, J., Wang, F., Zhang, R., Gu, Z., Cichocki, A.,
and Li, Y. (2015). Enhanced motor imagery training
using a hybrid bci with feedback. Biomedical Engi-
neering, IEEE Transactions on, 62(7):1706–1717.
Online Adaptive Filters to Classify Left and Right Hand Motor Imagery