An Auto-Calibration Approach to Robust and Secure Usage of Accelerometers for Human Motion Analysis in FES Therapies

A Functional Electrical stimulation (FES) therapy is a common rehabilitation intervention after stroke, and finite state machine (FSM) has proven to be an effective and intuitive FES control method. The FSM uses the data information generated by the accelerometer to robustly trigger state transitions. In the medical field, it is necessary to obtain highly safe and accurate acceleration data. In order to ensure the accuracy of the acceleration sensor data without affecting the accuracy of the motion analysis, we need to perform acceleration big data calibration. In this context, we propose a method for robustly calculating the auto-calibration gain using redundant acceleration vectors, and then calibrating the data generated by the accelerometer based on the calculated gain. The selection of the acceleration vector involved in the gain calculation is demonstrated by different experiments. The results show that the auto-calibration gain calculated after calibration is very close to 1, and the error is significantly less than before calibration, which indicates that the accelerometer unit is well calibrated.


Introduction
With the development of medical technology and the continuous improvement of people's living standards, the number of elderly people is rising, and there are a large number of stroke patients in the aging population. Stroke is a disease with a high mortality rate. Survivors are accompanied by varying degrees of functional impairment and limited mobility. They may lose their ability to control their arms. They cannot perform normal daily life, and some may even have permanent disabilities [Jiang, Xiong, Sun et al. (2011)]. Their quality of life has had a serious impact. Without systematic training, it is difficult for patients to recover. Therefore, it is necessary to carry out rehabilitation training for stroke  (Nez A et al. [Nez, Fradet, Laguillaumie et al. (2016)])

Related work
The root cause of stroke disability is that the patient's central nervous system is damaged, so that the limb movement cannot be effectively controlled, resulting in partial loss of limb behavior. The function of the bones and muscles of the patient's limbs has not been lost. In order to prevent hemiplegia, there are many rehabilitation methods, including electromyography biofeedback, constraint-induced movement therapy (CIMT), roboticassisted therapy, functional electrical stimulation, mental practice with motor imagery, etc. [He and Wang (2014)]. Electromyography biofeedback. Electromyography biofeedback is an application of an electromyography biofeedback device to amplify the physiological activity of muscle tissue that people are not aware of, and convert it into visual and auditory signals that can be perceived by people, and pass these signals through eyes, ears, etc. The organs are returned to the brain so that the human body can independently train according to these signals to control the bioelectric activity of the muscle tissue for training purposes. Some studies have shown that it is an effective adjuvant therapy, and it is also one of the hotspots of research at home and abroad [He, Hua, Luo et al. (2017)]. However, different studies use different treatment prescriptions and evaluate the efficacy in different ways, and each treatment lacks the evidence of basic research, and there is not enough data to show that EMG biofeedback therapy has significant benefits in improving upper limb function. There is also a limited effect of electromyography biofeedback therapy on improving the range of motion of the wrist. Constraint-induced movement therapy. CIMT is one of the most influential rehabilitation technologies in the past 20 years, and has been greatly developed at home and abroad and has received extensive attention. It improves the motor function of the limbs by restricting the movement of the limbs and forcing the limbs to perform a large number of intensive training, thereby improving the motor function and activities of daily living of patients with hemiplegia due to cerebral infarction. Professor Taub proposed CIMT. The multi-center clinical study in the United States confirmed that CIMT is the most effective rehabilitation technique for improving upper extremity motor function, especially for patients with hemiplegia and upper extremity motor dysfunction in convalescence stroke [Taub, Uswatte, King et al. (2006);Taub, Crago and Uswatte (1998)]. However, the applicability of CIMT is limited. For example, it is not suitable for widespread use in the acute phase of stroke. In addition, CMIT is expensive because it requires the time of the therapist and the resources of the rehabilitation department.
Robotic-assisted therapy. With the development of artificial intelligence technology, rehabilitation robot technology has also made great progress in recent years. Robotic assisted therapy is the use of mechanical devices to provide or support high-intensity and controllable repetitive upper limb exercises. Stanford University has developed the MIME (mirror image motion enabler) system based on PUMA500 and 560 industrial robots (Fig.  2) [Lum, Burgar and Shor (2003); Burgar, Lum, Shor et al. (2003)]. In addition, compared with traditional exercise therapy, robotic adjuvant therapy seems to be easier to be Patient approval [Kwakkel, Kollen and Krebs (2008)]. Liang et al.'s research shows that there are still some shortcomings in upper limb rehabilitation robots, such as the inability to perform flexion and extension training of wrist joints, the system's own joint range estimation system and the actual measured value error of the protractor are large [He and Wang (2014)]. Although the upper limbs Rehabilitation robot technology has made great progress in research at home and abroad, but the current research is still in its infancy, one robot is expensive and has no universality; the other is the lack of large-sample clinical application and research. Mental practice with motor imagery. Mental practice with motor imagery, also known as mental imaging, refers to consciously simulating and training an action through the brain without accompanying obvious physical or physical activity. Through long-term simulated imaginary exercise training, non-conditioned reflexes are transformed into conditioned reflexes. Neurological function and innervation of muscle function, thereby improving the damaged "sports network" and achieving the goal of exercise imaging training [Fu, Chen, Yu et al. (2010)]. However, the largest research to date, Letswaart, Johnston et al [Ietswaart, Johnston, Dijkerman et al. (2011)]. A total of 121 stroke patients with residual upper extremity weakness (mean <3 months after stroke) were examined and no improvement in outcome measurements was found. Therefore, there is no clear evidence that the psychological practice of motor imaging technology can improve motor function and facilitate the recovery of stroke in isolation. Functional electrical stimulation. FES is an effective method for treating hemiplegia in stroke patients. A large number of clinical studies have shown that electrical stimulation therapy can significantly improve the limb function of patients with stroke and improve the limb control ability of patients. Popovic et al. used FES to treat acute stroke patients with hemiplegia. After 3 weeks of treatment, the affected arm function was effectively improved [Popovic, Popovic, Sinkjaer et al. (2004)]. Chen et al. used FES to stimulate the forearm wrist extensor muscle group to produce wrist extension, after treatment. Wrist flexion and extension function and hand coordination activities have improved significantly, indicating that FES treatment can improve the motor function of the hand, and FES has a more positive effect on the improvement of arm function [Lin and Chen (2010)]. In summary, we can get the comparison results, see Tab. 1, FES has fewer shortcomings and is more suitable for helping patients to recover upper limb motor control after stroke. Therefore, we use FES to perform rehabilitation training on upper limb control function of stroke patients.

