**4. Rule-based gait detection**

In this chapter, the raw measurements of accelerometer and gyroscope are compared first, then the gait events are identified by using a rule-based method, and finally the false-detected gait phases are discussed and eliminated.

### **4.1 Raw inertial measurements**

Different methods have been presented for gait detection in the literature [38]. In a sense, gait phases are a function of time and inertial measurements. A segment of raw measurements is shown in **Figure 13**, including specific forces and angular rates of both feet measured by the accelerometer and the gyroscope, respectively, together with the key gait events and their delimited gait phases. Gait detection can be achieved by using a rule-based method from the raw measurements or its magnitude [39], root mean square [40], and moving average [41], which is straightforward and easy to implement. Different detection methods have been compared in [42], and the results suggest that angular rate is more reliable than acceleration for typical walking. As can be seen in **Figure 13**, the angular rates provide more prominent characteristics than the specific forces for gait detection, especially the angular rate around *Z*-axis in the sagittal plane. Due to the specificity of foot motion, there are at least two possible explanations for this phenomenon:

**Figure 13.** *A segment of raw inertial measurements from both feet.*


#### **4.2 Gait detection with predefined rules**

The rules for gait detection from inertial data can be predefined against the ground truth provided by the Vicon system. Generally, three types of rules might be involved in the detection process, i.e., peak detection, flat-zone detection, and zero-crossing detection. Take the stance phase, for example, it is the nature of walking or running locomotion that the foot swings to stance phase in every gait cycle and then exhibits a zero velocity until it swings again. This information can be effectively utilized by a flat-zone detection method to identify the successive stance phases. With careful rule design and parameter selection, the rule-based methods can identify all concerned events from a long inertial data sequence.

For a straight-line walking of 20 m long, the detection results are shown in **Figure 14**. However, as seen in **Figure 13**, the measurements are characterized by some sudden spikes, especially when the HS and TO events occur, which can induce momentary fluctuations in the magnitude or short-term statistics of angular rates and thereby result in false detections of gait phases. In some research, a time heuristic method is applied to the raw detection results to avoid unnecessary influence of the measurement fluctuations, i.e., incorrectly declaring, interrupting, or missing of gait phases. This is achieved by adding a time duration threshold to filter out the gait phases that have a duration shorter than the threshold, as the false gait phases are usually short-lasting [43, 44]. However, as all the thresholds are hand-tuned, they may work well for the gait data that they are derived from, but not apply to each subject's individual gait.

**89**

**Figure 15.**

*Applications of MEMS Gyroscope for Human Gait Analysis*

*DOI: http://dx.doi.org/10.5772/intechopen.86837*

**4.3 Elimination of false gait phases**

*Results of gait division and gait detection.*

**Figure 14.**

their simplicity and efficiency.

As each individual has a unique gait pattern, the percentage of the gait cycle

*Binary classification of potential gait phases. (a) Clustering of stance phases and (b) Clustering of swing phases.*

spent in each phase slightly varies between the literature sources. In literature research, it is rarely discussed explicitly how to choose a time duration threshold for eliminating the false gait phases but based on empirical evidence. Therefore, an adaptive time threshold is required to provide a more robust method for gait detection. As done in our previous study, a clustering technique can be used to automatically distinguish the true and false gait phases according to their time durations and yield the time threshold parameter simultaneously [33], as shown in **Figure 15**. In this scenario, since the number of clusters is known, the k-mean or k-median methods can be employed due to

*Applications of MEMS Gyroscope for Human Gait Analysis DOI: http://dx.doi.org/10.5772/intechopen.86837*

*Gyroscopes - Principles and Applications*

*A segment of raw inertial measurements from both feet.*

**4.2 Gait detection with predefined rules**

inertial data sequence.

each subject's individual gait.

higher than that of the specific forces.

error, gravity disturbance, and accelerometer bias.

1.Although the angular rates have large bias, their SNR (signal-to-noise ratio) is

2.The specific forces are perturbed by the integrated effects of initial alignment

The rules for gait detection from inertial data can be predefined against the ground truth provided by the Vicon system. Generally, three types of rules might be involved in the detection process, i.e., peak detection, flat-zone detection, and zero-crossing detection. Take the stance phase, for example, it is the nature of walking or running locomotion that the foot swings to stance phase in every gait cycle and then exhibits a zero velocity until it swings again. This information can be effectively utilized by a flat-zone detection method to identify the successive stance phases. With careful rule design and parameter selection, the rule-based methods can identify all concerned events from a long

For a straight-line walking of 20 m long, the detection results are shown in **Figure 14**. However, as seen in **Figure 13**, the measurements are characterized by some sudden spikes, especially when the HS and TO events occur, which can induce momentary fluctuations in the magnitude or short-term statistics of angular rates and thereby result in false detections of gait phases. In some research, a time heuristic method is applied to the raw detection results to avoid unnecessary influence of the measurement fluctuations, i.e., incorrectly declaring, interrupting, or missing of gait phases. This is achieved by adding a time duration threshold to filter out the gait phases that have a duration shorter than the threshold, as the false gait phases are usually short-lasting [43, 44]. However, as all the thresholds are hand-tuned, they may work well for the gait data that they are derived from, but not apply to

