Improving EEG-Based Motor Imagery Classification for Real-Time Applications Using the QSA Method

We present an improvement to the quaternion-based signal analysis (QSA) technique to extract electroencephalography (EEG) signal features with a view to developing real-time applications, particularly in motor imagery (IM) cognitive processes. The proposed methodology (iQSA, improved QSA) extracts features such as the average, variance, homogeneity, and contrast of EEG signals related to motor imagery in a more efficient manner (i.e., by reducing the number of samples needed to classify the signal and improving the classification percentage) compared to the original QSA technique. Specifically, we can sample the signal in variable time periods (from 0.5 s to 3 s, in half-a-second intervals) to determine the relationship between the number of samples and their effectiveness in classifying signals. In addition, to strengthen the classification process a number of boosting-technique-based decision trees were implemented. The results show an 82.30% accuracy rate for 0.5 s samples and 73.16% for 3 s samples. This is a significant improvement compared to the original QSA technique that offered results from 33.31% to 40.82% without sampling window and from 33.44% to 41.07% with sampling window, respectively. We can thus conclude that iQSA is better suited to develop real-time applications.


Introduction
In the last few years, interest in inferring information from the human brain stemming from cognitive thoughts by means of electroencephalography (EEG) has expanded to various disciplines such as neuroscience, robotics, computational science, physics, and mathematics. Research in these areas tends to revolve around the development of new communication and control technologies based on braincomputer interface (BCI) devices to support people with severe neuromuscular conditions in ways that can enable them to express their wishes or use devices as neuroprosthetics [1], wheelchairs [2,3], control a cursor on a computer screen [4], or even a robot [5,6]. Wolpaw et al. [7] argue that BCIs "give their users communication and control channels that do not depend on the brain's normal output 2 Computational Intelligence and Neuroscience channels of peripheral nerves and muscles." In other words, BCI devices establish a communication channel between the individual and a component (electromechanical devices, robots, software applications, etc.) to control it by means of brain activity generated by the user to carry out some intended action [8]. To that effect, the user must call upon those actions by means of a brain strategy known as motor imagery.
Motor imagery (MI) is a conscious process defined as a mental simulation of a particular movement [9]. The motor imagery is endowed with the same functional relationship to the imagined or represented movement and the same causal role in the generation of the movement in question [10]. In other words, MI is related to the intention and preparation of movements, whereby the subject imagines carrying out a particular action without making any real movements. This has led to studies using motor imagery to decipher processes that precede the execution of an action. For instance, Bai et al. [11] claim that mental practice using motor imagery of limb movement may facilitate motor recovery in persons who have experienced cerebrovascular injuries. In addition, McFarland et al. [12] conducted a comparative analysis of EEG topographies associated with actual hand movements and imagined hand movements, concluding that motor imagery plays an important role in EEG-based communication and suggesting that mu and beta rhythms might provide independent control signals.
Similarly, there have been studies focusing on MI support and BCI systems, proposing algorithms for feature extraction and classification. For instance, Pfurtscheller et al. [13] studied the reactivity of mu rhythms associated with the imagination of hand, foot, and tongue movements with 60 EEG electrodes in nine able-bodied subjects (with a 66.16% performance rate). In turn, Aghaei et al. [14] argue for the use of the separable common spatiospectral patterns (SCSSP) method to extract discriminant spatiospectral EEG features and a Laplacian filter of data set V of BCI competition III with the following mental imagery tasks: left-hand movement, right-hand movement, and generation of words beginning with a random letter involving 3 subjects. As for Gao et al. [15], they conducted EEG signal analysis during lefthand movements, right-hand movements, and resting with 10 subjects using the Kolmogorov complexity to extract the features and an AdaBoost multiclass classifier, achieving a 79.5% accuracy rate. In a separate study, Schlögl et al. [16] conducted a comparative study involving four classifiers to determine the global separability of data in relation to four different MI tasks with 5 subjects, modelling the EEG signal by means of an adaptive autoregressive (AAR) process whose parameters were extracted through Kalman filtering. Trad et al. [17] used empirical mode decomposition (EMD) and band power (BP) to extract EEG signals and classify MI in experiments involving 10 subjects aged 22-35 as they imagined left-hand and right-hand movements. Choi and Cichocki [18] implemented a MI-based algorithm to control a wheelchair using spatial filters to extract the features by means of a common spatial pattern (CSP) method and the linear SVMs to classify feature vectors. Three healthy men participated in the experiments where they had to imagine clenching the right hand, squeezing the left hand, and walking. In [19] results of tests conducted with a 74% accuracy rate to control a robot indoors on the basis of three mental states are presented. In particular, there are several studies focusing on the development of processing techniques, feature extraction, and classification to improve the BCI systems. In Tables 1 and 2, we present the most commonly used algorithms for these tasks from Lotte' et al. works [20]. However, we only extracted information related to our work, that is, motor imagery activities (imagined movement of the left hand, imagined movement of the right hand, imagined movement of the foot, imagined movement of the tongue, relaxation, and mental calculation). These works use different algorithms in the classification stages, such as SVM, KNN, LDA, MLP, HMM, Gaussian classifier, and Bayes quadratic, including combinations of these, which result in most studies in acceptable performance rates. However, most experiments are performed on a small number of subjects, which returns a low number of trials per session. In the feature extraction stage, most techniques used to analyze EEG signals extract information within the frequency or timefrequency domain, which may lead to information loss when information is transformed. In addition, they require noiseelimination filters and frequency band localization to identify the patterns of motor imagery.
On the other hand, in [21], the design of a motor imagery experiment was reported based on three mental processes: arrow moving to the left, arrow moving to the right, and waiting time, lasting 5 seconds per image. This study analyzed EEG signals with the implementation of the quaternion-based signal analysis (QSA). The quaternionbased signal analysis (QSA) method is a technique that uses EEG signals within the time domain because it is based on quaternion algebra. The use of quaternion algebra with the QSA technique makes it possible to describe signals within the time domain by means of rotations and orientations of 3D objects and represent multichannel EEG signals as a single entity, preventing data ambiguity and producing a more accurate representation doing fewer calculations than are needed with other techniques. The offline analysis was conducted in the feature extraction phase considering the total number of samples in each class, which produced an 84.92% accuracy rate. However, while the analysis of offline signals is convenient and efficient, offline analysis results may not generalize their performance to online applications. In the case of the QSA method, the online analysis obtained was just 33.31% considering window sizes of 0.5 seconds.
Thus, this paper presents an improvement to the QSA method that we shall call improved quaternion-based signal analysis (iQSA) for use in the feature extraction and classification phases, whose contribution consists in providing a technique for use in real-time applications, focusing on analyzing EEG signals online reducing the sample sizes needed to a tenth of the ones required by QSA, resulting in a faster response and fewer delays to improve execution times in real-time actions. The experiment involved using an Emotiv-Epoc device to acquire the brain signals from the motor and visual regions of the cerebral cortex. Similarly, during the training and validation phases, the EEG signal   [44] database was strengthened by adding a greater number of subjects and by combining decision trees in the classification phase based on use of the boosting technique.

