Quaternion-Based Signal Analysis for Motor Imagery Classification from Electroencephalographic Signals

Quaternions can be used as an alternative to model the fundamental patterns of electroencephalographic (EEG) signals in the time domain. Thus, this article presents a new quaternion-based technique known as quaternion-based signal analysis (QSA) to represent EEG signals obtained using a brain-computer interface (BCI) device to detect and interpret cognitive activity. This quaternion-based signal analysis technique can extract features to represent brain activity related to motor imagery accurately in various mental states. Experimental tests in which users where shown visual graphical cues related to left and right movements were used to collect BCI-recorded signals. These signals were then classified using decision trees (DT), support vector machine (SVM) and k-nearest neighbor (KNN) techniques. The quantitative analysis of the classifiers demonstrates that this technique can be used as an alternative in the EEG-signal modeling phase to identify mental states.


Introduction
The interest in establishing direct communication between the brain and other external devices using electroencephalographic (EEG) signals has increased with the use of brain-computer interface (BCI) systems. According to Wolpaw [1], "BCI interfaces allow to record the brain signals of an individual, extract their characteristics and turn them into artificial outputs that operate outside or in your own body". In other words, the interface establishes a channel of communication and control between an individual and an external device. BCI systems use EEG activity to perform various tasks, such as controlling cursor movements [2], browsing the web [3,4], selecting letters or icons [5][6][7][8], communicating with virtual environments (e.g., in games) [9,10], robot navigation [11][12][13], controlling a wheelchair [14][15][16][17] or operating prosthetics [18][19][20], among others.
By nature, EEG signals are non-linear and non-stationary. Usually, these signals are processed and analyzed using various mathematical methods to gather information regarding the frequency components and, in turn, the functional relationships between brain areas. The most-commonly used techniques in the analysis are the fast Fourier transform (FFT), power spectral density (PSD), Hjorth parameters and the discrete wavelet transform (DWT). Several strategies have been presented to analyze brain signals by extracting and classifying EEG signals for cognitive-movement detection purposes. For instance, Hongyu [21] presents an on-line classification method for BCI based on common spatial patterns (CSP) for feature extraction, using support vector machine (SVM) as a classifier for imagined hand and foot movements achieving accuracy results of 86.3%, 91.8% and 92.0% with three subjects. Similarly, Bhattacharyya [22] conducted a study of comparative performance analysis of different classifiers, linear discriminant analysis (LDA), quadratic discriminant analysis (QDA), k-nearest neighbor (KNN), linear SVM, radial basis function (RBF) SVM and naïve Bayesian) to differentiate EEG signals for left-right limb movement, with SVM being the most accurate at 82.14%. In turn, Jiralerspong [23] conducted an experimental test of three mental states using FFT with a hamming window function that resulted in a 72% recognition rate. These strategies show good accuracy rates, but the information is extracted within a frequency or time-frequency domain, thereby losing vital information. On the other hand, some studies have been conducted based on multi-scale entropy (MSE) analysis to detect features of biological signals, as shown in [24], where Costa, et al. present a generalization of multi-scale entropy to analyze the structure of time series of heartbeats. Similarly, Mossabber [25] uses multivariate multi-scale entropy (MMSE) as a generalization of MSE to be adapted for biological and physical systems. Morabito, et al. [26] also use a multivariate multi-scale methodology to assess the complexity of physiological systems by means of permutation entropy whereby time series are processed in segments. However, the analysis does not appear to analyze several signals at the same time, and the performance of signals is based on patterns, which results in magnitude being weighted differently.
An alternative would be to conduct the signal analysis within a time domain. Quaternions can be an alternative to model EEG signals because they provide us with a mathematical notation to represent object orientations and rotations three-dimensionally, which makes it possible to represent EEG multichannel signals beyond what traditional methods allow. Recent studies have used quaternion algebra with traditional methods. For instance, Furman [27] uses the so-called quaternion Fourier transform (QFT) to process 3D images, and claims that the rotation operation is faster than when using a matrix-based method. In addition, Zhao [28] uses quaternion principle component analysis (QPCA) to represent EEG multichannel epilepsy signals with better results than those obtained using a traditional approach.
There are some considerable advantages in using quaternions, and thus a new technique to represent EEG signals visually using quaternion algebra to classify brain activity in relation to visual cues is presented here. The visual representation, extraction and classification of EEG features correspond to the cognitive activity recorded as the brain processes motor images. Motor imagery can be defined as a mental process linked to a motor action without any overt motor output [29]. In the case of this study, three kinds of visual cues were used: left, right and waiting time. As a result, EEG signals gathered using the BCI device were divided into blocks that contained information from only four of the 14 sensors. Each block was represented using quaternions to extract the signal features, and were later classified (off-line) using three techniques: KNN, SVM and decision trees (DT). Finally, the various classification results obtained when detecting classes were used to validate the performance levels.
This paper is organized as follows: Section 2 is an introduction to quaternions, BCI systems and classifiers; Section 3 includes a description the QSA technique; Section 4 accounts for the experimental tests; Section 5 features a discussion of the QSA implementation results; and Section 6 ends with some conclusions.