**88**

**Figure 13.**

**Figure 14.** *Results of gait division and gait detection.*

#### **4.3 Elimination of false gait phases**

As each individual has a unique gait pattern, the percentage of the gait cycle spent in each phase slightly varies between the literature sources. In literature research, it is rarely discussed explicitly how to choose a time duration threshold for eliminating the false gait phases but based on empirical evidence. Therefore, an adaptive time threshold is required to provide a more robust method for gait detection. As done in our previous study, a clustering technique can be used to automatically distinguish the true and false gait phases according to their time durations and yield the time threshold parameter simultaneously [33], as shown in **Figure 15**. In this scenario, since the number of clusters is known, the k-mean or k-median methods can be employed due to their simplicity and efficiency.

**Figure 15.** *Binary classification of potential gait phases. (a) Clustering of stance phases and (b) Clustering of swing phases.*

Multiple parameters are involved for gait detection, which are interrelated and work together to achieve their goal. The adopted clustering technique tried to tune one of the thresholds automatically (i.e., the time threshold of gait phases) and further facilitate the choice of other thresholds, but careful parameter setting is stilled needed. Generally, rule-based methods rely on careful sensor alignment and a set of thresholds, which are brittle or difficult to implement due to the natural variability of human gait. Moreover, the thresholds are usually hand-tuned and fixed in the whole process regardless of gait changes, and the process of rule designing and threshold tuning itself is frustrating and time-consuming. Furthermore, if new sensors are added to the setup or the sensors are attached to new locations, new detection rules and associated thresholds are required. Therefore, there is a clear need of an adaptive detection method.

## **5. Machine learning-based gait detection**

As mentioned above, gait detection is actually a pattern recognition problem. Hidden Markov models (HMMs) have been widely used for pattern recognition. An HMM-based method was developed for gait detection in children with and without hemiplegia, and the gait events were specified as hidden states [45]. A classifier based on HMM is applied for gait phase detection and discrimination between walkingjogging activities [20]. An HMM was applied to detect the gait phases of children with cerebral palsy [46]. However, HMMs are less suitable for gait data of high dimension. An HMM was adopted to estimate temporal gait parameters with a feature selection and model parametrization system based on genetic algorithms (GAs) [47]. An HMM was presented to detect gait phases with observations provided by a five-layer feed-forward neural network (FNN) [48]. Generally, these hybrid methods have better performance than the pure HMMs when dealing with high-dimensional data. Inspired by the existing methods, an adaptive hybrid method is presented in our previous study [36], by modeling human gait with a left-right HMM and employing a three-layer neural network (NN) to deal with the raw measurements.

#### **5.1 HMM-based gait model**

HMM is a statistical model used to represent discrete and stochastic Markov process, in which the states cannot be directly observed. It can be of three types, i.e., ergodic, left-right, or parallel left-right. At each time instant, HMM is in just one state. For gait detection, the gait events or their delimited phases are the hidden states of HMM. Due to the periodic nature of normal foot motion with a sequence of ordered gait events, each state can only transit to itself or the "right" state. Thus, each gait phase can be represented by a unique state in HMM using a left-right model, as shown in **Figure 16**, where *aij* is the state transition probability. This process yields a sequence of hidden states and a sequence of corresponding observations. Each HMM state corresponds to a gait phase that begins with the present gait event and lasts until the next event.

**91**

*Applications of MEMS Gyroscope for Human Gait Analysis*

*DOI: http://dx.doi.org/10.5772/intechopen.86837*

**5.2 NN-/HMM-based hybrid gait model**

*Framework of the hybrid gait detection method.*

inputs in isolation.

**Figure 17.**

**6. Gait analysis experiment**

Given a sequence of ordered observations and a trained HMM, the Viterbi algorithm can estimate the most likely sequence of hidden states. However, HMMs are generative models, whereas discriminative models are supposed to achieve better classification results. Discriminative models based on machine learning techniques are perceived to be promising alternatives to HMMs [49]. Generally, any machine learning method, such as support vector machine (SVM), k-nearest neighbor (k-NN), and neural network (NN), can be used for gait detection. It is found that NNs can achieve the best trade-off between efficiency, accuracy, and computational complexity. The NNs can learn nonlinear combinations of inputs automatically, and a three-layer network can approximate any multivariate polynomial function [50]. However, the pure NNs have been limited to process

To take advantage of both NN and HMM methods for gait detection, one intuitive way is to combine them together in a hybrid manner [48]. The NN can process the gyroscope measurements first and provide observations for HMM with its classifications. Each input of NN is formed by using a sliding window approach, and hence it might be of high dimension. The HMM can model the sequential property of human gait and complement the NN by providing contextual information. **Figure 17** shows the framework of training and testing procedures of this hybrid detection method. Although the NN-/HMM-based hybrid method is computationally complex for training, it is computationally efficient at runtime. It requires no careful sensor alignment or parameter adjustment and generalizes well to new subjects, new gaits, new sensors, and new sensor locations [51].