Quaternions. Quaternions were proposed in 1843 by
Hamilton [22], as a set of four constituents (a real and three imaginary components) as follows: = + + + , where , , , ∈ R and , , are symbols of three imaginary quantities known as imaginary units. These units follow these rules: where and a are known as the quaternion's scalar and vector, respectively. When = 0, is known as pure quaternion. Based on the expanded Euler's formula, the rotation for quaternion around the axis = [ , , ] by angle theta is defined as follows (see [21,45] for further details).
A rotation of angle around a unit vector a = [ , , ] is defined as follows: Furthermore, the operation to be performed on a vector r to produce a rotated vector r is Equation (4) is a useful representation that makes the rotation of a vector easier. We can see that r is the original vector, r is the rotated quaternion, and is the quaternion that defines the rotation.

iQSA Algorithm.
The iQSA is a method that improves the performance and precision of the QSA method, which is a technique to analyze EEG signals for extracting features based Computational Intelligence and Neuroscience 5 Table 3: Statistical features extracted using quaternions.

Statistical features Equation
on rotations and orientations by means of quaternion algebra. With iQSA, we can conduct real-time signal analysis as the signals are being acquired, to difference of QSA method who performs an offline analysis.
The iQSA approach consists of three modules: quaternion, classification, and learning, which are described as follows.
(1) Quaternion module: in this module a features matrix ( ) is defined from the description of the quaternion and a vector , where each of them corresponds to an array of 4 and 3 EEG channels, respectively. This module is divided into three steps, which are described as follows: (a) Sampling window: here, we define the sample size ( ) to be analyzed and a displacement of the window in the signal ( disp). That is, the iQSA method performs the sampling by means of superposing, producing a greater number of samples to reinforce the learning stage of the algorithm. (b) Calculate rotation and module: then, a rotated vector rot is calculated using the quaternion and vector , where is a -by-4 matrix containing quaternions and is an -by-3 matrix containing quaternions displaced on the basis of a value. Later, the modulus is applied to the quaternion rot resulting in the vector mod . (c) Building an array of features: finally, the array mod is used to form a matrix with , features, where corresponds to the analyzed segment and is one of the 4 features to be analyzed using the equations included in Table 3, that is, mean ( ), variance ( 2 ), contrast (con), and homogeneity ( ).
(2) Classification module: the aim of this module is to create a combination of models to predict the value of a class according to its characteristics; to do this we use the boosting method adapted to the QSA model. To be more specific, we combine ten decision trees and a weight is obtained for each of them, which will be used during the learning to obtain the prediction by a majority rule. Here, we take 70% of samples from , of which the 80% are used for training and the rest for validation as follows: (a) Training: the subset of training data (80% samples) is assessed, using the models of decision trees to obtain a matrix with accurately classified samples ( ) and a matrix with inaccurately classified samples ( ). The learning of each tree is done by manipulating the training data set and partitioning the initial set in several subsets according to the classification results obtained; that is, a new subset is formed, generated, and created with the accurately classified samples, twice that number of inaccurately classified samples and the worst-classified samples from the original training data set. Later, when the trees of classification are created, these are used with the test data set to determine a weight in function of the accuracy of their predictions. (b) Validation: in this block we obtain a matrix with the reliability percentages given by the decision trees. The subset of validation data (20% samples) is assessed, using the decision trees to obtain an array with reliability values given by the processing of decision trees and the classes identified in the training process.
(3) Learning module: in this module, the subset of test data of (30% samples) is assessed to obtain reliability values matrix ( ) and the prediction by majority rule (̂). That is, the learning process will be conducted assessing features matrix of test using the trees that have been generated in classification process. The final predictor comes from a weighted majority rule of the predictors from various decision trees. Equation (6) shows the recognition and error rates obtained in each of the prediction models. In this matrix RT corresponds to accuracy rate, ET corresponds to error rate, and corresponds to reliability value of each decision tree.
In Algorithm 1, we present the pseudocode for the main elements of the iQSA algorithm towards real-time applications.
6 Computational Intelligence and Neuroscience  Figure 1, we show through block diagrams the main differences between the iQSA and QSA methods. It can be observed that QSA method considers quaternion and classification modules. On the other hand, iQSA method considers an improved classification module and one more for learning.

