Keywords

1 Introduction

The interpretation and use of brain patterns related to cognitive tasks is the basis of the Brain-Computer Interfaces (BCI) and Brain-Machine Interfaces (BMI). Neural patterns related to motor control, imagination and movement intention have been identified, and, integrated through BCI systems to control mechanisms destined to movement assistance in disabled persons with a partial or total restriction on the movement of their limbs. Examples of such devices are: exoskeletons [9, 16], prosthetic apparatus [5], wheelchairs [20] or robotic manipulators [15].

Previous studies had demonstrated the possibility to decode kinematics from EEG signals [7] and, consequently, achieve a continuous motion reconstruction. The first attempts to create a model to reconstruct continuous motion are found in [2], where was demonstrated that M1 cells firing rates are related to the movement direction in center-out hand movements. These firing rates were more intense with executed movements in a preferred direction, gradually decreasing as they went far. Mathematical models that establish a relationship between the tuning of the cell and the direction were developed in [2, 3]. Subsequently, a model that includes the hand velocity was introduced by [11]. Also, a linear model that relates the firing rate and hand position based on fitting coefficients through training was introduced by [8].

In [18], a method for decoding 2-D hand movement from primates neural activity through a generative model in a Bayesian approach using a Kalman Filter was introduced. This approach allowed to decode multiple kinematic variables from invasive EEG, enhancing the estimation performance in comparison with works that decoded kinematics from linear filters [1, 9, 17]. Thereupon, in [14], the experiment was replied in humans models using surface-level EEG obtaining similar results.

Kalman Filter was successfully applied to decode hand movement trajectories using Electrocorticography (ECoG) [13], hand velocity [10], position and velocity of a cursor in a screen [6], and control of a robotic arm by patients with tetraplegia [4]. Those experiments achieved the reconstruction of Cartesian movements and did not explore the use of the Kalman Filter to decode specific kinematic parameters in the joint dimension.

This work proposes to apply the Kalman Filter to decode the right elbow flexion/extension movement using non-invasive EEG recordings. The filter model is tested through cross-validation techniques determining a set of configuration parameters optimizing the signal decoding result. Also, the response is analyzed in a new group of data, evaluating the response according to the used data set.

2 Materials and Methods

2.1 Experimental Paradigm

This study was conducted by the protocol approved by the Ethics Committee of Federal University of Rio de Janeiro (Approbation number: 851.521). Six healthy right-handed volunteers (2 females and four males), without previous training in similar procedures, were studied. During the test, the volunteer is seated on a chair, with his arms in the rest position in a conditioned room (Fig. 1-left).

A screen was used to present the cue for the action, and the instructions were randomly generated to avoid any anticipation in action (Fig. 1-center). The experiment consisted of two actions indicated by a arrow (black for arm movement and white for non-movement), being formed each one by 60 trials of 10 s. Afterwards, the data was selected, extracting information for those time intervals were movement was executed. Non-movement data set was not used in this test. A movement consisted of the right elbow flexion and their return to rest position (an action on the interval of 90\(^{\circ }\)to 150\(^{\circ }\) approximately).

2.2 EEG Recording and Signal Processing

The EEG was recorded continuously from scalp electrodes using the Neuron-Spectrum system and software (Neurosoft Ltd., Ivanovo, Russia). A total of 32 passive Ag-AgCl electrodes were distributed around the scalp using a MCScap (Medical Computer Systems Ltd., Moscow, Russia) with removable electrodes according to a 10-10 modified system (Fig. 1-right). An additional EMG electrodes monitored the muscular activity in the biceps. A MPU6050 accelerometer located in the forearm was used to read the angular position.

Fig. 1.
figure 1

(Left) Volunteer disposition in front of the command screen. (Center) Description of the trial, referencing the on-screen image during the interval and the activity developed by the volunteer. (Right) Location of the 32 channels around the scalp.

The signals were amplified, digitized with a sampling rate of 1000 Hz and band-pass filtered in the 0.5–100 Hz frequency band. EEG data were processed using the EEGLAB Matlab toolbox. Artifacts, as eye blinking and head movements presented as components with homogeneous contributions, were removed using the ICA algorithm of the EEGLAB toolbox. The signals were removed using runica as decomposition method through the 10 s test in all the recorded trials. Segments with high signal interference or disturb were also removed.

Due to their relationship to motor control, EEG signals in the mu band were considered, thus, a fourth-order pass-band filter in the 8 to 13 Hz band was applied. To obtain the movement time interval in each trial was used a muscle activation detector in the EMG signal, utilizing the algorithm described in [19].