Figure 2:
Use assisted robots to help patients with rehabilitation training However, achieving a satisfactory level of FES control is very challenging. In order to better control the FES to make full use of it, the designers developed the FES control system using the sensor. The FES can be used as a feedback source to control the stimulus. The common sensors used in the FES system include the force sensor, the position sensor and the acceleration sensor. The sensor is typically used to provide a feedback signal in the FES system, and the controller can use the data information generated by the acceleration sensor to robustly trigger state transitions. In the medical field, highly accurate acceleration data is required to ensure the safety of the system. Calibration is a very effective way to improve the accuracy of the data collected from the three-axis accelerometer, so we need to calibrate the accelerometer. At present, accelerometer calibration methods mainly include: 1. 6-position accelerometer calibration method: Zhang et al. [Zhang and Ye (2009)] adopted a 6-position accelerometer calibration method, which is easy to implement, simple and easy to implement, and does not require external equipment assistance in actual use, but the method has low precision and is not suitable for medical treatment. field. 2. External device calibration method: relying on high-precision external equipment, such as turntables, for accurate calibration, main calibration installation error, scale factor and zero offset, mostly used for calibration in the laboratory, there are equipment restrictions. 3. Kalman Filtering: Jafari et al. [Jafari, Sahebjameyan, Moshiri et al. (2015)] used dual Kalman filtering, which is an excellent tool for data fusion from noise signals, calibrating MEMS gyros and accelerometers, respectively, and using modeling methods to minimize prediction errors for Kalman the zero-bias stability and random walk noise in the filter are modeled, but the algorithm is computationally complex and different filter parameters need to be set for different sensors [Liu, Li, Di et al. (2018)]. 4. Dynamic and static inertial measurement: Liu et al. [Liu and Fang (2008)] adopts an improved dynamic and static inertial measurement system (INS) high-precision calibration method. Although the accuracy is improved, the method needs to be assisted by external precision equipment (calibration turntable). In this case, this method cannot be used for accurate calibration. CIMT has limited applicability and it is not suitable for widespread use in the acute phase of stroke. In addition, CMIT is expensive.

Robotic assisted therapy
Provides or supports high-intensity and controllable repetitive upper limb exercises that are more easily recognized by patients than traditional exercise therapies.
It is impossible to perform the flexion and extension training of the wrist joint. The system's own joint range estimation system and the protractor have a large error in the actual measured value, which is expensive and not popular.

Mental practice with motor imagery
Can improve nerve function and innervation muscle function The largest study to date has not improved the results, so there is no clear evidence that it can perform stroke rehabilitation independently.
FES A large number of clinical studies have proved that electrical stimulation therapy can significantly improve the limb function of patients with stroke, improve the limb control ability of patients, and the wrist flexion and extension function and hand coordination activities of patients after FES treatment are significantly improved.
It is very challenging to achieve a satisfactory control of muscle response to stimuli.
In order to make the calibration of FES controller accelerometer more convenient and accurate, this paper adopts the method of fitting calibration, and optimizes it based on this, and proposes a method to calculate the automatic calibration gain robustly by using redundant acceleration vector. Then, the data generated by the acceleration sensor is calibrated according to the calculated gain.

