*5.4. Exercise 4: Shoulder Abduction*

Figure 9 shows the angles for the left shoulder and right shoulder in the shoulders' abduction exercise. The left shoulder angle varied between 80◦ and 128◦ with OpenPose and between 79◦ and 127◦ with Detectron 2. The right shoulder angle varied between 85◦ and 132◦ with OpenPose and between 80◦ and 138◦ with Detectron 2. For the left shoulder angle, RMSE = 4.68◦ and MAE = 4.17◦ for OpenPose, while RMSE = 11.79◦ and MAE = 7.89◦ for Detectron 2. For the right shoulder angle, RMSE = 4.16◦ and MAE = 3.74◦ for OpenPose, while RMSE = 12.74◦ and MAE = 9.03◦ for Detectron 2.

**Figure 9.** Exercise 4: Angles of both shoulders in shoulder abduction rehabilitation exercise for two iterations.

#### **6. Results**

Figure 10 shows a comparison of the RMSEs (root-mean-square errors) of OpenPose and Detectron 2 for each rehabilitation angle calculated in the exercises. OpenPose obtained a lower RMSE than Detectron 2 did for all four proposed rehabilitation exercises. For the exercises where the viewing angle of the webcam was not favorable, a large RMSE was obtained for both approaches. An example of these errors can be seen in the flexion left elbow exercise, which had RMSEs of 15.84◦ with OpenPose and 27.27◦ with Detectron 2. The best results were obtained by OpenPose in exercises 3 and 4 where it was easier to estimate the movement of the arms than to obtain an estimated RMSE below 5◦.

To visualize the error during each exercise step, we calculated the absolute error of each method. Figure 11 shows the absolute error for each rehabilitation exercise according to both libraries. We can see again that during the exercise of flexion of the left elbow (row b), both libraries achieved high absolute errors. The results show how OpenPose had fewer error peaks, and it seemed more stable for most of the angles checked.

**Figure 10.** RMSE of the four rehabilitation exercises compared to ground truth.

**Figure 11.** Absolute error for the four rehabilitation exercises compared to ground truth: (**a**) flexion side left elbow, (**b**) flexion left elbow, (**c**) abduction left shoulder, (**d**) abduction right shoulder, (**e**) extension left shoulder, and (**f**) extension right shoulder.

#### **7. Discussion**

In this article, we compared the performance of estimating shoulder and elbow angles for rehabilitation exercises using CNN-based human pose estimation methods: Open-Pose and Detectron2. Qualitatively, for the four proposed rehabilitation exercises, better results were obtained with OpenPose. OpenPose had an average RMSE of 7.9◦ and Detectron2 had an RMSE of 14.18◦. However, for the elbow flexion exercise, which had a worse angle of view, both methods obtained high errors. According to [39], evaluation therapists tend to underestimate the range of motion by 9.41◦ on average for any joint movement of the upper limb. Therefore, with the results obtained in this approach, it can be concluded that OpenPose is an adequate library for evaluating patient performance in rehabilitation programs that involve the following exercises: left elbow side flexion, shoulder abduction, and shoulder extension.

Regarding the response time of the analyzed pose estimators, the performance of these methods is related directly to the available GPU. In our study, we measured a performance between 6.7 and 13 FPS with OpenPose and between 1.8 and 3 FPS with Detectron 2. The kind of exercises related to upper limb rehabilitation is smooth and relatively slow, so the performance of OpenPose is high enough to monitor the exercises and provide useful information for rehabilitation therapy.

The major limitations of the present study were mainly related to the ground truth used; many approaches use three-dimensional motion analysis devices such as the VICON motion system or Optotrak. However, the equipment is expensive, and it requires a conditioned environment and technical skills for attaching sensors. We decided to use Kinect 2 as our ground truth because of the cost and because this sensor has a high accuracy in joint estimation while providing skeletal tracking. Another limitation of the study was that the system was only tested on a single healthy subject who participated in a single experimental session. A study with a larger group of subjects and different positions should be examined to compare the quality of the estimate of the human pose by both methods. In future works, we intend to collect data from more participants and extend this work to lower-limb movement estimations.

**Author Contributions:** Conceptualization, C.A.J., V.M. and Ó.G.H.; methodology, C.A.J., V.M. and J.L.R.; software, Ó.G.H.; validation, C.A.J., V.M., J.L.R. and Ó.G.H.; investigation, C.A.J., V.M. and Ó.G.H.; resources, C.A.J.; writing—original draft preparation, C.A.J., V.M., J.L.R. and Ó.G.H.; writing—review and editing, C.A.J., V.M., J.L.R. and Ó.G.H. All authors have read and agreed to the published version of the manuscript.

**Funding:** Óscar G. Hernández holds a grant from the Spanish Fundación Carolina, the University of Alicante, and the National Autonomous University of Honduras.

**Institutional Review Board Statement:** Not applicable.

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

**Data Availability Statement:** Not applicable.

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

#### **References**


**Laura Ferrero \*, Vicente Quiles, Mario Ortiz, Eduardo Iáñez and José M. Azorín**

Brain-Machine Interface System Lab, Miguel Hernández University of Elche, 03202 Elche, Spain; vquiles@umh.es (V.Q.); mortiz@umh.es (M.O.); eianez@umh.es (E.I.); jm.azorin@umh.es (J.M.A.) **\*** Correspondence: lferrero@umh.es

**Abstract:** Lower-limb robotic exoskeletons are wearable devices that can be beneficial for people with lower-extremity motor impairment because they can be valuable in rehabilitation or assistance. These devices can be controlled mentally by means of brain–machine interfaces (BMI). The aim of the present study was the design of a BMI based on motor imagery (MI) to control the gait of a lower-limb exoskeleton. The evaluation is carried out with able-bodied subjects as a preliminary study since potential users are people with motor limitations. The proposed control works as a state machine, i.e., the decoding algorithm is different to start (standing still) and to stop (walking). The BMI combines two different paradigms for reducing the false triggering rate (when the BMI identifies irrelevant brain tasks as MI), one based on motor imagery and another one based on the attention to the gait of the user. Research was divided into two parts. First, during the training phase, results showed an average accuracy of 68.44 ± 8.46% for the MI paradigm and 65.45 ± 5.53% for the attention paradigm. Then, during the test phase, the exoskeleton was controlled by the BMI and the average performance was 64.50 ± 10.66%, with very few false positives. Participants completed various sessions and there was a significant improvement over time. These results indicate that, after several sessions, the developed system may be employed for controlling a lower-limb exoskeleton, which could benefit people with motor impairment as an assistance device and/or as a therapeutic approach with very limited false activations.

**Keywords:** brain–machine interfaces; EEG; exoskeleton; motor imagery