Usually, pathological gait exhibits a characteristic gait pattern with limited range and velocity, such as shortened stance phase and step length, reduced gait cadence and gait velocity, and diminished extension-flexion movement. The outputs of wearable gait analysis system are of great use for a close examination of human gait, which allow a rapid and accurate quantification of these abnormalities. In this section, the setup and results of the experiments are first presented, then some discussions on the experimental results are made, and finally the capability of IMU-based

gait analysis system for tracking the rehabilitation process is verified.

**Figure 16.** *Left-right HMM with four gait phases.*

*Applications of MEMS Gyroscope for Human Gait Analysis DOI: http://dx.doi.org/10.5772/intechopen.86837*

**Figure 17.**

*Gyroscopes - Principles and Applications*

need of an adaptive detection method.

**5.1 HMM-based gait model**

**5. Machine learning-based gait detection**

Multiple parameters are involved for gait detection, which are interrelated and work together to achieve their goal. The adopted clustering technique tried to tune one of the thresholds automatically (i.e., the time threshold of gait phases) and further facilitate the choice of other thresholds, but careful parameter setting is stilled needed. Generally, rule-based methods rely on careful sensor alignment and a set of thresholds, which are brittle or difficult to implement due to the natural variability of human gait. Moreover, the thresholds are usually hand-tuned and fixed in the whole process regardless of gait changes, and the process of rule designing and threshold tuning itself is frustrating and time-consuming. Furthermore, if new sensors are added to the setup or the sensors are attached to new locations, new detection rules and associated thresholds are required. Therefore, there is a clear

As mentioned above, gait detection is actually a pattern recognition problem. Hidden Markov models (HMMs) have been widely used for pattern recognition. An HMM-based method was developed for gait detection in children with and without hemiplegia, and the gait events were specified as hidden states [45]. A classifier based on HMM is applied for gait phase detection and discrimination between walkingjogging activities [20]. An HMM was applied to detect the gait phases of children with cerebral palsy [46]. However, HMMs are less suitable for gait data of high dimension. An HMM was adopted to estimate temporal gait parameters with a feature selection and model parametrization system based on genetic algorithms (GAs) [47]. An HMM was presented to detect gait phases with observations provided by a five-layer feed-forward neural network (FNN) [48]. Generally, these hybrid methods have better performance than the pure HMMs when dealing with high-dimensional data. Inspired by the existing methods, an adaptive hybrid method is presented in our previous study [36], by modeling human gait with a left-right HMM and employing a

three-layer neural network (NN) to deal with the raw measurements.

gait phase that begins with the present gait event and lasts until the next event.

HMM is a statistical model used to represent discrete and stochastic Markov process, in which the states cannot be directly observed. It can be of three types, i.e., ergodic, left-right, or parallel left-right. At each time instant, HMM is in just one state. For gait detection, the gait events or their delimited phases are the hidden states of HMM. Due to the periodic nature of normal foot motion with a sequence of ordered gait events, each state can only transit to itself or the "right" state. Thus, each gait phase can be represented by a unique state in HMM using a left-right model, as shown in **Figure 16**, where *aij* is the state transition probability. This process yields a sequence of hidden states and a sequence of corresponding observations. Each HMM state corresponds to a

**90**

**Figure 16.**

*Left-right HMM with four gait phases.*

*Framework of the hybrid gait detection method.*

### **5.2 NN-/HMM-based hybrid gait model**

Given a sequence of ordered observations and a trained HMM, the Viterbi algorithm can estimate the most likely sequence of hidden states. However, HMMs are generative models, whereas discriminative models are supposed to achieve better classification results. Discriminative models based on machine learning techniques are perceived to be promising alternatives to HMMs [49]. Generally, any machine learning method, such as support vector machine (SVM), k-nearest neighbor (k-NN), and neural network (NN), can be used for gait detection. It is found that NNs can achieve the best trade-off between efficiency, accuracy, and computational complexity. The NNs can learn nonlinear combinations of inputs automatically, and a three-layer network can approximate any multivariate polynomial function [50]. However, the pure NNs have been limited to process inputs in isolation.

To take advantage of both NN and HMM methods for gait detection, one intuitive way is to combine them together in a hybrid manner [48]. The NN can process the gyroscope measurements first and provide observations for HMM with its classifications. Each input of NN is formed by using a sliding window approach, and hence it might be of high dimension. The HMM can model the sequential property of human gait and complement the NN by providing contextual information. **Figure 17** shows the framework of training and testing procedures of this hybrid detection method. Although the NN-/HMM-based hybrid method is computationally complex for training, it is computationally efficient at runtime. It requires no careful sensor alignment or parameter adjustment and generalizes well to new subjects, new gaits, new sensors, and new sensor locations [51].

### **6. Gait analysis experiment**

Usually, pathological gait exhibits a characteristic gait pattern with limited range and velocity, such as shortened stance phase and step length, reduced gait cadence and gait velocity, and diminished extension-flexion movement. The outputs of wearable gait analysis system are of great use for a close examination of human gait, which allow a rapid and accurate quantification of these abnormalities. In this section, the setup and results of the experiments are first presented, then some discussions on the experimental results are made, and finally the capability of IMU-based gait analysis system for tracking the rehabilitation process is verified.