Methodology
Because the 6-position calibration method requires a well-designed instrument, this method is only suitable for in-lab calibration. In order to break through the limitations of the instrument, Lötters et al. [Lötters, Schipper, Veltink et al. (1998)]. proposed an initial method that does not require any alignment equipment and is suitable for any type of accelerometer calibration. The method is based on the following theorem. In the case of static placement, the measured acceleration modulus is always Local gravity acceleration: (1) The method proposed in this paper is also based on the theorem.

Model
Ideally, the accelerometer will have exactly the same sensitivity anywhere within the specified amplitude range. It is generally accepted that models can be considered to be linear. ] , then the model is: The calibrated acceleration is linked to the original acceleration reading by six calibration parameters (three scale factors and three offsets). The model is based on a restrictive assumption: the three axes of the accelerometer are perfectly orthogonal. Due to the inaccurate structure of the three-axis accelerometer, the three axes cannot be completely orthogonal, we use T to represent the transformation matrix of the axis deviation: To further simplify the transformation matrix T, we assume that the x-axis of the reference coordinate system coincides with the x-axis of the accelerometer's actual rotating coordinate system, and the y-axis of the reference frame is in the plane of the x-axis and the y-axis of the actual rotation coordinate system of the accelerometer. So, the transformation matrix can be further written as follows: such that the model becomes: where ac is the calibrated acceleration, T a is the transformation matrix of the axis deviation, S is the scale factor, am is the acceleration reading, b is the offset. The factor can be replaced by a new matrix k whose factor depends on the non-orthogonal, acceleration sensitivity of the axis.