3 The Kalman Filter

The decoding model has as purpose to estimate the state \( \mathbf x _{k} \) in the time instant \( {t}_{k} \). The states represent right elbow angular position, velocity and acceleration. As a measured signal, the notation \( \mathbf z \in \mathfrak {R}^{C}\) is used, where C stands for the number of EEG electrodes used to decode the elbow kinematic.

According to [18] the filter is determined assuming a linear relationship between the state \( \mathbf x _{k} \) and the observations \( \mathbf z _{k} \) in the instant of time \( t_{k} \). The generative model is then stated as:

$$\begin{aligned} \mathbf z _{k}= \mathbf H _{k}{} \mathbf x _{k} + \mathbf v _{k} \end{aligned}$$
(1)

Where \( \mathbf H _{k} \in \mathfrak {R}^{C\times 3}\) is a matrix that linearly relates the neural activity captured from the EEG electrodes with the kinematics. A Gaussian noise \( \mathbf v _{k} \) described as a normal distribution whit zero mean and covariance matrix \(\mathbf R _{k} \in \mathfrak {R}^{C\times C} \), \( \mathbf v _{k} \sim (0,\mathbf R _{k}) \).

The state \( \mathbf x _{k} \) propagates in time according to the model:

$$\begin{aligned} \mathbf x _{k+1}=\mathbf A _{k}{} \mathbf x _{k} + \mathbf w _{k} \end{aligned}$$
(2)

Where \( \mathbf A _{k} \in \mathfrak {R}^{3\times 3}\) is a matrix that linearly relates the kinematics between times k and \( k+1 \). The noise term \( \mathbf w _{k} \) is assumed to have a normal distribution with zero mean and covariance \( \mathbf Q _{k} \in \mathfrak {R}^{3\times 3} \), \( \mathbf w _{k} \sim (0,\mathbf Q _{k}) \).

3.1 Training Process

To train \( \mathbf A _{k}, \mathbf H _{k} \), \(\mathbf R _{k}\) and \( \mathbf Q _{k} \) it was assumed that the models of Eqs. 1 and 2 are invariant along time. Considering that the signals \( \mathbf x _{k} \) and \( \mathbf z _{k} \) have a length \(k=1\ldots M\). Using least squares [18], the solutions for matrix \(\mathbf A \) and \(\mathbf H \) are expressed as:

$$\begin{aligned} \begin{aligned} \mathbf A&=\mathbf X _{2}{} \mathbf X _{1}^T(\mathbf X _{1}{} \mathbf X _{1}^T)^{-1}\\ \mathbf H&=\mathbf Z {} \mathbf X ^T(\mathbf X {} \mathbf X ^T)^{-1} \end{aligned} \end{aligned}$$
(3)

Using the learned values of \( \mathbf A \) and \( \mathbf H \) the noise covariance are then determined:

$$\begin{aligned} \begin{aligned} \mathbf Q&= \frac{\left( \mathbf X _2 - \mathbf A {} \mathbf X _1 \right) \left( \mathbf X _2 - \mathbf A {} \mathbf X _1 \right) ^T}{\left( M-1 \right) }\\ \mathbf R&= \frac{\left( \mathbf Z - \mathbf H {} \mathbf X \right) \left( \mathbf Z - \mathbf H {} \mathbf X \right) ^T}{ M } \end{aligned} \end{aligned}$$
(4)

Where the matrix \( \mathbf X \in \mathfrak {R}^{3\times M} \) correspond to the state values, matrix \( \mathbf X _{1} \in \mathfrak {R}^{3\times M-1} \) represents the state values from time interval \( k=1\ldots M-1 \), the matrix \( \mathbf Z \in \mathfrak {R}^{C\times M} \) is the EEG signals from the C channels, and the matrix \( \mathbf X _2 \in \mathfrak {R}^{3,M-1}\) stands for the state values taken from the time interval \( k=2\ldots M \).

Matrices \( \mathbf A , \mathbf H \), \(\mathbf R \) and \( \mathbf Q \) coefficients, are dependents of the training data. They could be configured according to a set of parameters, being, the number of channels C and the step time \( \varDelta _{t} \). Different combinations of such parameters were tested using cross-validation in a 6-folds configuration, the responses where measured with Mean Squared Error MSE (Eq. 5) and the Correlation Coefficient CC (Eq. 6).