iQSA versus QSA Methods. In
In Table 4, we present some of the main improvements made in the iQSA algorithm.
The QSA method, by its characteristics, is an excellent technique for the offline processing of EEG signals considering large samples of data and being inefficient when such data is small. This last becomes essential for online processing because the operations depend on the interaction in real time between the signals produced by the subject and the EEG signals translated with the aid of the algorithm. In this regard, the iQSA method considers small samples of data and creates a window with the superposition technique for a better data In this way, the signals produced by the iQSA algorithm affect the posterior brain signals, which in turn will affect the subsequent outputs of the BCI. Figure 2 presents the time system diagram of iQSA, which indicates the timeline of events in the algorithm. It follows the process of three EEG data blocks ( 1 , 2 , 3 ) obtained from the Emotiv-Epoc device. The processing block covers the analysis and processing of the data with the iQSA method until obtaining an output (OP), in this case, the class to which each block belongs.
It is also possible to observe the start and duration of the next two sets of data, where the start of block 2 is displaced from the progress of block 1 by a time represented as disp between −1 and 0 ; therefore, while the block 1 reaches the output at 2 , the process of 2 continues executing until reaching its respective output.

BCI System
. A brain-computer interface is a system of communication based on neural activity generated by the brain. A BCI measures the activity of an EEG signal by processing it and extracting the relevant features to interact in the environment as required by the user. An example of this device is the Emotiv-Epoc headset (Figure 3(a)), a noninvasive mobile BCI device with a gyroscopic sensor, and 14 EEG channels (electrodes) and two reference channels (CMS/DRL) with a 128 Hz sample frequency. The distribution of sensors in the headset is based on the international 10-20electrode placement system with two sensors as reference for proper placement on the head with channels labeled as AF3, F7, F3, FC5, T7, P7, O1, O2, P8, T8, FC6, F4, F8, and AF4 (Figure 3(b)).
An advantage of the Emotiv-Epoc device is its ability to handle missing values, very common and problematic when dealing with biomedical data.