Preliminaries
This section provides a brief but accurate description of the key elements used to develop the study that is, quaternion algebra and the BCI device used to acquire the brain signals.

Quaternions
Quaternions were proposed in 1843 by Hamilton [30], as a set of four constituents (one real component and three imaginary) of the form: q = w + ix + jy + kz, where w, x, y, z P R and i, j, k are symbols of three imaginary quantities known as imaginary units. These units follow these rules: ij " k, jk " i, ki " j ji "´k, kj "´i, ik "´j A quaternion can be described as: where s and v are known as the quaternion's scalar and vector, respectively. When s = 0, q is known as a pure quaternion. Table 1 summarizes the basic operations of quaternion algebra, where q and p are two quaternions, whilst the dot and the cross represent the usual scalar and vector products. Table 1. Operations using quaternions q and p.

Operation Formulae
Addition Note that the multiplication of quaternions is a not a commutative operation; instead, it is associative and distributive in relation to the addition.
Quaternions with a norm equal to one are known as unit (or normalized) quaternions. If q is a unit quaternion, it can be written as [31]: where cosθ " s, sinθ " ||v|| and u " v{||v||. Equally, the previous equation can be used to represent vector rotations. q " cosθ`sinθ e " ba´1 (4) where a and b are any two vectors having the same length, the angle between a and b is θ, e is perpendicular to both a and b, and a, b, and e form a right-handed set. For a rotation of angle θ around a unit vector a, q must be formed thus: Furthermore, the operation to be performed on a vector r to produce a rotated vector r' is: Equation (6) 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 q is the quaternion that defines the rotation.

BCI System
BCI devices capture brain signals of individuals that will be subsequently processed and analyzed. Depending on how signals are captured, BCI devices are classified as invasive and non-invasive. The Emotiv Epoc headset ( Figure 1a) is a non-invasive 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-20 electrode placement system with two sensors as reference for proper placement on the head. This device obtains the brain activity of an individual, and is able to detect and process their thoughts, feelings and expressions in real time. Based on the 10-20 system, the channels are: AF3, F7, F3, FC5, T7, P7, O1, O2, P8, T8, FC6, F4, F8, and AF4 ( Figure 1b). Equation (6) 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 q is the quaternion that defines the rotation.

BCI System
BCI devices capture brain signals of individuals that will be subsequently processed and analyzed. Depending on how signals are captured, BCI devices are classified as invasive and noninvasive. The Emotiv Epoc headset ( Figure 1a) is a non-invasive 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-20 electrode placement system with two sensors as reference for proper placement on the head. This device obtains the brain activity of an individual, and is able to detect and process their thoughts, feelings and expressions in real time. Based on the 10-20 system, the channels are: AF3, F7, F3, FC5, T7, P7, O1, O2, P8, T8, FC6, F4, F8, and AF4 ( Figure 1b).

Description of Classifiers
In this study, we used several classification algorithms: decision tree, support vector machine and k-nearest neighbor. DT [32][33][34] is a widely-used and easy-to-implement classification technique used to analyze data for prediction purposes. It consists of a set of conditions or rules organized in a hierarchical structure where the final decision can be determined following conditions established from the root to its leaves. SVM [35][36][37] refers to supervised learning models used to classify data into two categories by finding an optimal hyperplane that separates two possible values for the variable ∈ +1, −1}. If the data can be separated linearly, the hyperplanes divide SVM input data into two initial subgroups by assigning {−1, +1} tags. KNN [38] is a non-parametric approach used to solve classification and regression problems, based on the assumption that an object's class is the same as that of its closest neighbors.
Both decision trees and KNN are designed to handle multi-class problems, which is not the case for the SVM classifier as this is an algorithm originally developed for use with two classes only. However, the classification can be expanded to more than two classes by combining binary classifiers, that is, by generating a classifier for the d classes available. For instance, it could be used thus: classifier 1 (class 0 vs. class 1 and class 2), classifier 2 (class 1 vs. class 0 and class 2), classifier 3 (class 2 vs. class 0 and class 1). A decision function is used subsequently to group them and assess the class they belong to following this criterion: class 0 (1 0 0), class 1 (0 1 0) and class 2 (0 0 1).

Proposed Method
In signal-pattern recognition, each sample is represented by a collection of descriptors that will

Description of Classifiers
In this study, we used several classification algorithms: decision tree, support vector machine and k-nearest neighbor. DT [32][33][34] is a widely-used and easy-to-implement classification technique used to analyze data for prediction purposes. It consists of a set of conditions or rules organized in a hierarchical structure where the final decision can be determined following conditions established from the root to its leaves. SVM [35][36][37] refers to supervised learning models used to classify data into two categories by finding an optimal hyperplane that separates two possible values for the variable y P t`1,´1u. If the data can be separated linearly, the hyperplanes divide SVM input data into two initial subgroups by assigning {´1, +1} tags. KNN [38] is a non-parametric approach used to solve classification and regression problems, based on the assumption that an object's class is the same as that of its closest neighbors.
Both decision trees and KNN are designed to handle multi-class problems, which is not the case for the SVM classifier as this is an algorithm originally developed for use with two classes only. However, the classification can be expanded to more than two classes by combining binary classifiers, that is, by generating a classifier for the d classes available. For instance, it could be used thus: classifier 1 (class 0 vs. class 1 and class 2), classifier 2 (class 1 vs. class 0 and class 2), classifier 3 (class 2 vs. class 0 Sensors 2016, 16, 336 5 of 17 and class 1). A decision function is used subsequently to group them and assess the class they belong to following this criterion: class 0 (1 0 0), class 1 (0 1 0) and class 2 (0 0 1).

