Curve Similarity Model for Real-Time Gait Phase Detection Based on Ground Contact Forces

This paper proposed a new novel method to adaptively detect gait patterns in real time through the ground contact forces (GCFs) measured by load cell. The curve similarity model (CSM) is used to identify the division of off-ground and on-ground statuses, and differentiate gait patterns based on the detection rules. Traditionally, published threshold-based methods detect gait patterns by means of setting a fixed threshold to divide the GCFs into on-ground and off-ground statuses. However, the threshold-based methods in the literature are neither an adaptive nor a real-time approach. In this paper, the curve is composed of a series of continuous or discrete ordered GCF data points, and the CSM is built offline to obtain a training template. Then, the testing curve is compared with the training template to figure out the degree of similarity. If the computed degree of similarity is less than a given threshold, they are considered to be similar, which would lead to the division of off-ground and on-ground statuses. Finally, gait patterns could be differentiated according to the status division based on the detection rules. In order to test the detection error rate of the proposed method, a method in the literature is introduced as the reference method to obtain comparative results. The experimental results indicated that the proposed method could be used for real-time gait pattern detection, detect the gait patterns adaptively, and obtain a low error rate compared with the reference method.


Introduction
Gait pattern detection is an effective way to monitor and analyze the condition of human walking [1]. Gait analysis plays an important role in the fields of lower limb rehabilitation robot, assisting exoskeleton human-machine coupling systems, and daily life assistance [2]. On the basis of the specific objective of gait analysis, various sensor platforms and algorithms have been developed to classify all or some gait phases, including force sensors [3][4][5][6], inertial sensors [7][8][9], foot switches [3], and electromyography (EMG) sensors [10].
Recently, a large number of new sensors and their signal processing methods have been used for gait recognition. A gait recognition system in loose clothing has been proposed in the works of [11,12], where four sets of flexible piezoelectric sensors were embedded in both knee and hip parts on the patient's pants. Mileti et al. designed a pair of shoes with an Inertial Measurement Unit (IMU) and foot switches on each foot for gait quality assessment [13]. Zhou et al. combined color sensors, depth sensors, and inertial sensors for gait data collection and gait recognition [14]. Among the sensor platforms, force sensor platforms, such as load cell, which could be located in shoe soles to measure the ground contact force (GCF), may represent the gold standard method for gait analysis [15]. The electrical resistance change of a load cell is proportional to the GCF acted by the human foot.

Subjects and Procedures
This study included twenty-four subjects of average age 23.1 ± 3.2 years and average mass 68.2 ± 7.6 kg with no history of foot diseases or limitations. The study was approved by Beijing Sport University Institution Review Board (Re.-No. 2019007H). Before the experiments, the subjects gave their written informed consent for participation in this study as the purpose was explained in detail to each of them and their safeties could be ensured.
To validate our research, a gait phase detection system was designed as pictured in Figure 1. Two sets of load cells (LOSON LSH-10, LOSON Instrumetation, Nankin, China) were severally located in the insole of ball and heel. The load cell signals were collected at a sample frequency of 2000 Hz through 16-bit AD converters. A pressure tester (TLS-S1000W, Jinan Zhongchuang Industry Test System Co., Ltd., Jinan, China) is used to calibrate the load cell such that the amplified output signal within a range of 0-5 V correlates with the measured mass of 0-200 kg [27]. After data acquisition and sensor calibration, the GCF signals were filtered by average filter with a cut-off frequency of 100 Hz to eliminate the unnecessary high frequency noise.

Subjects and Procedures
This study included twenty-four subjects of average age 23.1 ± 3.2 years and average mass 68.2 ± 7.6 kg with no history of foot diseases or limitations. The study was approved by Beijing Sport University Institution Review Board (Re.-No. 2019007H). Before the experiments, the subjects gave their written informed consent for participation in this study as the purpose was explained in detail to each of them and their safeties could be ensured.
To validate our research, a gait phase detection system was designed as pictured in Figure 1. Two sets of load cells (LOSON LSH-10, LOSON Instrumetation, Nankin, China) were severally located in the insole of ball and heel. The load cell signals were collected at a sample frequency of 2000 Hz through 16-bit AD converters. A pressure tester (TLS-S1000W, Jinan Zhongchuang Industry Test System Co., Ltd, Jinan, China) is used to calibrate the load cell such that the amplified output signal within a range of 0-5 V correlates with the measured mass of 0-200 kg [27]. After data acquisition and sensor calibration, the GCF signals were filtered by average filter with a cut-off frequency of 100 Hz to eliminate the unnecessary high frequency noise. Each subject was asked to perform five trials to wear the designed shoes (i.e., seen in Figure 1) to walk on a treadmill. The five trials were performed for 30 s each at a designated constant speed of 2 km/h, 3 km/h, 4 km/h, 5 km/h, and 6 km/h in turn. According to the adult's step size of 60 cm~80 cm, the duration of each gait cycle at a speed of 2~6 km/h is about 1000~2000 ms. The slower the speed, the longer the gait cycle. Each subject took an average of 110 steps at different speeds with 150 s. Using the same acquisition device, we selected 10 subjects from the above-mentioned 24 subjects for continuous shift 60 s walking experiments, using real-time data for online gait phase detection.

