3.2.2. Extended Kalman Filter

The accelerations obtained after the application of different values of the process noise standard deviation *σ<sup>a</sup>* (with the sensors noise standard deviation *σ<sup>s</sup>* fixed to 0.001 m), along with the application of the forward-backward 2nd order Butterworth filter with different cutoff frequencies to the position data, were compared to those directly measured by the IMUs. The units for *σ<sup>a</sup>* are omitted in what follows for the sake of brevity, since they depend on the associated degree of freedom: for translational DOFs, *σ<sup>a</sup>* is expressed in m/s2 whereas for rotational DOFs it is in rad/s2.

Figure 11 shows the three components of the accelerations at the seven segments analyzed for combinations of *σ<sup>a</sup>* and cutoff frequencies of 0.1/30 Hz, 1/20 Hz and 50/6 Hz, while Figure 12 provides more detail for the left foot. Table 2 gathers the RMSE of the optical-system based accelerations with *σ<sup>a</sup>* ranging between 0.1 and 50 m/s<sup>2</sup> (or rad/s2, depending on the corresponding coordinate), and cutoff frequencies ranging between 6 and 30 Hz, with respect to those directly measured by the inertial system.

It can be seen in Figures 11 and 12 that the accelerations obtained with the EKF were smoother than those obtained with Vaughan's method, and that the experimental peak measurements of the inertial sensors were better dissociated from the noise peaks. Moreover, Table 2 presents lower values of the RMSEs. The best results were obtained for a process noise standard deviation of 1 m/s2 combined with a 20 Hz Butterworth filter.

In addition to obtaining better accelerations, it should be noted that the EKF automatically ensures kinematic consistency, whereas Vaughan's method shows joint distance variations above 1 cm along the gait cycle, so the resulting motion would require further post-processing depending on the intended application.

**Figure 11.** Accelerations obtained from the optical system with the EKF for combined process noise variances and cutoff frequencies of 0.1/30 Hz (black), 1/20 Hz (blue) and 50/6 Hz (cyan), respectively, vs. accelerations measured by the IMUs (red).

**Figure 12.** Detail of accelerations at the left foot obtained from the optical system with the EKF-based method for combined process noise standard deviations and cutoff frequencies of 0.1/20 Hz (black), 1/15 Hz (blue) and 50/6 Hz (cyan), respectively, vs. accelerations measured by the IMUs (red).


**Table 2.** RMSE of the accelerations obtained from the optical system through the EKF-based method with different combinations of process noise standard deviations and cutoff frequencies, with respect to the accelerations measured by the IMUs, taken as reference. The row with the lowest mean RMSE is highlighted in red.

#### **4. Discussion and Limitations of the Study**

This work proposes both an extended Kalman filter that facilitates optical motion capture, and an objective filter-tuning procedure that improves the resulting accelerations in gait analysis by using accelerometer data. First, a preliminary test including nine IMUs was carried out to assess the errors incurred by the inertial sensors in the measured orientations and accelerations. Second, the gait analysis of a healthy subject was performed. Both optical motion capture and inertial motion capture (using the seven most accurate IMUs out of the nine tested in the spot check) were recorded. The motion was then reconstructed by the classic Vaughan's method (filtering the marker trajectories with a Butterworth filter) and by the proposed EKF (applying a process noise variance and filtering the marker trajectories with a Butterworth filter), and the accelerations measured by the IMUs were used to tune the parameters of the filters for both methods.

As observed earlier in [11–13], the preliminary test highlighted the IMUs limitation to yield an accurate orientation. These errors depend on the calibration of the accelerometers and magnetometers, and on the algorithm used to estimate the orientations. Brodie [13] showed that it is possible to reduce the errors by substituting the commercial algorithm implemented in the inertial sensors by an improved one, which is consistent with the experience of the authors using other algorithms [35,36], but even in this case their accuracy remains limited. Therefore, although the performance of the IMUs has been improved in the last decade, optoelectronic systems are still used as the golden standard reference [18,19,43]. For this reason, it was decided to reduce the use of the orientations provided by the IMUs to a minimum for the gait analysis, taking as reference the local accelerations measured by the IMUs, and applying all the required transformations in the optical methods so as to obtain the accelerations, denoted as virtual accelerations, which are directly comparable to those provided by the inertial sensors.

This decision was enforced after observing, in the preliminary test, the effect of the orientation errors incurred by the IMUs on the global accelerations. As reported by Woodman [44], it is necessary to have very accurate rotation sensors in inertial navigation systems because the precise orientation of the body must be known in order to mathematically calculate the gravitational acceleration to find the translational acceleration. As observed in Figure 8, the gravitational acceleration was incorrectly estimated and appeared as translational acceleration perpendicular to the gravitational vector. To alleviate this problem, the orientations obtained from the optical system could be used instead but, as they are sensitive to the filter tuning, the resulting global accelerations from the IMUs would be distorted too.