Proposed Method
In signal-pattern recognition, each sample is represented by a collection of descriptors that will be segmented and classified. Thus, the characterization of signals, in this case EEG signals, is essential to determine the performance and accuracy of the final classification process. As mentioned in Section 1, the analysis in the frequency domain is a common technique used when extracting features of EEG signals; for instance, the Fourier transform, short Fourier transform or wavelet transform are commonly used. However, the use of quaternion algebra is proposed as a novel tool to extract EEG-signal features that simplifies the final classification task. EEG signals can be described using quaternion-based rotations and orientations, as shown earlier. Vector rotations are usually described by the rotation matrix or Euler angles [39], and quaternions can be advantageous for three reasons: (1) they avoid ambiguities in the data; (2) they allow a more accurate representation of the data; and (3) they require fewer calculations than other rotational techniques.
The proposed so-called quaternion-based signal analysis (QSA) method described in Algorithm 1 ( Table 2) can be used to model multichannel EEG signals using quaternions, taking a set of input signals as a single entity, and converting it into a pure quaternion.
For each y i (t) do return [R,pr] Thus, the multichannel EEG information is represented using quaternions to characterize signals recorded for 10 min during each test, and classified after further processing subsequently. Algorithm 1 can be described as follows: Line 1 defines the input data: delta (dt) movements in time t, signals to be analyzed (signals) and blocks with the channels to be analyzed (nblocks), where each block includes signals from four channels, and pr is a flag to indicate whether the sample is being used during validation or training. Line 2 calculates the segments matrix y(t) defined by changes between the three classes (left, right and waiting time) from the pool of signals contained in nblocks. The quaternions array quat, at line 3, is created using the channels included in nblocks. Line 4 dictates that for each segment y i , q(t) and r(t) are formed considering that q(t) is an array with n quaternions (line 4a) and r(t) is an array with n pure quaternions moved according to a dt value (line 4b). After this, the rotation q rot (t) is calculated using quaternions q(t) and r(t) (line 4c), which produces an array of n rotated quaternions. Line 4d calculates the scalar array q mod (t) from the module q rot (t), which contains n scalar elements that will be used at line 4e to form a matrix with M i,j features, where index i corresponds to the analyzed segment and index j is one of the m features to be analyzed using the equations included in Table 3. Line 4f gives shape to vector c i using the classes assigned to each segment y i . In addition, matrix M k,j is created using k-th data for the training phase at a %t rate (line 5) and matrix M l,j , together with the remainder of the original matrix M ij , is used to create the validation where index l corresponds to the elements used in the validation process in a 1´%t proportion to the analyzed segment (line 6). Thus, in lines 7 and 8 data are trained and/or validated by calling the function ProcQSA() and returning a vector R using classesĈ k (class aimed for training purposes) and C l (class aimed for validation purposes). In the function ProcQSA(), during the training phase, matrix Mt data are assessed using DT, KNN or SVM classifiers, adjusting the parameters for each classifier. Finally, the accuracy percentages are calculated during the training and validation phases (lines 9 and 10). Table 3. Statistical features extracted using quaternions.