Decision Trees and Boosting.
Decision trees (DT) [46][47][48] are a widely used and easy-to-implement technique that offers high speed and accuracy rates. DT are used to analyze data for prediction purposes. In short, they work by setting conditions or rules organized in a hierarchical structure where the final decision can be determined following conditions established from the root to its leaves.  Recently, several alternative techniques have been presented to construct sets of classifiers whose decisions are combined in order to solve a task and to improve the results obtained by the base classifier. There exist two popular techniques to build sets: bagging [49] and boosting [50]. Both methods operate under a base-learning algorithm that is invoked several times using various training sets. In our case, we implemented a new boosting method adapted to QSA method, whereby we trained a number of weak classifiers iteratively so that each new classifier (weak learner) focuses on finding weak hypothesis (inaccurately classified). In other words, boosting calls the weak learner times thus determining, at each iteration, a random subset of training samples by adding the accurately classified samples, twice that number of inaccurately classified samples and the worstclassified samples from the original training data set to form a new weak learner .
As a result, inaccurately classified samples of the previous iteration are given an ( ) weight in the next iteration, forcing the classifying algorithm to focus on data that are harder to classify in order to correct classification errors of the previous iteration. Finally, the reliability percentage of all the classifiers is added and a hypothesis is obtained by a majority vote, whose prediction tends to be the most accurate.

Channel Selection for iQSA.
From the 14 electrodes that the Emotiv-Epoc device provides, we decided to perform an analysis on the electrodes located in three different regions of the cerebral cortex looking for those with better performance to form the quaternion: (1) electrodes located on the motor cortex, which generates neural impulses that control movements, (2) those on the posterior parietal cortex, where visual information is transformed into motor instructions [51], and (3) the ones on the prefrontal cortex, which appear as a marker of the anticipations that the body must make to adapt to what is going to happen immediately after [52].
In this regard, in Table 5 we present the performance for each of the sets of channels that were selected and further analyzed by the iQSA algorithm. Comparing the data sets shown in Figure 4, it is observed that all have a similar behavior in each sample size. For a 64-sample analysis, data sets 2 and 4 obtained 82.30% and 82.33%, respectively. The channels for data set 2 are related to the frontal and motor areas of the brain and the channels for data set 4 are related to the parietal and motor areas. From these results and due to the fact that we mainly focus on motor control tasks, set 2 (F3, F4, FC5, and FC6) has been chosen.