Calculates auto-calibration gains
The auto-calibration gain of each sensitive axis can be calculated using Eqs. (6) -(8) below. We need at least 3 acceleration vectors to solve the following equation: (g selects the local gravity acceleration of Nanjing 9.79 m/s 2 [Baidu Document (2018) Where kx, ky and kz are the automatic calibration gains for each sensitive axis respectively, ax, ay and az are the accelerometer readings before calibration. In order to be able to calculate the calibration gain robustly, we use a redundant acceleration vector to calculate. When we use more acceleration vectors instead of 3, for example when using 9 vectors, (which will explain how to select the acceleration vector in the third part) we will get the following equation: Finally, calculate the calibration gain ( 2 , 2 and 2 ) according to Eq. (10).

Calculates auto-calibration errors
We use the least squares error model to calculate the error of the auto-calibration gain for each accelerometer's sensitive axis, calculated by Eqs. (11)-(12) below: where 1 − 9 are the calculated errors for when applies a set of calculated auto-calibration gains for each linear equations.

Calculated g using auto-calibration i 4 Experiments
In this section, we will use the above methods to select different acceleration data sets for experiments. Before the calibration, the acceleration sensor readings should be close to the gravitational acceleration when static. Therefore, the calculated gain should be approximately equal to one. We use the following steps to experiment with different acceleration vectors for different data sets: 1. Move the sensor along 3 axes to collect 5 seconds of acceleration data; 2. Select 9 acceleration vectors in different ways, select eight fixed points, the ninth point is the moving point, and calculate data for each group of nine; 3. Calculate the gain and error of each group; 4. Calculate the automatic calibration gain after removing the bad acceleration vector; 5. Compare the gain calculated before and after the bad acceleration vector is removed. Acceleration data when moving the acceleration sensing unit along the x, y, and z axes is collected (see Fig. 3). The dashed vertical line represents the eight acceleration vectors that calculate the auto-calibration gain. The ninth acceleration vector is moved from the first acceleration reading in the above figure to the last acceleration reading. These 9 acceleration vectors are combined to calculate the gain.   CMC, vol.60, no.1, pp.67-83, 2019 Figure 5: Sum of the errors of the different ninth acceleration vectors As can be seen from Fig. 5, there is a large error in some points, which we can think is due to the existence of a bad acceleration vector. The bad acceleration vector is generated by signal noise or when the acceleration sensor is moved with a large acceleration. Next, we remove the bad acceleration vector and compare the gain changes between the two. We have developed a rejecting rule: set a threshold, which is the best guess from the average of the initial partial error readings. When the error is greater than the threshold, we consider this a bad acceleration vector. Fig. 6 shows the auto-calibration gain after rejecting the bad acceleration vector (bad calculation is when sum of errors greater than 51.15, this is the average from first 80 readings).  Tab. 2 shows the gain and standard deviation of each axis of the acceleration sensor before and after the bad vector is removed.
We can see that after eliminating the bad acceleration vector, the standard deviation is significantly smaller than the unremoved, so that we can get the auto-calibration gain more accurately.
In the following experiment, we used the same data set as the previous experiment. When we selected eight acceleration vectors, we let them have no significant separation, as shown in the vertical dotted line in Fig. 7. The same as above dashed vertical line represents the eight acceleration vectors that calculate the auto-calibration gain. The ninth acceleration vector is moved from the first acceleration reading in the above figure to the last acceleration reading.    Fig. 9, we can see that this may cause a portion of the error when the selected acceleration vector is not significantly separated. This is because if many selected acceleration vectors (each acceleration vector is a linear equation, e.g., 2 1 2 + 2 1 2 + 2 1 2 = (9.79m/s 2 ) 2 ) are closed to each other (see dash vertical lines in Fig. 9). The errors ( = 1 − 9) for a set of calculated auto-calibration gains applied to those closed linear equations might be all small. This will lead to an overall small sum of error. In addition, those acceleration vectors (linear equations) will be more likely to be linear dependent to each other. When there is another g vector, which is separated from those closed g vectors, obtained for the calculation (see Fig. 7 when ninth acceleration vector moves from 2.5 seconds), this may lead to a big increase to the sum of errors (see Fig. 9 from 2.5 seconds). A possible explanation to this is, the errors ( = 1 − 9) for a set of calculated auto-calibration gains applied to those closed linear equations increasing at a same time. Therefore, we propose that in this automatic calibration method, when the acceleration sensing unit rotates, all acquired acceleration vectors should be separated from each other in space. When there is a calibration phase, we move the acceleration sensing unit around the X, Y, and Z axes and pause for >1 second when the x-axis is in different quadrants of space, and get the first 8 acceleration vectors when the acceleration sensing unit is at different pauses. Fig. 10 shows the acceleration data for the calibration phase. The acceleration sensing unit rotates around the X, Y, and Z axes, and pauses for >1 second when the x-axis sensing unit is in different quadrants of space. When the sensing unit is paused at a certain position, the first 8 acceleration vectors are obtained. The acceleration vector from the calibration phase is considered to have good quality because there is a large gap between them under spatial and static conditions (minimizing the effect of the acceleration motion of the sensing unit). The ninth acceleration vector moves from the first acceleration reading in the above figure to the last acceleration reading. Combine all 9 acceleration vectors to calculate the gain.  It can be seen from Fig. 13 that the calculated auto-calibration gains are very close to 1, indicating that the accelerometer unit is well calibrated. As can be seen from the comparison Tab. 3, the error after calibration is significantly less than before calibration. Next, we collect another data set that rotates the sensing unit around the X, Y, and Z axes, and pauses for >1 second when the x-axis sensing unit is in different quadrants (approximately the first 20 seconds) in the space of the calibration phase. When the sensing unit is paused at a certain position, the first 8 acceleration vectors are obtained. The ninth acceleration moves from the acceleration reading at approximately 21 seconds in Fig. 14 to the last acceleration reading.

Conclusion
Stroke survivors may lose control of upper limbs. FES therapy is a post-stroke rehabilitation intervention, and FSM has proven to be an effective and intuitive FES control method. The FSM uses the data information generated by the accelerometer to robustly trigger state transitions. In the medical field, highly accurate acceleration data is required, and the correlation of human motion analysis results directly depends on the accuracy of the collected data. Therefore, we need to calibrate the accelerometer. This paper proposes a method to calculate the auto-calibration gain robustly using redundant acceleration vectors. The least squares error model is used to calculate the error of the auto-calibration gain of each accelerometer's sensitive axis. This method removes the limitations of calibration equipment and is superior to traditional laboratory calibration methods. In the experiment, we found that the error of partial calculation increases due to the existence of poor acceleration vector. For this reason, we have established a rule to eliminate the bad acceleration vector and calculate the automatic calibration gain. It has been experimentally shown that this may cause some error when the selected acceleration vector is not significantly separated. Therefore, we propose that in the automatic calibration method, when the acceleration sensing unit rotates, all acquired acceleration vectors should be separated from each other in space. Next, after the calibration phase, we move the acceleration sensing unit around the X, Y and Z axes and pause for >1 second when the x axis is in different quadrants of space, and obtain the first 8 acceleration vectors, which minimizes the acceleration of the sensing unit. The impact, then calculate the gain and compare. Experiments show that the calculated auto-calibration gain is very close to 1, which indicates that the accelerometer unit is well calibrated. It can be seen from the experimental comparison table that the error after calibration is significantly less than before calibration.