Statistical Features Equation
Mean pµq " Table 3 shows the formulae used to extract features by Haralick [40] and adapted for use with quaternion algebra to implement the QSA model. Equation (7) shows matrix M with its features vector. In this matrix columns correspond to features and rows to samples. The features vector consists of the average, variance, contrast and homogeneity.

Description of the Experimental Tests
This section outlines the steps followed to implement the proposed QSA method (Algorithm 1) with EEG signals obtained from various participants for the purposes of detecting three mental states: thinking "left", "right" and "waiting time", with no need for any movement or word.
First of all, the technique consists in representing the EEG signals as a single quaternion. For experimental testing, one channel of the EEG signal is used as the real component and three more channels as the imaginary components. After that, feature computation provides the input data for the KNN, SVM and DT classifiers. EEG signals are acquired using the Emotiv Epoc headset (shown above in Figure 1a). The graphic user interface used to analyze the acquired signals is Python-based, and the feature selection and extraction is programmed using Matlab R2014a ® . The following subsections include detailed descriptions of each stage of the block diagram ( Figure 2). EEG signals are acquired using the Emotiv Epoc headset (shown above in Figure 1a). The graphic user interface used to analyze the acquired signals is Python-based, and the feature selection and extraction is programmed using Matlab R2014a ® . The following subsections include detailed descriptions of each stage of the block diagram ( Figure 2).

EEG Signal Acquisition
For signal acquisition purposes, the BCI's cognitive mode was used, given that motor activities were one of the cognitive processes involved in producing movement, which was the key focus of the tests. The experiment was conducted with 10 participants of several ages, both male and female. The time for each individual test was 10 consecutive minutes, during which three elements appeared on the screen: an arrow pointing to the left and moving in that direction, a cross representing rest time and an arrow pointing to the right and moving in that direction (see Figure 3). The left and right arrows alternate after appearing for 10 s (test mode) with a 5 s rest time in between during which a cross appeared at the center of the screen. In other words, a total of 40 arrows were shown alternately for 10 min, with 5 s breaks between each alternation. The purpose of the experiment was to make the participant think or imagine movement while the arrow appeared on the screen. In addition, during the test mode, participants were asked to remain motionless and avoid sharp body movements that could interfere with the signal being recorded, which they did, but were then allowed to move freely during rest time. States 0, 1 and 2 were used to refer to the three elements: waiting time (0), left (1) and right (2) during the classification phase. The number of samples recorded during the EEG data acquisition phase from each of the 10 participants amounts to 76,800, considering eight of the 14 available channels on the Emotiv Epoc device in relation to activity in the motor and frontal areas of the brain. Later, the samples were combined (Table 4) to form signal blocks (nblocks) that were then used as input in Algorithm 1 in order to find the channel with the best performance.

