A New Hidden Markov Model Algorithm to Detect Human Gait Phase Based on Information Fusion Combining Inertial with Plantar Pressure

Gait phase detection is important in the field of motion analysis and exoskeleton-assisted walking so that the accurate control of exoskeleton robots can be achieved. Therefore, to obtain accurate motion gait information and ensure good detection accuracy of the gait phase, in this study, a new hidden Markov model (N-HMM) algorithm is proposed to improve the accuracy of gait phase detection. A multisensor gait data acquisition system was developed to determine the acceleration and plantar pressure of the human body. Data were collected from 10 healthy subjects and sensors were attached to the subjects’ legs and feet to detect the motion gait phase. A comparison of results with hidden Markov model (HMM) algorithms shows that the proposed algorithm improves the recall and precision rates by 3 and 3.5%, respectively. The N-HMM was used for gait phase detection and the detection accuracy of the N-HMM was compared with that of the HMM, support vector machine (SVM), decision tree, and back propagation (BP) network algorithms. The average accuracy of the N-HMM was 96.2%, outperforming all other algorithms. The results show that the N-HMM is capable of detecting the human gait phase with high accuracy. The results of this study provide a theoretical basis for the design and control of exoskeleton robots.


Introduction
Gait phase detection is an effective method for analyzing human motion and behavior recognition. It is very meaningful in people's daily life and is valuable for assisted walking. (1) The detection of the human gait and the selection of the appropriate parameters to achieve safe and effective motion control are important to achieve high accuracy, safety, and stability. (2,3) Recent advances in sensor technology have enabled the development of small, low-cost wearable devices that are widely used for the collection of physiological, biomechanical, and motion data. (4) In the field of gait phase detection, sensors based on 3D optical detection have been used. However, they have limited application space and can only be used indoors. (5) Lim et al. used an electromyographic (EMG) sensor to collect data on human muscle activity and identified up to four gait stages. (6) However, the sensor requires a complex and specific mounting method, because it requires direct contact with the skin and is susceptible to sweat between the skin and the sensor, which reduces the accuracy of data collection. (7) Inertial sensors, such as gyroscopes, accelerometers, and magnetometers, are becoming more popular because they are not affected by the aforementioned sensor limitations. (8) An internal measurement unit (IMU) is a low-cost, low-energy, and durable device that is easily carried, provides accurate and up-to-date human motion data, and is easily attached to different parts of the human body. (9) Machine learning algorithms are widely used in different disciplines. Linear discriminant analysis and artificial neural networks have been widely used for human motion detection. (10) Hargrove et al. detected human motions, such as horizontal walking, walking up and down stairs, and standing, and achieved detection rates between 77.3 and 90.0%. (11,12) However, the disadvantage of this method is that it can only be used indoors. Ferreira et al. used support vector machine (SVM) and K-nearest-neighbor algorithms and nine accelerometers. (13) Hernandez et al. used acceleration sensors and myoelectric sensors to identify human motion with a detection rate of 91%. (14) However, one disadvantage of these methods is that they require a large number of sensors, and the calibration, synchronization, and collection of data are particularly complex. (15) Lerner et al. used seven sensors, which were mounted on the feet, thighs, calves, and waists. The gait phase was identified on the basis of a feed-forward neural network; however, the system required seven sensors and the detection rate was lower than 85%. (16,17) Bingli et al. used acceleration signals collected by a mobile phone tied to the waist to identify the gait phase using a hidden Markov model (HMM); the results were used for identity authentication on mobile phones. (18,19) Mannini and Sabatini used an HMM for gait phase detection using motion information acquired by a gyroscope fixed on the instep. However, the detection accuracy of the algorithm was not sufficiently high to achieve detailed control. (20) Exoskeleton control requires highly accurate detection. (21,22) To obtain accurate motion gait information and ensure good detection accuracy of the gait phase, in this study, a new hidden Markov model (N-HMM) algorithm is proposed for gait phase detection. A time parameter is used in the N-HMM, and the time-based distribution function replaces the self-transition probability. We collect motion data from 10 healthy test subjects, including the acceleration signal of the human leg and the pressure signal of the foot. A comparison of results with HMM algorithms shows that the proposed algorithm improves the recall rate and accuracy by 3 and 3.5%, respectively. The N-HMM was used for gait phase detection, and the detection accuracy of the N-HMM was compared with those of other algorithms. The average accuracy rate of the proposed N-HMM for the gait phase detection is 96.2%, outperforming all other algorithms. The experimental results show that the N-HMM algorithm can achieve a higher recognition rate.
This paper is organized as follows. Section 1 shows the introduction. Section 2 describes the acquisition system and gait phase division. Section 3 describes the experiments and algorithms. Section 4 presents the results and discussion. Section 5 presents the conclusions and prospects.