$$\begin{aligned} \mathbf {MSE}= \frac{1}{M} \sum _{k=1}^M(\mathbf x _{k}-\hat{\mathbf{x }}_k)^2 \end{aligned}$$
(5)
$$\begin{aligned} \mathbf {CC}= \frac{ \sum _k (\mathbf x _k - \bar{\mathbf{x }} ) ( \hat{\mathbf{x }}_k -\bar{\hat{\mathbf{x }}} ) }{\sqrt{ \sum _{k} (\mathbf x _k-\bar{\mathbf{x }})^2 \sum _{k} (\hat{\mathbf{x }}_k-\bar{\hat{\mathbf{x }}})^2 }} \end{aligned}$$
(6)

4 Results

4.1 Cross-validation

In the beginning, the channels were reorganized according to the coherence respect to \( C_{3} \). In Fig. 2 the error curves obtained for ascending movements are presented, testing \( \varDelta _{t} \) values from 1 to 200 ms, and a set of channels C from 3 to 34. The left graphics illustrate the validation (black line) and training (dashed line) response according to the time step. Meanwhile, the right graphic presents the MSE in training according to the number of channels considering the \( \varDelta _{t} \) value. The horizontal lines present the variance through volunteers. The red square shows a low MSE zone that is augmented at the right.

According to the results, the parameters \( \varDelta _{t}= \) 70 ms and \( C= \) 3 channels were selected. This choosing was generalized in all the volunteers.

Fig. 2.
figure 2

Error curve across volunteers according to \( \varDelta _{t} \) (left) and the number of channels C (right) for ascending tasks. (Color figure online)

4.2 State Estimation

A new 6-fold cross-validation was performed to evaluate the filter response according to the selected parameters. The compiled results in this section show the response of the validation set in Fig. 3 a decoding example is presented for an ascending (a), and a descending (b) task.

Fig. 3.
figure 3

Decoding for ascending (a) and descending (b) movements. The bold line indicates the real value for position \( x_{1} \), velocity \( x_{2} \), and acceleration \( x_{3} \), and the dashed line is the state estimation \( \hat{\mathbf{x }} \).

The mean response for each volunteer decoding respect to position \( x_{1} \), velocity \( x_{2} \) and acceleration \( x_{3} \) in ascending and descending tasks are presented in Tables 1 and 2. The mean Frobenius norm value \( \Vert \mathbf A \Vert \) of the trained state matrix A is introduced to give an insight of the relationship between the matrix coefficients and the decoding response.

Was observed that lower values in \(\Vert \mathbf A \Vert \) gives decoding responses with low mean MSE and high mean CC. To illustrate this assertion, a dispersion graphic collecting all volunteers MSE against their respective \(\Vert \mathbf A \Vert \) was built in Fig. 4 for ascending (a) and descending (b) tasks. When \( \Vert \mathbf A \Vert \) (horizontal axis) is raising up, their respective MSE (vertical axis), grown proportionally with minimal and maximal limits that increases along x-axis forming a cone-shape across the plane.

Fig. 4.
figure 4

Dispersion graphics of MSE against \(\Vert \mathbf A \Vert \) for ascending (a) and descending (b) movements in the 6 volunteers.

Due to \(\mathbf A \) was resultant from states signals \( x_{n} \), both magnitudes were analyzed through a dispersion graphic. In Fig. 5 are compared the norm of \(\mathbf A \) against the standard deviation of the training set states used to build it. Was observed that in sets with higher speed and acceleration variance, the resultant \( \Vert \mathbf A \Vert \) increased in a quasi-exponential form. However, the position state not presented similar behavior, due to it had a lower standard deviation.

Fig. 5.
figure 5

Dispersion graphics comparing the Standard Deviation (\( \sigma \)) of the estimated states and their resultant \( \Vert \mathbf A \Vert \) in ascending movements.

Table 1. MSE and CC of each \( x_{n} \) state for all the \( V_{n} \) volunteers for ascending movements.
Table 2. MSE and CC of each \( x_{n} \) state for all the \( V_{n} \) volunteers for descending movements.

4.3 Decoding Imposed Movement

The results in the previous section showed that those volunteers whose data set allowed to train state models with lower \( \Vert \mathbf A \Vert \) value presents better decoding results. To validate the decoding capabilities according to the data set, kinematic patterns that trained a state model matrix with \( \Vert \mathbf A \Vert \,< 3 \) were selected. This value was chosen as it seems to present a high decoding accuracy according to the dispersion graphic in Fig. 5.

Thus, a proposed motion was trained with the collected data and was used as a reference trajectory for decoding movement in a new test group. This group consisted of a set of signals from 12 volunteers who developed the same experiment without motion sensor. The proposed movement was adjusted for each volunteer according to their mean interval of movement, that action allowed to eliminate inter-trial variations.