EEG Signal Acquisition
For signal acquisition purposes, the BCI's cognitive mode was used, given that motor activities were one of the cognitive processes involved in producing movement, which was the key focus of the tests. The experiment was conducted with 10 participants of several ages, both male and female. The time for each individual test was 10 consecutive minutes, during which three elements appeared on the screen: an arrow pointing to the left and moving in that direction, a cross representing rest time and an arrow pointing to the right and moving in that direction (see Figure 3). The left and right arrows alternate after appearing for 10 s (test mode) with a 5 s rest time in between during which a cross appeared at the center of the screen. In other words, a total of 40 arrows were shown alternately for 10 min, with 5 s breaks between each alternation. The purpose of the experiment was to make the participant think or imagine movement while the arrow appeared on the screen. In addition, during the test mode, participants were asked to remain motionless and avoid sharp body movements that could interfere with the signal being recorded, which they did, but were then allowed to move freely during rest time. States 0, 1 and 2 were used to refer to the three elements: waiting time (0), left (1) and right (2) during the classification phase. EEG signals are acquired using the Emotiv Epoc headset (shown above in Figure 1a). The graphic user interface used to analyze the acquired signals is Python-based, and the feature selection and extraction is programmed using Matlab R2014a ® . The following subsections include detailed descriptions of each stage of the block diagram ( Figure 2).

EEG Signal Acquisition
For signal acquisition purposes, the BCI's cognitive mode was used, given that motor activities were one of the cognitive processes involved in producing movement, which was the key focus of the tests. The experiment was conducted with 10 participants of several ages, both male and female. The time for each individual test was 10 consecutive minutes, during which three elements appeared on the screen: an arrow pointing to the left and moving in that direction, a cross representing rest time and an arrow pointing to the right and moving in that direction (see Figure 3). The left and right arrows alternate after appearing for 10 s (test mode) with a 5 s rest time in between during which a cross appeared at the center of the screen. In other words, a total of 40 arrows were shown alternately for 10 min, with 5 s breaks between each alternation. The purpose of the experiment was to make the participant think or imagine movement while the arrow appeared on the screen. In addition, during the test mode, participants were asked to remain motionless and avoid sharp body movements that could interfere with the signal being recorded, which they did, but were then allowed to move freely during rest time. States 0, 1 and 2 were used to refer to the three elements: waiting time (0), left (1) and right (2) during the classification phase. The number of samples recorded during the EEG data acquisition phase from each of the 10 participants amounts to 76,800, considering eight of the 14 available channels on the Emotiv Epoc device in relation to activity in the motor and frontal areas of the brain. Later, the samples were combined (Table 4) to form signal blocks (nblocks) that were then used as input in Algorithm 1 in order to find the channel with the best performance. The number of samples recorded during the EEG data acquisition phase from each of the 10 participants amounts to 76,800, considering eight of the 14 available channels on the Emotiv Epoc device in relation to activity in the motor and frontal areas of the brain. Later, the samples were combined (Table 4) to form signal blocks (nblocks) that were then used as input in Algorithm 1 in order to find the channel with the best performance. Figure 4 shows the signals acquired from block 1 for 5 s.   1  FC5  FC6  P7  P8  2  FC5  FC6  T7  T8  3  FC6  FC5  P7  P8  4  FC6  FC5  T7  T8  5  F3  F4  FC5  FC6  6  F3  F4  FC5  FC6  7  F4  F3  FC5  FC6  8  F4  F3  T7  T8  9  T7  T8  FC5  FC6  10  T7 T8 P7 P8 Figure 4 shows the signals acquired from block 1 for 5 s.

QSA Method Implementation
After acquiring the data in the previous step, the next phase consisted of extracting EEG signal features to find the desired classes (thinking "left", "right" and "waiting time"). First, the QSA method was implemented (Algorithm 1) to represent EEG signal blocks as shown in Table 4, and to extract the features related to the cues shown. In these experiments pre-processing was not required. Thus, to detect sharp changes between classes a segments matrix y(t) was obtained using 1200 samples for each 10 s acquired for "left" and "right" classes, and 600 samples for the "waiting time" class obtained for each 5 s-long breaks. In addition, the quaternion (quat) emerged from block signals considering the first channel as the scalar component and the remaining ones as the imaginary components, as shown in Figure 5. Later, q(t) and r(t) were calculated, the latter with its relevant dt movement. As for the movement, several tests were conducted using different dt values for each block. In other words, a dt movement of 1 to 10 was used in multiples of 7.8 ms (sample period) at point in time t to find out its impact on the classification accuracy percentage. Rotation qrot was calculated using q(t) and r(t), as well as qmod using the result of rotation qrot. Once the module was obtained, the four features included in Table 3 (Mean, Contrast, Homogeneity and Variance) were calculated to generate matrix Mi,j and vector ci (where i represents the segments of y(t) and j represents the features). The resulting matrix Mi,j was using during the training and classification process to infer the mental state and the required class.