Experiment
As seen in earlier sections, one of the objectives of this paper is to analyze EEG signals towards real-time applications. Therefore, it is necessary to reduce the number of samples of EEG signals that have been acquired by subjecting them to a process based on the iQSA method to decode motor imagery activities, while keeping or improving Computational Intelligence and Neuroscience 9  accuracy results achieved with this technique. In this way, the experiment was designed to register EEG signals from several individuals and to identify three motor-imageryrelated mental states (think left motion, think right motion, and waiting time).

Description of the Experiment.
The experiment was conducted in three sessions: Session 1 involved motor imagery with tagged visual support ( + ), that is to say, an arrow with the word LEFT or RIGHT written on it. Session 2 involved motor imagery with visual ( ) support only. In Session 3 the subject only received a tactile stimulus ( ) to evoke motor imagery while keeping his or her eyes closed. In each session, the aim was to identify three mental states (think left motion, think right motion, and waiting time). The visual and stimuli were provided using a GUI interface developed in Python 2.7 to show the movement of a red arrow for 5 seconds for each of the motor brain actions and a fixed cross at the center of the GUI to indicate a rest period for 3 seconds (the third brain action). The tactile stimulus was provided by touching the left/right shoulder of the individual to indicate the brain action to be performed. Each session lasted for 5 minutes and was done on separate days.
To start with, the participant was asked to sit on a comfortable chair in front of a computer screen. As the participant was given instructions regarding the test, an Emotiv-Epoc headset was placed on his or her head, making sure that each of the Emotiv device electrodes was making proper contact with the scalp (Figure 5). Once the participant was ready, he or she was asked not to make sudden body movements that could interfere with the signal acquisition results during the experiment.
The training paradigm consisted of a sequential repetition of cue-based trials ( Figure 5). Each trial started with an empty blank screen; during the time = 0 to = 3 s a cross was displayed to indicate to the user that the experiment had started and that it was time to relax. Then at second 3 ( = 3 s) an arrow appearing for 5 s pointed either to the left or to the right. Each position indicated by the arrow instructed the subject to imagine left or right movement, respectively. The next trial started at = 8 s with a cross. This process was repeated for 5 minutes, displaying the arrows 32 times and the cross 33 times within each run. Thus, the data set recorded for the three runs consisted of 96 trials.

iQSA Method Implementation.
After data acquisition, the next stage consists in extracting EEG signal features in order to find the required classes, that is, think left motion, think right motion, and waiting time. To start with, the iQSA method was implemented to represent the four EEG signals within a quaternion and to carry out the feature extraction related to the stimuli presented. To that effect, data set 2 was prepared to assess their performance when time ( Figure 6: Graphic description of the iQSA method. rot represent the rotation of with respect to ; mod is the module of rot ; class 1, class 2, and class 0 represent the motor activities evaluated, in this case "think left motion," "think right motion," and "waiting time," respectively. samples), and 0.5 seconds (64 samples) were considered. Values 0, 1, and 2 were used to refer to the three mental activities: waiting time (0), think left motion (1), and think right motion (2). So, a segments matrix was obtained to detect sudden changes between classes for each data set. The segments matrix consisted of samples from 32 trials from left and right classes and samples from 33 trials for the waiting time class. In addition, the quaternion was created with the block signals proposed (F3, F4, FC5, and FC6), considering F3 as the scalar component and F4, FC5, and FC6 as the imaginary components ( Figure 6). From the samples to be analyzed, several segments were created to generate the quaternion and vector with a displacement = 4 and thus obtain the rotation ( rot ) and modulus ( mod ).
Once the module was obtained, the mean ( ), contrast (con), homogeneity ( ), and variance ( 2 ) features were calculated to generate the matrix and the vector with the required classes. Later, we returned to the current segment, and a displacement of 64 samples for the signal was effected to obtain the next segment.
Later, M was used in the processing stage using 70% of data from training and 30% from test; here each class has the same sample size and was randomly chosen. In the classification module, we generate the matrix 1 with the 80% from training data of and 2 with the remaining 20% of the training data, which will be used for training and validation, where 10 training trees were created to force the algorithm to focus on the inaccurately classified data.
Here, for each iteration we generate new subsets of samples with the double of inaccurately classified samples and fewer accurately classified samples, along with a reliability rate for each tree. Later, with matrix 2 the data were validated to obtain the percentage of reliability of each tree. Finally, with the remaining data of , a prediction by majority rule is voted and a decision is reached based on the reliability rate of each classification tree.