Before initiating the test, EEG signals from both groups were compared to analyze equivalence respect to the cognitive response and the movement in Fig. 6 had presented a grand average Relative Power over \( C_3 \) channel in the analyzed band from both the training (orange) and test (blue) groups in the task interval when a motion was executed. This analysis was done according to [12], using a relative signal the time interval \( t < 0 \) s, when the non-task cognitive state was expected. The horizontal bars represent the movement average time interval.

Fig. 6.
figure 6

Grand Average Relative Power for Training (orange) and Test (blue) groups when the movement was executed. (Color figure online)

Fig. 7.
figure 7

(Left) Is presented the dispersion graphics of MSE against norm of \(\Vert \mathbf A \Vert \) using regulated trajectories. (Right) bar plot describes the MSE variation for each state.

In both cases, a de-synchronization in the band (ERD) was presented before the movement onset and continues until it ends near to 5 s. Then, a synchronization ERS was presented on the band, increasing the signal energy around 20%. In both circumstances, this response was expected according to the literature.

In Fig. 7 is presented the decoding response for ascending trajectories. Due to variations on each volunteer, the adjusted trajectory norm vary their magnitude. The decoding capabilities leads to a maximum mean MSE of 2.5. Selecting an adequate set of trajectories allowed the filter to estimate motion in all three states with a minor error over the tested volunteers. In the right part of the figure, MSE variations for each state are presented. Acceleration continues presenting the worst response over all the decoded states.

The proposed model was compared with a second test, here, trajectories with \( \Vert \mathbf A \Vert > 5 \) from the first data set were selected to conform the imposed trajectory, this value was chosen as it presented lower decoding precision in Fig. 4. The response of this group is presented in Fig. 8. Due to the selection of an intended movement composed with non-homogeneous data set, the decoding error increased in all three states.

Fig. 8.
figure 8

(Left) Is presented the dispersion graphics of MSE against norm of \(\Vert \mathbf A \Vert \) using non-regulated trajectories. (Right) bar plot describes the MSE variation for each state.

In the Table 3 is presented a resume of the experiment. In it is described the MSE variation across volunteers according to \( \Vert \mathbf A \Vert \).

Table 3. MSE response with respect to the 12 volunteers.

5 Discussion

The results of the previous section showed that the Kalman Filter presented a variate capability to decode the elbow motion from non-invasive EEG, this variability was dependent on both the configuration parameters used to configure the signals that trained the propagation model and the data set variability.

The error curve in Fig. 2 showed an optimal interval of \( 50 \le \varDelta _{t}\ge 150\) ms around the 6 volunteers. Also, it was found that increasing the number of channels for that specific interval, a decreasing of the decoding accuracy was presented. Thus, with EEG channels \( C_{3}, C_{5} \) and \( C_{1} \) it was possible to achieve an optimal decoding response. The selected readings had in common their proximity to the contra-lateral right arm control region. This results also were found for descending movements. Presumably, the decoding algorithm required a set of channels with a strong coherence among them; hence, tests with a major number of electrodes may require a high-density configuration.

The error curves gave us an insight of parameter \( \varDelta _{t} \) influence into the state estimation. When its values increased, it led to a diminution in the decoding error for both ascending and descending movements. This result was similar to the found in [18] were decoding response increased with an augment of the time step, indicating that movements described with fewer points are closer to the linear consideration done for the propagation model. However, decoding with high \( \varDelta _{t} \) values could affect the movement control when fast response BMI systems are required.

The results after the parameter selection showed that acceleration is the state with the worst decoding response presenting a mean MSE up to 400 in one of the volunteers. This result also was coincident with [18], who considered that this state appears not to be encoded in neural firing rates. Following results in the imposing motion decoding test showed that trained A matrix with high value into the acceleration coefficients led to wrong responses, minimizing the precision of the a priori prediction. Therefore, we argue that the incapacity of the filter to estimate acceleration is more related to the state model than the biological response of the neural firing rates, where noise caused by the derivation of the signal is higher, and it is intensified as the movement augments their speed, having difficulty the state model to propagate an adequate response.

The result in Tables 1, 2 and Fig. 4 showed that volunteers who presented lower mean MSE and higher mean CC, also had lower \( \mathbf A \) matrix norm value, this result repeated in descending tasks. The relationship between both magnitudes was linear with positive inclination, but points disperse in the plane forming a cone, this shape is related with \( \Vert \mathbf A \Vert \) as the dispersion plane increased along with the value coefficients.