Sensor system
The gait information acquisition system consists of two types of sensor, namely, acceleration and pressure sensors. The pressure device is used to sense the pressure on the sole of the foot, and the acceleration device is used to sense the acceleration of the movement of the human leg. The two types of sensor are used together to obtain accurate gait information, detect the state of human motion, and thus identify the intentions of the human body. The four acceleration sensors are installed in the middle of the calf and the middle of the thigh. The four pressure sensors are installed on the sole of the foot. The data collection of the wearable sensors is shown in Fig. 1.
The sensor signal acquisition is divided into six controller area network (CAN) bus communication nodes, namely, the left thigh, left calf, right thigh, right calf, left foot, and right foot. Each IMU module collects motion information for a group of test subjects, and the collected data is transmitted to a microcontroller unit (MCU) module of the corresponding slave. When the host sends a data request through the CAN bus, the six slaves transmit the sensor data to the MCU of the host through the CAN bus, and the host transmits the data to the upper computer through a wireless serial port. The data acquisition system is shown in Fig. 2.

Inertial sensor
The inertial sensor ADXL345 is small and characterized by ultralow power consumption and high resolution (up to 13 bits and a measurement range of ±16 g). (23) The workflow of ADXL345 is as follows: The XYZ three-axis sensor unit detects the acceleration in the three axes and converts it into an analog signal, which is stored in the sensor. Table 1 shows the specifications of ADXL345. To obtain as much useful motion information as possible, the location of the sensor on the subject is important. ADXL345 is placed in the middle of the thigh and the middle of the shank, as shown in Fig. 3. The thigh sensor is mounted 16 cm above the knee joint, and the sensor position on the calf is 15 cm below the knee joint. Experience has shown that the attachment of the sensors in these positions provides accurate data on the motion and acceleration of the leg. (24) The same position is used in each experiment for consistency.

Plantar pressure sensor
The pressure sensor used in the gait information acquisition system is FSR402, as shown in Fig. 4(a). The greater the pressure applied to the sensing element, the smaller the resistance of the internal circuit, resulting in a higher output voltage. The allowable pressure range for such sensors is typically from 100 g to 10 kg of gravity. Table 2 shows the characteristics of the FSR402 pressure sensor.
In the walking phase, it is important to choose a suitable location for the sensor to collect the plantar pressure data. During walking, the heel is the initial contact part and the toe contact represents the end of the supporting phase. Therefore, the four key points selected for the location of the sensor are the toes and heels, as shown in Fig. 4(b). The four FSRs are named FSR1, FSR2, FSR3, and FSR4, respectively.

Gait division
The gait is a periodic cycle from the first contact of one foot on the ground to the second contact of the heel on the ground. Usually, a gait cycle is divided into two main phases, namely, the stance and swing phases. Heel striking the ground and toe off the ground mark the beginning of the stance and swing phases, respectively. (25)    During the walking cycle, the human legs in turn support the person while moving forward. There are four gait stages, as shown in Fig. 5. They are the initial contact (IC), foot flat (FF), heel off the ground (HO), and toe off the ground (TO). The initial contact is a short-lived process that reveals the interaction between the heel and the ground. During the loading response, the leg absorbs the impact until the forefoot falls on the ground. When standing in the middle, the foot is stationary and supports the weight because the other foot begins to swing. When the heel is off the ground, the terminal posture begins and continues while the toe still touches the ground. Once the toe is off the ground, the cycle enters the swing phase. All the gait phases in which the ground is touched are stance phases. The standing phase lasts nearly 62% of the walking time, whereas the swing phase comprises nearly 38%. By identifying these gait phases, the device can be acted upon at the right time. (26)