Gait Pattern Detection Algorithm
Generally, a complete gait cycle could be divided into two main phases, that is, stance phase and swing phase. As two sets of load cell were mounted in each shoe, four types of gait patterns could be differentiated. Specifically, when the foot fully contacts the ground, the gait pattern is the stance phase. When the foot totally leaves the ground, the gait pattern is the swing phase. The Each subject was asked to perform five trials to wear the designed shoes (i.e., seen in Figure 1) to walk on a treadmill. The five trials were performed for 30 s each at a designated constant speed of 2 km/h, 3 km/h, 4 km/h, 5 km/h, and 6 km/h in turn. According to the adult's step size of 60 cm~80 cm, the duration of each gait cycle at a speed of 2~6 km/h is about 1000~2000 ms. The slower the speed, the longer the gait cycle. Each subject took an average of 110 steps at different speeds with 150 s. Using the same acquisition device, we selected 10 subjects from the above-mentioned 24 subjects for continuous shift 60 s walking experiments, using real-time data for online gait phase detection.

Gait Pattern Detection Algorithm
Generally, a complete gait cycle could be divided into two main phases, that is, stance phase and swing phase. As two sets of load cell were mounted in each shoe, four types of gait patterns could be differentiated. Specifically, when the foot fully contacts the ground, the gait pattern is the stance phase. When the foot totally leaves the ground, the gait pattern is the swing phase. The transitions between the stance and swing phases are gait events. When the ball leaves the ground and the heel contacts the ground, the gait pattern is heel strike. When the ball contacts the ground and the heel leaves the ground, the gait pattern is heel-off.
Usually, the division of contacting or leaving the ground is made through setting a threshold. Several drawbacks existed for threshold-based methods, which have been summarized in detail in the works of [21,28]. To solve these problems, this paper used the curve similarity model to implement the status division of contacting or leaving the ground.
If this curve similarity model is built, a curve consisting of several GCF points would be discriminated to be on-ground or off-ground status. The key to this model is to determine the start point of each status so that the GCF will be discriminated to be in the same status for a subsequent period of time until the next different gait starting point is detected. Meanwhile, if more GCF points are used, the curve similarity model would gain better results. However, more computation resource would be costed. In this paper, four GCF points are utilized to build the curve similarity model.