QSA Method Implementation
After acquiring the data in the previous step, the next phase consisted of extracting EEG signal features to find the desired classes (thinking "left", "right" and "waiting time"). First, the QSA method was implemented (Algorithm 1) to represent EEG signal blocks as shown in Table 4, and to extract the features related to the cues shown. In these experiments pre-processing was not required. Thus, to detect sharp changes between classes a segments matrix y(t) was obtained using 1200 samples for each 10 s acquired for "left" and "right" classes, and 600 samples for the "waiting time" class obtained for each 5 s-long breaks. In addition, the quaternion (quat) emerged from block signals considering the first channel as the scalar component and the remaining ones as the imaginary components, as shown in Figure 5. Later, q(t) and r(t) were calculated, the latter with its relevant dt movement. As for the movement, several tests were conducted using different dt values for each block. In other words, a dt movement of 1 to 10 was used in multiples of 7.8 ms (sample period) at point in time t to find out its impact on the classification accuracy percentage. Rotation q rot was calculated using q(t) and r(t), as well as q mod using the result of rotation q rot . Once the module was obtained, the four features included in Table 3 (Mean, Contrast, Homogeneity and Variance) were calculated to generate matrix M i,j and vector c i (where i represents the segments of y(t) and j represents the features). The resulting matrix M i,j was using during the training and classification process to infer the mental state and the required class.

Classification
During the training and validation stages, several samples were taken to create submatrix Mk,j using 30% of Mi,j on condition that the data contained examples of the three classes required, that is, "left" (1), "right" (2) and "waiting time" (0). In addition, to create matrix Mm,n during the piloting phase, 70% of the data were used. In this study, the training and validation process was conducted using three classifiers: (1) decision tree based on input and predictor variables; (2) SVM using a kernel-type Gaussian RBF with a default scaling factor; and (3) KNN, which uses the Euclidean distance with a number of default Matlab-selected neighbors. The classification process was repeated 20 times for each of the 10 movements mentioned in each block. The methodology was applied to each of the 10 participants with the following results: 10 participants × 10 blocks × 10 dt × 20 repeats.
Considering all these parameters, a detailed analysis of the performance and best accuracy for each classifier for various signal blocks and movements is presented in the following sections.

Results and Discussion
The accuracy percentages obtained during the classification phase are shown in Table 5. The table presents the accuracy rate for the three classifiers for each dt movement. As can be seen, with a movement dt = 4, DT is the classifier with the best classification percentages at 84.92%, followed by KNN at 84.34%. In contrast, when the movement was dt = 2, KNN was 84.39%. Finally, SVM recorded the lowest classification percentages, such as 77.49% for dt = 4.  Figure 6, in turn, shows the graphs that correspond to Table 5 data. Figure 6a shows the symmetry of data for the three classifiers. In addition, in Figure 6, both (a) and (b) show that data for DT and KNN are both close to 84%, while the SVM mean was recorded as 78%.

Classification
During the training and validation stages, several samples were taken to create submatrix M k,j using 30% of M i,j on condition that the data contained examples of the three classes required, that is, "left" (1), "right" (2) and "waiting time" (0). In addition, to create matrix M m,n during the piloting phase, 70% of the data were used. In this study, the training and validation process was conducted using three classifiers: (1) decision tree based on input and predictor variables; (2) SVM using a kernel-type Gaussian RBF with a default scaling factor; and (3) KNN, which uses the Euclidean distance with a number of default Matlab-selected neighbors. The classification process was repeated 20 times for each of the 10 movements mentioned in each block. The methodology was applied to each of the 10 participants with the following results: 10 participantsˆ10 blocksˆ10 dtˆ20 repeats.
Considering all these parameters, a detailed analysis of the performance and best accuracy for each classifier for various signal blocks and movements is presented in the following sections.