Participants and measurements
In this experiment, we used ten healthy test subjects (age: 26 ± 2 years old, height: 170 ± 7 cm, weight: 60 ± 8 kg, and shoe size: 24.5 ± 2.5 cm). The specific information (age, height, weight, and shoe size) of the subjects is shown in Table 3. Everyone was asked to  perform a series of exercises; all the subjects were healthy, were able to walk normally, and had no gait disturbances. For the sake of precision, the materials of the shoes were the same, and the size of the insole sensor was prepared according to the size of the foot, which met the conditions of the experiment. The subjects did not perform strenuous exercises one week prior to the experiment. A consent form was signed.
The subjects' exercise data were collected at the same speed and the tester walked on a treadmill at a speed of 2.8 km/h. On the treadmill, the subject was tested three times at the same speed with a recording interval of 3 min per test. All leg acceleration signals and plantar pressure signal data were obtained. Figure 6 shows a subject walking on the treadmill during the experiment.

Data processing
The motion gait signal is a low-frequency signal. We used a wavelet to filter out the highfrequency noise. Wavelet decomposition was used to perform a time-frequency transformation of the signal. By shifting and stretching, the high-frequency noise can be separated from the motion gait data. Irregular points in the data are eliminated by smoothing. Figure 7 shows the acceleration data of one test subject.
Each set of accelerometer data includes acceleration information in the three directions a x , a y , and a z . The use of too many variables makes it difficult to analyze the results; therefore, data reduction is required. In this study, principal component analysis (PCA) is used to compress and reduce the acceleration data in three directions to reduce the number of input variables. At a speed of 2.8 km/h, the right thigh acceleration Comp.1RT is expressed by Eq.
(1); the right calf acceleration Comp.1RC is expressed by Eq. (2); the left thigh acceleration Comp.2LT is expressed by Eq. (3); the left calf acceleration Comp.2LC is expressed by Eq. (4). The acceleration data after PCA are shown in Fig. 8. There are 4 accelerometers, and the threeaxis data of each sensor can obtain reasonable parameters as shown by the formula after PCA, and the accurate percentage can reach 95%.
To detect the gait phases, we have to find features in the data that reflect the gait phases. A sliding window is used and the overlap between the adjacent windows is 50%. The extracted features consist of the mean and variance of the acceleration, as shown in Eqs. (5) and (6). Mean: Variance: Among them, N is the total number. The acceleration data and plantar pressure data have strong periodicity, and there is a clear boundary between the adjacent cycles. The phase of the cycle is also evident. The FSR data are used to extract the gait cycle and phase by determining the force of the heel striking the ground and the toes being off the ground. Four phases of the human gait are divided using the plantar pressure data. An example of the four-phase division of the right leg acceleration data and plantar pressure data is shown in Fig. 9.
As shown in Fig. 9, there are two consecutive cycles during human walking. The blue line represents the force of the heel and the red line represents the force of the toe. At point A, the heel begins to land and, owing to the forward movement, the heel pressure gradually increases. At point B, the toes begin to touch the ground, the heels move gradually off the ground, and the pressure decreases. At point C, the heel is completely off the ground and the toe force is largest. At point D, the toe is off the ground. DE indicates the swing phase until the cycle begins again at point E. The four phases in the figure are as follows: A→B is phase S1, from the heel striking the ground to the foot being flat; B→C is phase S2, from the foot being flat to the heel being off the ground; C→D is phase S3, from the heel being off the ground to the toe being off the ground; D→E is phase S4, from the toe being off the ground to the heel striking the ground again.

3.3
Parameter training of hidden Markov model

Conventional hidden Markov model
The HMM is a statistical model based on the Markov chain. (27) It consists of two parts, a state sequence and an observation sequence. It is determined by the initial state probability vector π, the state transition probability matrix A, and the observed probability matrix B. It can be represented by a set of ternary symbols: The HMM can have two types of structure based on the structure of the transition probability matrix A. One is a cyclic type of each state and the other is a left and right circulation type. In the traversing structure, each state can be mutually converted. In the left and right traversing structures, there is a certain order of transition between the states and each state cannot be easily converted. (28) The two structures of the HMM are shown in Fig. 10.
Since the four stages of the gait are not directly observable, we observe the acceleration of the leg. We use a Gaussian probability model to map the observable acceleration data and unobservable gait stages. We divide the gait cycle into four stages, and the number of states in the HMM is four. We represent these four gait stages as S1, S2, S3, and S4. For the four phases of the gait cycle, we find that the transition between the gait phases occurs only between the adjacent phases, and the direction of the transfer is fixed; one stage either persists or changes into the next stage. In the state observation probability matrix, the transition probability between nonadjacent stages is 0 and there is a sequence of gait stages. The final HMM structure is shown in Fig. 11.