Global Threshold Method and Its Disadvantage
By setting a threshold Thr, GCFs can be divided into on-ground and off-ground statuses: where T(i) is the GCF at i-th point and Thr is the threshold. The Lopez-Meyer [6] method calculates the mean values of the maximum and minimum threshold of GCFs as the Thr for gait detection. The mathematical expressions are as follows: ( The scale factor is obtained by the leave-one-out method, which is used in gait detection system. In this paper, set α = 0.094. Usually, m is not equal to be n. At the most, the GCF has only one maximum and only one minimum value in a complete gait cycle. However, an incomplete gait cycle would lead to only one Tmax or Tmin. Therefore, an abnormality will occur in the gait discrimination.
Although the threshold value is intuitive, the sensor detection pressure is related to the wearer's weight and walking posture, and it is easy to generate abnormal values, which can be clearly seen in Figure 2. Therefore, when using the threshold method for gait detection directly, it is necessary to eliminate these abnormal conditions. If window filtering is used, the system detection delay will be increased in a real-time system.  The GCF value change is related to the walking speed. As seen in Figure 3, when the walking speed changes from 2 Km/h to 6 Km/h, the GCF value gradually increases, and the corresponding Thr also gradually increases. Therefore, for variable speed walking, the threshold of Thr is uncertain. Combined with the above analysis, it can be seen that the threshold method is simple to calculate, but the stability and reliability need to be improved in real-time calculation. In the postview after-the-fact analysis, combined with window filtering, it can be used as a reference for gait detection for comparative analysis.

Starting Flag of on-Ground and off-Ground Statuses
The starting time of each status was determined by comparing GCFs with the threshold calculated through the Lopez-Meyer method [6].
Obviously, the threshold was only used in the training of the curve similarity model. As depicted in Figure 4, a curve consisting of four GCF points is obtained referring to the threshold. The GCF value change is related to the walking speed. As seen in Figure 3, when the walking speed changes from 2 km/h to 6 km/h, the GCF value gradually increases, and the corresponding Thr also gradually increases. Therefore, for variable speed walking, the threshold of Thr is uncertain. The GCF value change is related to the walking speed. As seen in Figure 3, when the walking speed changes from 2 Km/h to 6 Km/h, the GCF value gradually increases, and the corresponding Thr also gradually increases. Therefore, for variable speed walking, the threshold of Thr is uncertain. Combined with the above analysis, it can be seen that the threshold method is simple to calculate, but the stability and reliability need to be improved in real-time calculation. In the postview after-the-fact analysis, combined with window filtering, it can be used as a reference for gait detection for comparative analysis.

Starting Flag of on-Ground and off-Ground Statuses
The starting time of each status was determined by comparing GCFs with the threshold calculated through the Lopez-Meyer method [6].
Obviously, the threshold was only used in the training of the curve similarity model. As depicted in Figure 4, a curve consisting of four GCF points is obtained referring to the threshold. Combined with the above analysis, it can be seen that the threshold method is simple to calculate, but the stability and reliability need to be improved in real-time calculation. In the post-view after-the-fact analysis, combined with window filtering, it can be used as a reference for gait detection for comparative analysis.

Starting Flag of on-Ground and off-Ground Statuses
The starting time of each status was determined by comparing GCFs with the threshold calculated through the Lopez-Meyer method [6].
Obviously, the threshold was only used in the training of the curve similarity model. As depicted in Figure 4, a curve consisting of four GCF points is obtained referring to the threshold. x(i) is GCF at the starting flag of on-ground status, while x(i − 1), x(i − 2), and x(i − 3) are the GCFs identified as off-ground status. If this curve could be recognized accurately, the on-ground status would be differentiated initially. The future GCFs with a long period after x(i) would also be judged to be on-ground status. Meanwhile, if the ending flag of on-ground status could be recognized, the on-ground status would be differentiated totally. x(i) is GCF at the starting flag of on-ground status, while x(i − 1), x(i − 2), and x(i − 3) are the GCFs identified as off-ground status. If this curve could be recognized accurately, the on-ground status would be differentiated initially. The future GCFs with a long period after x(i) would also be judged to be on-ground status. Meanwhile, if the ending flag of on-ground status could be recognized, the on-ground status would be differentiated totally. However, the ending flag of on-ground status is extremely similar to the starting flag of offground status, as pictured in Figure 5. Obviously, a one point difference existed between the two flags. If the starting flag of off-ground status is identified, the ending flag of on-ground status could be deduced. As shown in Figure 5, a curve consisting of four GCF points is acquired referring to the threshold. x(i) is GCF at the starting flag of off-ground status, while x(i − 1), x(i − 2), and x(i − 3) are the GCFs identified as on-ground status. Similarly, if this curve could be identified accurately, the off-ground status would be differentiated initially. The future GCFs with a long period after x(i) would also be judged to be off-ground status. Additionally, the ending flag of off-ground status could be deduced according to the recognition of the starting flag of on-ground status, as demonstrated in Figure 4.  However, the ending flag of on-ground status is extremely similar to the starting flag of off-ground status, as pictured in Figure 5. Obviously, a one point difference existed between the two flags. If the starting flag of off-ground status is identified, the ending flag of on-ground status could be deduced. As shown in Figure 5, a curve consisting of four GCF points is acquired referring to the threshold.
x(i) is GCF at the starting flag of off-ground status, while x(i − 1), x(i − 2), and x(i − 3) are the GCFs identified as on-ground status. Similarly, if this curve could be identified accurately, the off-ground status would be differentiated initially. The future GCFs with a long period after x(i) would also be judged to be off-ground status. Additionally, the ending flag of off-ground status could be deduced according to the recognition of the starting flag of on-ground status, as demonstrated in Figure 4. x(i) is GCF at the starting flag of on-ground status, while x(i − 1), x(i − 2), and x(i − 3) are the GCFs identified as off-ground status. If this curve could be recognized accurately, the on-ground status would be differentiated initially. The future GCFs with a long period after x(i) would also be judged to be on-ground status. Meanwhile, if the ending flag of on-ground status could be recognized, the on-ground status would be differentiated totally. However, the ending flag of on-ground status is extremely similar to the starting flag of offground status, as pictured in Figure 5. Obviously, a one point difference existed between the two flags. If the starting flag of off-ground status is identified, the ending flag of on-ground status could be deduced. As shown in Figure 5, a curve consisting of four GCF points is acquired referring to the threshold. x(i) is GCF at the starting flag of off-ground status, while , and x(i − 3) are the GCFs identified as on-ground status. Similarly, if this curve could be identified accurately, the off-ground status would be differentiated initially. The future GCFs with a long period after x(i) would also be judged to be off-ground status. Additionally, the ending flag of off-ground status could be deduced according to the recognition of the starting flag of on-ground status, as demonstrated in Figure 4.  Thus, the status division could be made by recognizing the starting flags of on-ground and off-ground statuses according to Figures 4 and 5. The curve similarity model is built to identify the two flags, which is described in the following section.
. However, according to actual experiments, if only four GCF points were used to establish the model, it would lead to many detection mistakes. Therefore, scale difference was added to extend this curve, which could be rewritten as follows: where L (k) is the k-scale difference of L; and the range of k is selected to be 1, 2, and 3 in this model. Then, L (k) could be expanded as follows: where is the k-scale difference of the sequence at x(i), and Equation (4) could be described as follows: After curve extension, the model should be constructed and noted as ϕ(L), where ϕ(L) is the transformation function. Curve similarity theory is used to measure the degree of similarity between two curves. Firstly, given two curves, L A and L B , the similarity distance between them could be expressed as follows: where d is the similarity distance between two curves, and | | is the absolute distance. For d, given a threshold ε, if d ≤ ε, the curves L A and L B are proven to be similar. Otherwise, they are not. According to Equations (3) and (5), there are ten elements in curve L, including four GCF point and their scale differences. In order to describe the curve similarity model in an understandable manner, the curve L is rewritten as follows: To transform every element of L in the same dimension, Gaussian function is selected to be the transformation function ϕ(L), which could be described as follows: where φ(x j ) is the transformation function of x j . Meanwhile, µ j and δ j are the average value and standard deviation of x j , respectively. Thus, the gains of µ j and δ j should be calculated or trained from gait phase labeling data. For L A and L B , one of them is considered as a reference curve or template curve, which is trained and represents a classification, while the other is considered as a comparison curve to measure similarity of two curves. Assuming that L A is the template curve, the obtained x j for L A is equal to µ j by coincidence. Meanwhile, L B is the comparison curve. Then, the similarity distance between L A and L B could be rewritten as follows: The purpose of building this curve similarity model is to measure the similarity of the reference curve and comparison curve. Once the comparison curve is similar to the reference curve, the comparison curve has the same classification as the reference curve. Given a threshold ε, if d ≤ ε, the curves L A and L B are proven to be similar. Generally, the threshold ε is selected as follows: where P is the length of L, and equals 10 in this model. Then, ε = 2 is preferable. As depicted in Figures 4 and 5, the starting flags of on-ground and off-ground statuses should be recognized. Therefore, two curve similarity models should be constructed severally for on-ground and off-ground statuses, noted as ϕ(L 1 ) and ϕ(L 2 ). Meanwhile, each model is built through Equation (8), and the parameters in these models are selected through Equation (10).
The testing data point is noted as the comparison curve ϕ(Lc) and we calculate the similarity distances as follows: For ϕ(L 1 ), if d 1 is smaller than ε, the testing data point is classified as on-ground status. On the other side, for ϕ(L 2 ), if d 2 is smaller than ε, the testing data point is classified as off-ground status. However, if the testing data point fails to satisfy both conditions, the testing data point is classified as its last status.

Gait Phase Classification by GCF
As mentioned above, detecting the starting flag of off-ground status can determine whether the gait phrase enters off-ground status, and detecting the starting flag of on-ground status can determine whether the gait phase enters off-ground status. It is very difficult to capture solely the occurrence of the starting flags of two statuses because that the range of pressure varies greatly. The range before and after is used as the interval from which the starting flags of off-ground and on-ground statuses occur, and the new gait classification is redefined.
In the process from on-ground to off-ground, when the GCF is less than the threshold pressure and before middle off-ground, we define the status as the initial status of off-ground, referred to as the initial off-ground. There is a corresponding process from off-ground to on-ground, which is called the initial on-ground. Its duration range is from the terminal off-ground to the first time when GCF is greater than the threshold pressure.
From a large number of walking gait pressure curves, this pressure change lasts from 40 to 60 ms, where the faster the walking, the shorter the duration. We take a continuously changing pressure curve as our research object, and develop the gait detection model within one gait cycle to four status detection, that is, the initial off-ground, the off-ground, the initial on-ground, and on-ground statuses order by order. Here, the on-ground status is labeled as 3, the initial off-ground status is labeled as 1, the off-ground status is labeled as 0, and the initial on-ground status is labeled as 2. In this way, we divide a normal walking process into four gait phases that are repeated over and over again, as shown in Figure 6. pressure curve as our research object, and develop the gait detection model within one gait cycle to four status detection, that is, the initial off-ground, the off-ground, the initial on-ground, and onground statuses order by order. Here, the on-ground status is labeled as 3, the initial off-ground status is labeled as 1, the off-ground status is labeled as 0, and the initial on-ground status is labeled as 2. In this way, we divide a normal walking process into four gait phases that are repeated over and over again, as shown in Figure 6. Therefore, the specific classification of gait phase is as follows: (1) Traverse a piece of GCF data, calculate Thr; (2) In each gait cycle, when the gait motion moves from on-ground to off-ground status, the first data point whose GCF is less than Thr is calculated as the starting position of the initial offground status, and then the delay time tW where the data point is the ending position of the initial off-ground status, and the subsequent point is taken as the off-ground status; (3) Likely, when the gait motion moves from off-ground to on-ground status, the first data point whose GCF is greater than Thr is calculated as the ending position of the initial on-ground status, and then time tW in advance where the data point is the starting position of the initial on-ground status, and the subsequent point is taken as the on-ground status; (4) On the part of abnormal gait tagging data, such as gait mutation, tW is too large or too small, take the form of manual updating.

Evaluation Protocols of the Gait Phase Detection
In order to evaluate the reliability of the proposed method, the reference method should be determined. As reported in the work of [6], the Lopez-Meyer method was approved through comparing itself with the "GAITRite system", and gained a comparative and reliable confidence of 95%. Therefore, the Lopez-Meyer method was introduced as the reference method. However, the term of detection error rate was used to replace the reliability. Then, the detection error rate of this Therefore, the specific classification of gait phase is as follows: (1) Traverse a piece of GCF data, calculate Thr; (2) In each gait cycle, when the gait motion moves from on-ground to off-ground status, the first data point whose GCF is less than Thr is calculated as the starting position of the initial off-ground status, and then the delay time t W where the data point is the ending position of the initial off-ground status, and the subsequent point is taken as the off-ground status; (3) Likely, when the gait motion moves from off-ground to on-ground status, the first data point whose GCF is greater than Thr is calculated as the ending position of the initial on-ground status, and then time t W in advance where the data point is the starting position of the initial on-ground status, and the subsequent point is taken as the on-ground status; (4) On the part of abnormal gait tagging data, such as gait mutation, t W is too large or too small, take the form of manual updating.
Usually, set t W = 40~60 ms, here t W = 50 ms, if one gait cycle is 1000 ms~2000 ms, the maximum theoretical error of detection is 2.5%~5%.

Evaluation Protocols of the Gait Phase Detection
In order to evaluate the reliability of the proposed method, the reference method should be determined. As reported in the work of [6], the Lopez-Meyer method was approved through comparing itself with the "GAITRite system", and gained a comparative and reliable confidence of 95%. Therefore, the Lopez-Meyer method was introduced as the reference method. However, the term of detection error rate was used to replace the reliability. Then, the detection error rate of this study was determined by comparing the detection results between the reference method and the proposed algorithm.
Four points are taken as a gait curve, and gait data is traversed. Each training sample contains the GCF values of four data points as input, and the gait phase classification of the last data point is used as the classifier output.
In the evaluation protocol of actual detection statuses, the corresponding detection results under each status are as described in Table 1.

Detection
True Status

On-Ground (3) Initial Off-Ground (1) Off-Ground (0) Initial Off-Ground (2)
Starting flag of off-ground × Keep the last status The symbol "*" indicates no evaluation. In a gait movement, the actual number of gait phases is cn i . The number of corresponding gait phases detected each time is dn i , where the correct detection number is tn i , the missed detection number is mn i , the false detection number is fn i , and the over detection number is sn i , where i = 1 or 2.
Then, the total error values for gait detection of off-ground and on-ground statuses are defined as follows: Obviously, tn i = cn i − mn i . At the same time, mn i is called the number of missed detections, fn i is also called the number of false detections, and sn i is called the number of over detections. When the number of training samples is fixed, the smaller the F 1 or F 2 , the lower the error rate, the higher the accuracy of the system, and the better the corresponding curve template.
In the experiments, we mainly evaluate gait detection to solve a classification problem. As a classification problem, we use classification error rate as a measurement of performance evaluation. The error rate of each gait phase detection for off-ground and on-ground status, and the total error rate are defined as E 1 = (mn 1 + f n 1 )/cn 1 × 100% E 2 = (mn 2 + f n 2 )/cn 2 × 100% E 3 = (mn 1 + f n 1 + mn 2 + f n 2 )/(cn 1 + cn 2 ) × 100% (13) At the same time, we also use the method from the literature [27,28] to evaluate the accuracy of gait phase detection.
where c(k) is the true gait phase represented by every GCF data point, h(k) is the result of gait phase detection for every moment, and N is length of all data points. E 4 can be considered as the total data point error rate.

Development of Gait Phase Classifiers by EC
Note that the quality of curve template is a very important index for gait phase detection. A good curve template will be able to better distinguish the starting flag of off-ground and on-ground status. Therefore, the key is to find the optimal parameters of the template curve. We label the collected gait data for four categories by the Lopez-Meyer method and divide them into a training set and a testing set. In this paper, an evolutionary computation (EC) algorithm is presented to carry out random intelligent search. Because the off-ground and on-ground curve templates are independent of each other, the evolutionary computation will be carried out twice.
The overall idea of evolutionary computation is to generate random PopSize individuals S = {S 1 , S 2 , . . . S PopSize }, each of which corresponds to a set of template curve parameters µ and δ.
In each iteration search of evolutionary computation, each individual will correspond to a total detection error value F 1 or F 2 as Formula (9), where the smaller the total detection error value, the better the individual. Fitness value is calculated by the sum of all the error values of the training dataset at one iteration.
The specific Algorithm 1 steps are described as follows: According to the maximum number of generations MaxGen as termination conditions. Normally, PopSize = 20, MaxGen = 200.

Real-Time Gait Detection by CSMs
In real-time gait detection, we directly use gait detection by trained two CSMs from multiple people and different speeds, as shown in Figure 7. Taking the left foot as an example, the real-time gait detection Algorithm 2 is as follows:

Results and Discussion
There were two different databases for the experiment; one database comes from 24 subjects including 120 sample files and the other database came from 10 subjects including 10 sample files. In each sample file, the global threshold method described in Section 2.3 was used to label the data, and the data of each gait cycle were labeled as four gait phases. Walking at speeds of 2-6 Km/h for 30 s, a total of 100 gait cycles around would be obtained for each subject.
Because the adoption rate was 100 Hz, labeled gait classification data of 3000 rows would be generated for training and testing by traversing each sampling point in each sample of first database. Therefore, our gait classification records for the whole training and testing were about 120 × 3000 = 360,000.

Results and Discussion
There were two different databases for the experiment; one database comes from 24 subjects including 120 sample files and the other database came from 10 subjects including 10 sample files. In each sample file, the global threshold method described in Section 2.3 was used to label the data, and the data of each gait cycle were labeled as four gait phases. Walking at speeds of 2-6 Km/h for 30 s, a total of 100 gait cycles around would be obtained for each subject.
Because the adoption rate was 100 Hz, labeled gait classification data of 3000 rows would be generated for training and testing by traversing each sampling point in each sample of first database. Therefore, our gait classification records for the whole training and testing were about 120 × 3000 = 360,000.
For the first database, we selected some samples as training set and the rest as a testing set. Firstly, 25, 50, and 75 samples from subjects #1~5, #1~10, and #1~15, respectively, were selected as training set to verify the accuracy and reliability of the model. Secondly, five samples from subjects #1, #4, #9, #12, and #15 were selected as a training set, and the all subjects were selected as a testing set to verify the robustness of the model. For each training set, we repeated it 10 times to obtain different models to verify the reliability and stability of the models. Finally, for the second database, we chose the model trained to test the generalization performance of the model for continuous variable speed walking.

Results of Gait Pattern Detection
We used 50 samples from 10 subjects as training data and the rest of the samples as testing data. The ten elements of L in each gait cycle could be obtained by referring to the threshold calculated through the Lopez-Meyer method. Then, mean value and standard deviation for each element could be calculated. µ and δ from the curve similarity model for off-ground and on-ground status are listed in Tables 2 and 3, respectively. In the first experiment, with 50 samples of the training set, the EC algorithm searches the optimal parameters of two CSMs for off-ground and on-ground status, respectively, to minimize the corresponding F 1 and F 2 values. µ and δ from two CSMs for off-ground and on-ground status are listed in Tables 2 and 3, respectively. Then, the training sets were processed using the selected coefficients to obtain the detection error rate. Meanwhile, the testing sets from the remaining subjects were processed using the same coefficients.
In this paper, the collected GCFs from the ball and heel were processed using the proposed method, which are collectively pictured in Figure 8a,b. The starting flags of on-ground status are marked as a triangle, while those of off-ground status are marked as a circle. It could be clearly illustrated in Figure 8a that more than one starting flag of on-ground status could be obtained in one gait cycle. However, this situation would not cause any detection error because the results were still identified as on-ground statuses. When the status divisions of ball and heel were accomplished, the gait pattern could be distinguished according to the rules, as shown in Figure 9a    We apply the same CSMs to the gait phase detection of biped walking, and the results at different walking speeds are shown in Figure 10. We apply the same CSMs to the gait phase detection of biped walking, and the results at different walking speeds are shown in Figure 10. As can be seen from Figure 10, with the increase of walking speed, the GCF value gradually increases. The traditional fixed threshold method has great limitations. Our method can be well adapted to gait detection at different walking speeds. At the same time, we can adapt to the gait detection of the other foot by using only one foot data for training.

Accuracy and Reliability
As the off-ground and on-ground statuses were both identified using the two CSMs, the detection error rate should be calculated for both statuses. Note that E1 is the detection error rate for off-ground statuses, E2 is the detection error rate for on-ground statuses, E3 is the total detection error rate, and E4 is another detection error rate named the total data point error rate. As depicted in Table 4, the proposed method gains highly low detection error rates when compared with the reference method. Training Testing Figure 10. A subject gait phrase detection at speeds of 2~6 km/h.
As can be seen from Figure 10, with the increase of walking speed, the GCF value gradually increases. The traditional fixed threshold method has great limitations. Our method can be well adapted to gait detection at different walking speeds. At the same time, we can adapt to the gait detection of the other foot by using only one foot data for training.

Accuracy and Reliability
As the off-ground and on-ground statuses were both identified using the two CSMs, the detection error rate should be calculated for both statuses. Note that E 1 is the detection error rate for off-ground statuses, E 2 is the detection error rate for on-ground statuses, E 3 is the total detection error rate, and E 4 is another detection error rate named the total data point error rate. As depicted in Table 4, the proposed method gains highly low detection error rates when compared with the reference method. As can be seen from Table 4, the accuracy of the other subjects for testing is very high according to our evaluation protocol, except for subjects #16, #21, and #24. Even so, we find that with the same E 4 protocol statistics, the total error rate of several high error rate subjects is less than 10%. This shows that our proposed model can be well adapted to the traditional way of statistics, with a strong fault-tolerant performance.
According to the evaluation protocol, E 1 , E 2 , and E 3 for subject #5 were zero, indicating that the trained model could accomplish the gait classification perfectly. The corresponding E 4 is 6.86% because of the difference in gait switching positions caused by the two different evaluation protocols. Furthermore, repeating the above-mentioned experiment ten times with 25, 50, and 75 samples, we count the overall average rate as an assessment of system accuracy and reliability, as depicted in Table 5.

No.
Training Testing  Form Table 5d, the total average detection error rates were 4.10% and 3.92% for the training and testing data, respectively. On the other side, both the PM and STTTA methods were used to compute the detection error rates by E 4 . As a result, with the same evaluation protocol, 7.75%, 10.82%, and 10.55% were acquired for the CSM, the PM, and the STTTA, respectively. Experimental results demonstrated that the proposed method performed better in the application of gait pattern detection than the methods in the literature [25,26].
For each training model, the generated model parameters were different, and the maximum error rate using different protocol statistics was less than 10%, which showed that the proposed method was reliable and effective. Of course, choosing the optimal model to further reduce the gait detection error rate would be the next step in the future.

Robustness and Stability
As the on-ground and off-ground statuses were both identified using the CSM, the detection error rate should be computed for both status robustness.
For the second experiment, ten repetitive training sessions were conducted to calculate the error rate of each result, and the results were arranged from small to large according to E 3 and E 4 values, as shown in Figure 11.

Robustness and Stability
As the on-ground and off-ground statuses were both identified using the CSM, the detection error rate should be computed for both status robustness.
For the second experiment, ten repetitive training sessions were conducted to calculate the error rate of each result, and the results were arranged from small to large according to E3 and E4 values, as shown in Figure 11. Figure 11. The average error rate of 10 times is counted, and the results are as follows. STTTA, selftuning triple-threshold algorithm; PM, proportional method.
As seen in Table 6, according to the error rate E4 statistics, the worst case is better than the other two methods, while the model training only uses GCF data of one subject at different speeds.  [24] 10.82% Comparison with STTTA [25] 10.55% Obviously, the more data are used for training, the higher the accuracy of the model would be, and the better the model adapts to the changes of GCF at different speeds with strong robustness. The Table 6 indicates that the CSMs can be trained by only one subject and tested by other subjects of different weights.

Generalization Performance
Using the above-mentioned trained models, we tested and verified ten people walking for 60 s. Once the model had been trained, in real-time gait detection, the model's input depended only on the current and past four sampling points of the sole GCF. The two CSM models respectively detect the out-of-synchronization flag events, and the detection results start with a new gait phase. Figure 11. The average error rate of 10 times is counted, and the results are as follows. STTTA, self-tuning triple-threshold algorithm; PM, proportional method.
As seen in Table 6, according to the error rate E 4 statistics, the worst case is better than the other two methods, while the model training only uses GCF data of one subject at different speeds.  [24] 10.82% Comparison with STTTA [25] 10.55% Obviously, the more data are used for training, the higher the accuracy of the model would be, and the better the model adapts to the changes of GCF at different speeds with strong robustness. The Table 6 indicates that the CSMs can be trained by only one subject and tested by other subjects of different weights.

Generalization Performance
Using the above-mentioned trained models, we tested and verified ten people walking for 60 s. Once the model had been trained, in real-time gait detection, the model's input depended only on the current and past four sampling points of the sole GCF. The two CSM models respectively detect the out-of-synchronization flag events, and the detection results start with a new gait phase. Therefore, this model was fully applicable to real-time gait detection. Similarly, the global Lopez method is combined with filtering to label the data, and the comparison is performed by PM, STTA, and the CSM method proposed. The experimental results are as follows Table 7. It can be seen in Table 7 that the detection result of #10 is the best. In evaluation mode 1, the accuracy of the gait detection result is 100%, and the detection result of #2 is the worst. Figures 12  and 13 show the results of all gait tests.
It can be seen in Figures 12-14 that in the real-time gait detection, the CSM method can obtain better real-time detection results without the new training model. The more training data, the higher the accuracy of the model detection, and the more versatile it is.
As a machine learning method, it was important to train data with quality and quantity. We chose multiple model trainings for different sizes of sample files. Although each trained model parameter was inconsistent, we achieved good accuracy on the testing set as shown in Figures 12-14, which indicates that the proposed model had good generalization performance. Therefore, this model was fully applicable to real-time gait detection. Similarly, the global Lopez method is combined with filtering to label the data, and the comparison is performed by PM, STTA, and the CSM method proposed. The experimental results are as follows Table 7.  [24] 10.82% Comparison with STTTA [25] 10.55% It can be seen in Table 7 that the detection result of #10 is the best. In evaluation mode 1, the accuracy of the gait detection result is 100%, and the detection result of #2 is the worst. Figures 12  and 13 show the results of all gait tests.   As a machine learning method, it was important to train data with quality and quantity. We chose multiple model trainings for different sizes of sample files. Although each trained model parameter was inconsistent, we achieved good accuracy on the testing set as shown in Figures 12,13 and 14,which indicates that the proposed model had good generalization performance.

Advantages of the Research
When compared with the reference method, the proposed method could identify the gait patterns in real time, and obtain lower detection error rates than the methods [27,28] in the literature. If the CSM is trained well, it is not necessary to determine the threshold separately. The curve model contains a change process of plantar GCFs for a period of time, which has higher accuracy and robustness. It can be seen from Figures 12 to Figure 14 that in the real-time gait detection, the CSM method can obtain better real-time detection results without the new training model. The more training data, the higher the accuracy of the model detection, and the more versatile it is. As a machine learning method, it was important to train data with quality and quantity. We chose multiple model trainings for different sizes of sample files. Although each trained model parameter was inconsistent, we achieved good accuracy on the testing set as shown in Figures 12,13 and 14,which indicates that the proposed model had good generalization performance.

Advantages of the Research
When compared with the reference method, the proposed method could identify the gait patterns in real time, and obtain lower detection error rates than the methods [27,28] in the literature. If the CSM is trained well, it is not necessary to determine the threshold separately. The curve model contains a change process of plantar GCFs for a period of time, which has higher accuracy and robustness.

Advantages of the Research
When compared with the reference method, the proposed method could identify the gait patterns in real time, and obtain lower detection error rates than the methods [27,28] in the literature. If the CSM is trained well, it is not necessary to determine the threshold separately. The curve model contains a change process of plantar GCFs for a period of time, which has higher accuracy and robustness.
For a healthy human, gait pattern detection could be used to evaluate walking conditions. For people with foot diseases, traditionally, gait pattern detection could be used as quantitative data along with other temporal parameters (i.e., stride width, walking speed, cadence, and walking symmetry) to diagnose and prescribe patients' pathological gaits and evaluate walking conditions after rehabilitation [23]. Meanwhile, gait pattern detection results would be used in several walking-aid devices, such as exoskeleton robots and smart wearable intelligent devices, or powered prostheses to help people with walking disabilities.
Gait pattern detection plays an extremely important role to recognize the user's intentions in the applications of exoskeleton robots and powered prostheses. Because the foot contacting the ground is directly related to classifying the gait patterns, force sensor platforms are commonly utilized with exoskeleton robots and powered prostheses.

Limitation of the Research
In our model, the template curve needs to be trained, and the training time of the model is long. Once the sensor changes, the model needs to be retrained, and it is difficult to adapt quickly. In our research, only healthy subjects were adopted on flat ground, not taking the pathological subjects into account. The experiments were done on a treadmill because the method is not suitable for irregular terrain and stairs walking.

Conclusions
This paper presents a curve similarity model as a classifier for real-time gait pattern detection. The curve is composed of a series of GCF data points, and the CSM is built offline to obtain a template curve. Then, the testing curve is compared with the template curve to figure out the similarity distance. The result of the computed similarity distance would lead to the division of off-ground and on-ground statuses by comparing the GCF with a given threshold. Finally, the gait patterns could be differentiated according to the detection rules. Under the same evaluation protocol, the proposed CSM acquired the lowest average detection error rates of 7.75%, when compared with PM (i.e., 10.82%) and STTTA (i.e., 10.55%). The experimental results demonstrated that the proposed method performed better in the application of gait pattern detection than the methods in the literature. Moreover, the proposed method could be used for real-time gait pattern detection and to detect the gait patterns adaptively.