Results
As said earlier, one of the aims of this study was to reduce the assessment time (sample size) without loss of the accuracy rate. Therefore, a comparison of the iQSA and QSA techniques was performed to show its behavior when the number of samples decreases.   In spite of the good performance rates reported with the QSA algorithm for offline data analysis, the classification results were not as good when the number of samples was reduced up to 64 samples as shown in Figure 7(a). Graphically, as can be seen, the error rate increases gradually when the sample size is reduced for analysis, reaching up to 66.56% error for a reading of 64 samples. In this way, it was necessary to make several adjustments to the algorithm, in such a way as to support an online analysis with small samples sizes, without losing information and sacrificing the good performance rates provided by the offline QSA algorithm.

Comparison between iQSA and QSA
Thus, the data of the 39 subjects were evaluated, considering three cases: (1) QSA method without window samples, (2) QSA method with window samples, and (3) iQSA proposed method. Comparing the results of Table 6, the precision percentages for the iQSA method range from 73.16% for 384 samples to 82.30%% for 64 samples, unlike the original QSA method whose percentage decreases to 33.31% for 64 samples in case 1 and 33.44% in case 2 although the sampling window has been implemented. Figure 8 shows the behavior of the iQSA technique in blue and QSA technique in red, where the mean, maximum, and minimum of each technique are shown. Comparing both techniques, it is observed that the data analyzed with the original QSA method drastically loses precision as the number of samples selected decreases. This was not the case for data sets using the iQSA technique whose precision did not vary too much when the number of samples for classification was reduced, improving even its performance.