The virtual accelerations obtained by Vaughan's method were very sensitive to the filtering applied to the trajectories of the markers. Best matches with experimental values were observed for cutoff frequencies ranging between 10 and 15 Hz. Bartlett [45] stated that cutoff frequencies between 4 and 8 Hz are often used in filtering movement data, while the OpenSim software [40] recommends to use a cutoff frequency of 6 Hz. However, it was observed that by using low cutoff frequencies, the accelerations were too smooth and the peaks measured by the IMUs were not reached. Schreven et al. [31] found that filtering the data with a cutoff frequency of 6 Hz decreases the accuracy of the reconstructed kinematics and, hence, can affect the accuracy of the joint moments obtained from inverse dynamics, as shown in [46].

Regarding the EKF method, apart from its robustness and simplicity of use, it showed a better accuracy in the resulting accelerations. The best filtering was obtained for a plant noise variance of 1 m/s<sup>2</sup> (or rad/s2, depending on the corresponding coordinate) and a cutoff frequency of 20 Hz. Noise was eliminated, peaks measured by the IMUs were almost reached, and the resulting RMSEs were better than those incurred by Vaughan's method. Moreover, the EKF offered consistent kinematics by providing constant lengths of the body segments along the motion. Vaughan's method is similar to those proposed in [19] and, like them, does not impose the kinematic constraints to compute the joint kinematics from the marker trajectories. Therefore, it would require an additional step to correct these inconsistencies before dynamic analysis.

Although gait may be perceived as a smooth activity, acceleration peaks due to foot impact are observed in Figures 10 and 12, captured by the inertial system. In fact, they were also captured by the optical system when sampling at 100 Hz. Focusing on the acceleration peaks due to left foot landing, happening at around 60% of the gait cycle, it can be seen in Figure 10 that filtering with a cutoff frequency of 40 Hz already allows to capture them, but at the cost of keeping a lot of noise in the rest of the signal. On the other hand, using a cutoff frequency under 30 Hz provides a much cleaner signal, but notably oversmooths the impact peaks. Therefore, the procedure proposed in this paper can be useful for other researchers to evaluate existing filtering methods, design new ones and chose the best filtering parameters, but also to select the best capture frequency for their applications, because they will be able to distinguish between peaks due to noise and peaks due to actual motion.

The conducted study has been based on the results obtained from the gait analysis of one single subject. Although it could be expected that the frequency content of the motion signals is more dependent on the type of activity than on the particular subject performing it, tests including a greater number of subjects would be advisable in order to confirm the presented conclusions. This has been the reason to include the word 'preliminary' in the title.

### **5. Conclusions**

The conclusion is twofold. First, when performing motion capture and analysis using a marker-based optical system, the extended Kalman filter significantly streamlines the motion capture and reconstruction process, since it facilitates automatic marker labeling, and manages occlusions and reflections in a robust and efficient way. Second, the availability of accelerations measured by inertial sensors can be very helpful for the tuning of the filters, no matter which motion reconstruction method is used. Consequently, the reliability of the obtained accelerations is improved.

**Author Contributions:** F.M. designed and performed the experiments with the supervision of U.L. and J.C.; U.L. implemented the EKF algorithm; F.M. analyzed the data. F.M., U.L. and J.C. wrote the manuscript; M.P.S. helped F.M. to perform the experiments. All authors have read and agreed to the published version of the manuscript.

**Funding:** This work was funded by the Spanish MCI under project PGC2018-095145-B-I00, cofinanced by the EU through the EFRD program, and by the Galician Government under grant ED431C2019/29. Moreover, F. Michaud would like to acknowledge the support of the Spanish MCI by means of the doctoral research contract BES-2016-076901, co-financed by the EU through the ESF program.

**Institutional Review Board Statement:** Ethical review and approval were waived for this study, due to the non-invasive and non-dangerous character of the experiments.

**Informed Consent Statement:** Informed consent was obtained from all subjects involved in the study.

**Data Availability Statement:** The data presented in this study are available on request from the corresponding author. The data are not publicly available due to privacy restrictions.

**Acknowledgments:** Authors would like to acknowledge the different funding supports. Moreover, authors would like to acknowledge Mario Lamas for his voluntary participation in this project.

**Conflicts of Interest:** No conflicts of interest lie with any of the authors.

#### **References**