New hidden Markov model
Because the conventional HMM does not contain a time factor, it can only use mathematical statistics to describe the probability of remaining in a certain state for a certain time. In the conventional HMM, the dwell time d is defined as the number of times in a state and a ü is the self-transition probability. In the HMM, the probability of d in the state q i is   Equation (8) indicates that in the HMM, the probability of the state dwell time is geometrically distributed and its value decreases exponentially over time. However, in most cases, the probability of each state remaining near the average residence time is highest. For the gait stage model, we assume that there are three adjacent stages A, B, and C. When moving from phase A to phase B, the probability that the state remains in phase B increases, and when the time in phase B approaches the average dwell time, the probability that the state remains in phase B is highest. Next, during the transition from stage B to stage C, the probability of the state remaining in stage B will decrease. From this process, we can see that there is a process of initial increase followed by a decrease in the state residence time of the gait phase. However, the state residence time of the HMM is geometrically distributed and there is only one descent process. Therefore, the use of the HMM to describe the transition between gait phases has a relatively low accuracy.
We describe the dwell time by using a time-based distribution function instead of the rotation probability in the HMM and introduce time parameters into the modified HMM. For each state, instead of the self-transition probability in the conventional HMM, we use a residence time distribution function to describe the probability that the state remains in the phase. The N-HMM consists of four parts, namely, the initial state probability vector π, the state transition probability matrix A, the observation probability matrix B, and the dwell time distribution function P.
The state dwell time distribution is ( ) indicating the probability of d time units residing in state p j , it can be described by a gamma distribution as Here, a j is the shape parameter of the dwell time and b j is the scale parameter of the dwell time.
The N-HMM model λ is defined as The set Q is a collection of all states and the set V is a collection of all observations: , ,..., , , ,..., , 12) where N is the number of states and M is the number of observations.
I is a sequence of states of length T and O is the corresponding observation sequence: The schematic diagram of the N-HMM is shown in Fig. 12.
The use of the time parameters in the N-HMM overcomes the limitation of modeling in the HMM due to the Markov chain assumption. The N-HMM is more suitable than the HMM for describing the gait phase sequence. By introducing the dwell time distribution function into the conventional HMM, we can accurately describe the gait cycle and detect the four stages in the gait cycle.

Algorithm block diagram and model construction
The gait phase identification algorithm diagram of the N-HMM is shown in Fig. 13. First, the human motion data collected by the sensors are divided into two parts: the training and test sets. The data include the acceleration sensor data and plantar pressure data. Secondly, the data in the training set are preprocessed and extracted, and then the extracted features and reference phase are modeled to establish the proposed HMM model. Finally, the data from the test set are input into the established gait recognition model, and the recognition results are obtained to evaluate the performance of gait recognition.
The four-phase gait cycle described by the Markov process is a process of various states. A complete gait cycle is a continuous first-order Markov process; the gait stage either remains in  this stage or moves to the next stage. At the same time, for each phase, the process that resides in that phase can be considered as a gamma distribution of the dwell time. Thus, the four-phase gait cycle described by the N-HMM can be described as a first-order Markov process when moving from one stage to the next. The model structure is shown in Fig. 14.