Results and Discussion
The accuracy percentages obtained during the classification phase are shown in Table 5. The table presents the accuracy rate for the three classifiers for each dt movement. As can be seen, with a movement dt = 4, DT is the classifier with the best classification percentages at 84.92%, followed by KNN at 84.34%. In contrast, when the movement was dt = 2, KNN was 84.39%. Finally, SVM recorded the lowest classification percentages, such as 77.49% for dt = 4.   Figure 6, in turn, shows the graphs that correspond to Table 5 data. Figure 6a shows the symmetry of data for the three classifiers. In addition, in Figure 6, both (a) and (b) show that data for DT and KNN are both close to 84%, while the SVM mean was recorded as 78%. On the other hand, Figure 6b shows the accuracy of the various classifiers. Note that parameter "dt" does not alter the accuracy of the results and as a result does not affect the QSA model. Table 6 shows the signal block performance results for the 10 blocks under analysis. Block 1 had the best results for DT and KNN with an accuracy in excess of 86% for both classifiers at movements of 1 and 3. As for SVM, it achieved an accuracy rate of 78% in block 4 with a movement dt = 8. Table 6. Best accuracy rates for signal blocks using classifiers DT, KNN and SVM.

Classifier
Signal  Table 7 shows that block 1 achieved the best average results for DT and KNN, unlike SVM which performed at its best in block 3. Table 7. Average accuracy rate for signal blocks using classifiers DT, KNN and SVM.

Classifier
Signal  Figure 7 shows the behavior of blocks by classifier. As can be seen, blocks 1 and 3 stand out for all three classifiers. In contrast, block 6 shows a poor performance for DT at 84.44%, block 9 produced poor results for KNN at 83.04% and block 7 did likewise for SVM at 77.02%. On the other hand, Figure 6b shows the accuracy of the various classifiers. Note that parameter "dt" does not alter the accuracy of the results and as a result does not affect the QSA model. Table 6 shows the signal block performance results for the 10 blocks under analysis. Block 1 had the best results for DT and KNN with an accuracy in excess of 86% for both classifiers at movements of 1 and 3. As for SVM, it achieved an accuracy rate of 78% in block 4 with a movement dt = 8. Table 6. Best accuracy rates for signal blocks using classifiers DT, KNN and SVM.

Classifier
Signal  Table 7 shows that block 1 achieved the best average results for DT and KNN, unlike SVM which performed at its best in block 3. Table 7. Average accuracy rate for signal blocks using classifiers DT, KNN and SVM.