4.2.
iQSA Results. Figure 9 shows the behavior of 39 participants under both techniques (iQSA and QSA), considering all the sample sizes. The values obtained using the iQSA method are better than values obtained with QSA method whose values are below 50%. Numerical results show that the iQSA method provides a higher accuracy over the original QSA method for tests with a 64-sample size.
Given the above results, a data analysis was conducted using 64 samples to identify the motor imagery actions. The performances obtained with the set of classifiers were compared using various assessment metrics, such as recognition rate (RT) and error rate (ET), and sensitivity ( )  and specificity (Sp). The sensitivity metric shows that the classifier can recognize samples from the relevant class, and the specificity is also known as the real negative rate because it measures whether the classifier can recognize samples that do not belong to the relevant class.
As Table 7 shows, the highest accuracy percentage was 84.50% and the lowest 68.75%. In addition, the sensitivity average for class 0 ( 0 ) associated with the waiting time mental state was 82.53%, and the sensitivity average for class 1 ( 1 ) and class 2 ( 2 ) associated with think left motion and think right motion was 81.07% and 81.65%, respectively, which indicates that the classifier had no problem classifying classes. In turn, the specificity rate for class 0 (Sp 0 ) shows that 81.36% of the samples classified as negative were actually negative, while class 1 (Sp 1 ) performed at 82.09% and class 2 (Sp 2 ) at 81.80%.
To evaluate the performance of our approach, we have carried out a comparison with other methods such as FDCSP [53], MEMD-SI-BCI [54], and SR-FBCSP [55] using data set 2a from BCI IV [56] and the results are shown in Table 8. Our method shows a slight improvement (1.09%) compared to the SR-FBCSP method, which presents the best results of the three.
To analyze our results, we performed a significant statistical test making use of the STAC (Statistical Tests for Algorithms Comparison) web platform [57]. Here, we chose the Friedman test with a significance level of 0.10 to get a ranking of the algorithms and check if the differences between them are statistically significant. Table 9 shows the Friedman test ranking results obtained with the value approach. From such table, we can observe that our proposal gets the lowest ranking; that is, iQSA has the best results in accuracy among all the algorithms.
In order to compare whether the difference between iQSA and the other methods is significant, a Li post hoc procedure was performed (Table 10). The differences are statistically significant because the values are below 0.10.
In addition, the classification shown in Table 8 is achieved by the iQSA in real time and compared to the other methods a prefiltering process is not required.
In Table 11, we show the time required for each of the tasks performed by the iQSA algorithm: (1) features extraction, (2) classification, and (3) learning. The EEG signal analysis in processes 1 and 2 was responsible for obtaining the quaternion from the EEG signals, learning trees, and training. Process 3 evaluates and classifies the signal based on the generated decision trees, as should be done in real-time analysis.
According to the experiment, for offline classification (processes 1 and 2), the processing time required was 0.3089 seconds. However, the time required to recognize the motor imagery activity generated by the subject was of 0.0095 seconds, considering that the learning trees were already generated, and even when the processing phase was done in real time, it would take 0.3184 seconds to recognize a pattern after the first reading. With this, our proposed method can be potentially used in several applications such as controlling a robot, manipulating a wheelchair, or controlling home appliances, to name a few.
As said earlier, the experiment consisted of 3 sessions with each participant (visual tagged, visual, and tactile). The average accuracy obtained from the 3 experiments is between 76% and 78%. Figure 10 shows results from the visual stimulation session, which produced the lowest rate at 76.63%, followed by tagged visual session which reached 76.98% and the tactile session 77.28%. In Figure 10, it is shown that the mental activity generated with the aid of a tactile stimulus is slightly more accurate than visual and visual tagged stimuli where recognition is more imprecise and slow with visual stimulus.
To summarize, the results of tests conducted with 39 participants using this new method to classify motor imagery brain signals, 20 times with each participant, considering 70%-30% of the data have been presented and creating several subsets of 80-20% for the classification process. The average performance accuracy rate was 81.75% when using 10 decision trees in combination with the boosting technique at 0.5-second sampling rates. The results show that this methodology for monitoring, representing, and classifying EEG signals can be used for the purposes of having individuals control external devices in real time.    Table 11: Execution time of iQSA method.

Conclusions
Feature extraction is one of the most important phases in systems involving BCI devices. In particular, feature extraction applied to EEG signals for motor imagery activity discrimination has been the focus of several studies in recent times. This paper presents an improvement to the QSA method known as iQSA, for EEG signal feature extraction with a view to using it in real time with mental tasks involving motor imagery. With our new iQSA method, the raw signal is subsampled and analyzed on the basis of a QSA algorithm to extract features of brain activity within the time domain by means of quaternion algebra. The feature vector made up of mean, variance, homogeneity, and contrast is used in the classification phase to implement a set of decision-tree classifiers using the boosting technique. The performance achieved using the iQSA technique ranged from 73.16% to 82.30% accuracy rates with readings taken between 3 seconds and half a second. This new method was compared to the original QSA technique, whose accuracy rates ranged from 40.82% to 33.31% without sampling window and from 41.07% to 33.34% with sampling window. We can thus conclude that iQSA is a promising technique with potential to be used in motor imagery recognition tasks in real-time applications.

Conflicts of Interest
The authors declare that there are no conflicts of interest regarding the publication of this paper.