The results in Fig. 5 showed that increments in \( \Vert \mathbf A \Vert \) are related to movement variability, specifically, with an increase in the motion’s velocity and acceleration during the test. Consequently, when matrix A was trained with high variance trials, the resulted model in Eq. 2 will not estimate the state value correctly, to verify this, the mean \( \sigma \) of the three states, the mean \( \Vert \mathbf A \Vert \) and the mean MSE in each volunteer are compared in Table 4, observing that volunteers who presented a high variation in the movement’s velocity and acceleration during the training, presented high mean MSE. However, the algorithm response was more accurate for decoding descending movements, even in the acceleration state, whose worst MSE was of 27,74 for Volunteer 3.

Table 4. Mean Standard Deviation of each state compared with their respective mean norm of matrix A and mean MSE.

According to these results, we believe that movement estimation had a higher dependence of the propagation model. Through all the volunteers, was found that the A matrix trained from movements with high variability achieved the worst estimation values. Indeed, the optimal value of \( \varDelta _{t} = 70\) ms, built A matrix with more difficulties to propagate fast movements. Arguably, the experimental conditions were dependent on the physical and mental conditions of the volunteers, as the ascending movements presented worst decoding estimations through volunteers than the descending ones, thus, factors like the volunteer’s reaction to the visual stimulus, fatigue, and the gravity effects during the flexion could cause a high variation in the executed movement. Volunteers, as \( V_{2} \) in Table 1 presented a better signal decoding for ascending movements than, for example, \( V_{6} \), being the major differences in the acceleration and velocity, that indicates a lower regularity in the task execution by \( V_{6} \) as the trained filters fail to estimate the movement.

Hence, the optimal encoding parameters searching led to finding a value set fitted in conditions specified by the regularity of the volunteer during the experiment. The proposed linear models, therefore, are not suited for high movement variations, and, presumably, coefficients related to velocity and acceleration estimation were trained to specific movement conditions.

In order to test this assessment, a state matrix from trajectories with higher and lower regularity was built and used to decode motion from a new data set. The results showed that a non-regulated motion led to training a model which high decoding inaccuracy and also, presenting an increment in the MSE dispersion on all the tested volunteers over all states. This dispersion was analogous to the cone shape distribution found in the posterior group, being less significant as \( \Vert \mathbf A \Vert \) decreases.

Consequently, a wrong state prediction during the a priori step makes the filter more dependent of the measurement value in the a posteriori step, which discordance with the estimated value led the filter to avoid the convergence in the K-gain, resulting in a reduced decoding precision. Therefore, we theorized that models originated from non-regulated data are more sensitive to the inter-trial EEG variance, increasing dramatically the MSE as the resulting matrix \( \mathbf A \) got higher coefficients values, making the filter unstable as it obtains larger K-gain values.

6 Conclusion

In this work, the Kalman filter was tested to decode the elbow movement using non-invasive EEG signals. The experimental result showed us that it is possible to decode this movement with relative precision. An optimal configuration for the state and measurement signals was made through a set of parameters (number of channels and time step), allowing us to find the best estimation through cross-validation. Were found that the decoded movement presented a precision variation around the volunteers and that the filter decodes better the descending task than the ascending ones.

A set of analysis was made using the optimal set of parameters and was found that the capability to estimate different movements by the filter appears to be affected by the trained state model. Being that, when the resultant matrix A coefficient presented higher values, the resultant decoding error in the validation group increased. Subsequently, when propagation models were trained from data with significant variance, it means, movements with higher variation in the acceleration and velocity, the resultant A matrix presented high values coefficients, that subsequently, occasioned low precision estimation in the validation data sets.

Was found that those volunteers who executed movements with high irregularity presented the worst estimation results in comparison of those that performed a set of movements with low variance. Regardless, due to the form that the experiment was conducted, is possible that the resulted propagation model was a generalization of the most common actions executed by the volunteers, therefore, parameters selected from cross-validation, were the ones that fitted the most regular actions, with an estimation capability related to a specific region inside the set of possibilities made during the experiment.

The presented results gave us an insight into how Kalman filter works and how the training set could be configured through a rigorous selection of trials to improve decoding results. Therefore, the information could be removed according to the response of the volunteer, if it does not cope with the task regularity. On the other hand, it is possible to integrate them with clustering algorithms that detect different ranges of movement, and therefore, to allow us to train a set of filters according to the mean speed of each range, adapting them to decode a significant set of movements with minor estimation error.