Results
We used appropriate indicators to evaluate the gait phase detection performance based on the N-HMM. We calculated the precision and recall to assess the overall performance of the model and also used the curve of the receiver operating characteristics (ROC) to evaluate the performance.
The precision indicator considers the impact of the sample distribution on the detection rate. The recall rate refers to the proportion of positive samples correctly identified to the total number of positive samples, which is regarded as the detection rate of a single gait stage. (29) The accuracy is the result of positive samples detected by the classifier and the proportion of real positive samples; it is the overall detection rate of the system. (30) The calculation formulas are Eqs. (14)- (16). Precision: Recall: As shown in Fig. 15, for the gait phases S1 and S4, the detection performance of the N-HMM is better than that of the HMM. For the gait phase S2, the two models have similar performance characteristics. For the gait phase S3, the HMM performance is better than that of the N-HMM. Overall, the N-HMM performs better than the HMM.
As shown in Table 4, for the gait phases S1, S3, and S4, the recall is higher for the N-HMM than for the HMM, which indicates that the N-HMM detects these three phases better than the HMM. For the gait phase S2, the recall metrics of the N-HMM and HMM are the same. Overall, the average recall rate of the N-HMM is 93.5% and that of the HMM is 90.5%, which is lower by 3%. For the gait phases S1, S2, and S4, the precision is higher for the N-HMM than for the HMM, which indicates that the N-HMM detects these three phases better than the HMM. For the gait phase S3, the precision metrics of the N-HMM and HMM are the same. Overall, the average precision rate of the N-HMM is 95.5% and that of the HMM is 92%, which is lower by 3.5%. This result indicates that the N-HMM is more suitable for gait phase detection than the HMM. As shown in Fig. 16, the ROC results indicate that for the gait phases S1 and S4, the detection performance is better for the N-HMM than for the HMM. For the gait phase S2, the two models have the same performance. For the gait phase S3, the HMM has a better performance than the N-HMM. Overall, the N-HMM is better than the HMM.

Comparative analysis
Commonly used gait detection methods include SVM algorithms, decision trees, and neural networks. In Sect. 4.1, we compared the detection performance characteristics of the N-HMM and HMM. The results showed that the N-HMM was more suitable for gait phase detection and had a better performance than the HMM. In this section, we compare the average accuracy rates of the N-HMM algorithm with those of other common gait phase detection algorithms. We use the same data as in the previous section; the results of the various algorithms are shown in Table 5 and Fig. 17.
As shown in Table 5, the detection rate of the N-HMM was determined to be higher than those of the other algorithms. The N-HMM exhibited a better detection performance than the HMM. The average accuracy rate of the N-HMM is 96.2% and that of the HMM is 93.2%. The results showed that the average accuracy rate of the N-HMM was higher than that of the HMM, and that the detection performance was better. Nickel et al. discussed in detail the results of using the HMM and SVM for gait phase detection using acceleration data. (31,32) They pointed out that the SVM had a higher error rate than the HMM. Our experimental results were consistent with the results of Nickel et al. The average accuracy rate of the N-HMM is 96.2% and that of the SVM is 90.7%, which is lower by 5.5%. For the back-propagation (BP) neural network and decision tree, the detection results of the N-HMM are better than those of the BP neural network and decision tree. The average accuracy rate of the BP neural network is 87.5% and that of the decision tree is 89.2%. Both are lower than the recognition rate of the N-HMM, as shown in Fig. 17. BP neural networks commonly fall into a local optimum during training, and decision trees can suffer from overfitting or underfitting in the training process. The results show that the N-HMM algorithm has the highest average detection rate. Therefore, the  gait detection algorithm using the N-HMM algorithm is very suitable for gait detection and the recognition rate is high, making it highly suitable for controlling exoskeleton robots.

Conclusions
The accurate identification of human movements and gaits is of great significance for the control of exoskeleton robots. In this paper, the N-HMM algorithm was proposed to improve the accuracy of gait phase detection. A multisensor fusion human gait detection method was developed. Ten healthy test subjects were fitted with sensors and instructed to walk on a treadmill to obtain the data. A comparison of the results of HMM algorithms showed that the proposed algorithm improves the recall and precision rates by 3 and 3.5%, respectively. The proposed N-HMM was capable of accurately detecting the gait phases of the human gait cycle. We compared the average accuracy rates of the N-HMM, HMM, SVM, and other common gait phase detection algorithms. The experimental results showed that the proposed algorithm resulted in the highest accuracy with an average gait detection rate of 96.2%. The results also showed that the N-HMM algorithm can achieve a higher recognition rate, laying a theoretical foundation for the development of intelligent wearable robots. In the future, we will investigate the motion phases under different conditions, such as the identification of the moving phases of staircase walking and uphill and downhill walking.