Classifier
Signal  Figure 7 shows the behavior of blocks by classifier. As can be seen, blocks 1 and 3 stand out for all three classifiers. In contrast, block 6 shows a poor performance for DT at 84.44%, block 9 produced poor results for KNN at 83.04% and block 7 did likewise for SVM at 77.02%. Therefore, the best accuracy results were obtained by block 1 with a movement dt = 4. Table 8 and Figure 8 show the behavior of data obtained for each participant in block 1. Therefore, the best accuracy results were obtained by block 1 with a movement dt = 4. Table 8 and Figure 8 show the behavior of data obtained for each participant in block 1.   metrics, such as recognition rate (RT) and error rate (ET). However, according to Ibarra [41], these metrics do not always suffice to assess a classification method. For instance, in some cases the estimate of the recognition rate may not contain enough information to be assessed. Therefore, further metrics ought to be used, such as sensitivity (Sd) and specificity (Spd), and four complementary performance metrics: accuracy (Ad), false alarm rate (FAd), positive probability (PPd) and negative probability (NPd), where subscript d corresponds to the class in point. The sensitivity metric assesses how aptly the classifier can recognize samples from the class in point. Specificity, also known as real negative rate, measures whether the classifier can recognize samples that do not belong to the class in point. Accuracy assesses the number of samples classified within the class in point that actually belong to it. The false alarm rate records fake positives or type-I errors. Positive probability is concerned with the proportion of samples within the class in point that has been classified correctly compared to the samples that do not belong to the class in point and have been misclassified. This latter metric is weighted considering the number of samples in each Subject 1 consistently achieved the best results compared to the remaining participants because this was the only participant that was trained using the BCI device and data-acquisition system. However, considering that the remaining participants had no training, their results were good nonetheless.
The performance obtained by the three classifiers has been compared using various assessment metrics, such as recognition rate (RT) and error rate (ET). However, according to Ibarra [41], these metrics do not always suffice to assess a classification method. For instance, in some cases the estimate of the recognition rate may not contain enough information to be assessed. Therefore, further metrics ought to be used, such as sensitivity (S d ) and specificity (Sp d ), and four complementary performance metrics: accuracy (A d ), false alarm rate (FA d ), positive probability (PP d ) and negative probability (NP d ), where subscript d corresponds to the class in point.
The sensitivity metric assesses how aptly the classifier can recognize samples from the class in point. Specificity, also known as real negative rate, measures whether the classifier can recognize samples that do not belong to the class in point. Accuracy assesses the number of samples classified within the class in point that actually belong to it. The false alarm rate records fake positives or type-I errors. Positive probability is concerned with the proportion of samples within the class in point that has been classified correctly compared to the samples that do not belong to the class in point and have been misclassified. This latter metric is weighted considering the number of samples in each class. Negative probability measures the proportion of samples classified as not belonging to the class in point. This metric is weighted considering the number of samples in each class.

RT "
# tc|c "ĉu # tcu ET " # tc| c ‰ĉu # tcu (9) The results are presented in Table 9, highlighting the best score delivered by each performance measure using the three classifiers.
Note that in Table 9 the DT classifier shows the best performance for the recognition, sensitivity, specificity, accuracy and positive probability rates. The results for KNN are similar to those for DT, but the former shows a better accuracy performance with class 0. The SVM classifier shows the worst performance in recognition and error, but has a better performance in sensitivity with class 1 and accuracy for class 0. The error rates are 15.25% for DT, 16.38% for KNN, and 22.65% for SVM, all of them still within an acceptable range.
To sumrize, the results of testing this new method with 10 participants 20 times per participant using 30%-70% of the data have been presented. The average performance accuracy was 84.75% when using the DT classifier. The same test was performed using DT and SVM classifiers that yielded an accuracy rate of 83.62% for KNN and 77.35% for the SVM classifier. After exhaustive tests of the proposed technique, the results show that this methodology for monitoring, representing and classifying EEG signals can be usefully applied for the purposes of having individuals control external devices.

Conclusions
Representing rotations in three-dimensional spaces using quaternions is computationally more efficient, both in terms of storage space required and the number of necessary operations. Thus, the results presented in this article show that QSA can be used as a tool to extract EEG signal features to identify "left" and "right" accurately using DT and KNN classifiers, even though admittedly the tests were conducted in a semi-controlled environment.
This study has presented the QSA method to obtain features of EEG signals and to represent motor instructions. The differences between these features were assessed using DT, SVM and KNN classifiers. The best classification results were obtained using DT. The QSA technique opens up new modeling and classification opportunities to process both biosignals and other types of signals for BCI devices. The QSA technique requires greater levels of independence between signals embedded into each quaternion for best results. In the future, this technique should be modified to reduce the number of samples needed to obtain a class and thus the analysis and processing times. In addition, the number of cognitive classes should be increased to include facial and emotional expressions in tests as well.
Author Contributions: Ibarra-Manzano proposed and described the theoretical use of the QSA technique; Batres-Mendoza and Guerra-Hernandez programmed the QSA and the classifiers; Batres-Mendoza and Montoro-Sanjosé designed and prepared the experiments; Batres-Mendoza and Almanza-Ojeda tested and analyzed the metrics of the data; and Rostro-Gonzalez and Rene J. Romero-Troncoso contributed the BCI System, its use and the theoretical explanation of the classifiers for implementing them. All the authors contributed to writing the manuscript; and Montoro-Sanjose and Almanza-Ojeda carried out the proofreading of the paper.

Conflicts of Interest:
The authors declare no conflict of interest.

Abbreviations
The following abbreviations are used in this manuscript: