Piecewise Linear Labeling Method for Speed-Adaptability Enhancement in Human Gait Phase Estimation

Human gait phase estimation has been studied in the field of robotics due to its importance in controlling wearable devices (e.g., robotic prostheses or exoskeletons) in a synchronized manner with the user. Researchers have attempted to estimate the user’s gait phase using a learning-based method, as data-driven approaches have recently emerged in the field. In this study, we propose a new labeling method (i.e., a piecewise linear label) to have the estimator learn the ground truth based on variable toe-off onset at different walking speeds. Using whole-body marker data, we computed the angular positions and velocities of thigh and torso segments and utilized them as input data for model training. Three models (i.e., general, slow, and normal-fast) were obtained based on long short-term memory (LSTM). These models are compared in order to identify the effect of the piecewise linear label at various walking speeds. As a result, when the proposed labeling method was used while training the general model, the estimation accuracy was significantly improved. This fact was also found when estimating the user’s gait phase during the mid-stance phase. Furthermore, the proposed method maintained good performance in detecting the heel-strike and toe-off. According to the findings of this study, the newly proposed labeling method could improve speed-adaptability in gait phase estimation, resulting in outstanding accuracy for both gait phase, heel-strike, and toe-off estimation.

These wearable devices should be controlled in real-time and kept in sync with the user's walking. Failure to achieve such synchronization can result in instability and an inability to provide adequate assistance to the user while walking [4], [7]. Thus, accurate gait phase estimation is required for wearable devices to provide synchronized control with the user [4], [8]. Recent technological advances in machine learning enable researchers to improve the accuracy and robustness of gait phase estimation [5], [6]. The machine learning techniques were able to present human gait behavior more precisely because they used diverse kinematics and kinetics data from multiple sensors for their model training. This yields a continuous gait phase estimation, which is preferable for the seamless control of lower-limb wearable devices [10], [11], [12], [13] over a discrete gait phase estimation [14], [15], [16]. Seo et al., for example, estimated the user's gait phase for their ankle exoskeleton in a continuous manner using shank-mounted inertial measurement units (IMUs) and additional foot pressure sensors for their model training [3]. Kang et al. presented a learning-based gait phase estimator for their hip exoskeleton [4]. Data from multiple sensors, including hip encoder angles and Euler angles from the thigh IMUs, was used to train their neural network model. Both studies achieved robust and accurate estimations at dynamic walking speeds [3], [4]. Some other researchers have also focused on estimating the amputee user's gait phase for the prosthetic leg control [5], [6], [7]. For instance, Vu et al. proposed an algorithm to achieve densely discretized gait phase detection while improving accuracy. They utilized lower-shank data for training their model, which predicted a full gait cycle within a 1% interval [5]. Lee et al. made a more precise estimation using long short-term memory (LSTM) based on thigh-and torso-mounted IMUs in a continuous manner at various walking speeds [6]. An online learning scheme based on individuals' gait kinematics (i.e., thigh kinematics) was also proposed to improve the gait phase estimator by Zhang et al. Starting with a pre-trained general model, their model automatically refined the features based on individuals' gait kinematics [7].
Regardless of the input dataset (e.g., hip encoder, shank IMU, thigh IMU, etc.), a linearly interpolated function (i.e., [0,1]) based on heel-strike information has been traditionally used as the ground truth for the supervised learning process [3], [4], [5], [6], [7]. This is because human walking is a repetitive motion that occurs on a regular basis over a gait cycle, which is commonly defined as beginning with a This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ Fig. 1. An example of linearly interpolated ground truth used in [6]. Angular positions (blue) and velocities (red) of thigh and torso segments were used as input data, and the linear function (black dashed line) based on heel-strike was utilized as the ground truth throughout the gait cycle.
heel-strike and ending with an ipsilateral heel-strike [17], [18]. As a result, each heel-strike was used to initiate the gait cycle, and the gait phase between heel-strikes was mapped from 0% to 100% of the gait cycle. The linear function was obtained by linearly interpolating the gait phase between heel-strikes and was used as the ground truth for model training (see Fig. 1). All prior studies, including [3], [4], [5], [6], and [7], also used this traditional method of linear labeling during their training process. However, this linear labeling function cannot adapt to variable toe-off timings at different speeds because it only considers heel-strike timings when establishing the ground truth. It is very well known that sub-phases (e.g., heel-off and toe-off) between heel-strikes occur at different timings depending on walking speed [19], [20]. For example, people tend to have a later toe-off (i.e., a longer stance phase) to maintain their balance while walking slowly [19], [20], [21]. It is unclear, however, whether the variable sub-phase timings affect gait phase estimation.
To our knowledge, variable toe-off timings are not typically considered when generating the ground truth for gait phase estimation. Furthermore, the effect of variable toe-off timing on gait phase estimation accuracy has yet to be studied. Thus, the main objective of this study is to propose a new labeling method, called a piecewise linear (PLN) label, as the ground truth in model training to reflect variable toe-off timing at different speeds. The contributions of this study are: (i) to reflect variable toe-off timing while estimating the user's gait phase estimation, (ii) to compare the new labeling method (i.e., PLN) to the conventional linear (LN) labeling method, and (iii) to find a feasible model with the proposed method. The rest of this paper is organized as follows: Section II briefly explains the LN labeling method and presents a novel PLN labeling method for improving speed-adaptability while estimating the user's gait phase during walking. In addition, our neural network model for gait phase estimation is described briefly in this section. Section III validates the proposed idea by presenting training and prediction results at various walking speeds. We also present a heel-strike detection error and a toe-off detection error for further investigation. All of the findings are discussed and summarized in Sections IV and V, respectively.

II. METHODS
As previously stated, the most common labeling method for gait phase estimation is a linear function [3], [4], [5], [6], [7]. In [6], we also attempted to estimate the user's gait phase using the linear (LN) labeling function based on heel-strikes regardless of walking speed (see Fig. 1). Surprisingly, it was discovered that errors increase during the mid-stance phase, with larger deviations at slow walking speed [6]. In this study, we speculate on a possible solution. The larger estimation error observed at slow walking speed suggests that additional information taking different speeds into account in model training may be required to improve speed adaptability. A different labeling method could aid in improving the accuracy of gait phase estimation at various walking speeds. In this section, we first explain an LN labeling method as a baseline and then explain a piecewise linear (PLN) label that can adapt to different toe-off onset timings at different walking speeds during model training.

A. Dataset
To ensure an adequate size of input data for our model training, we utilized an open-source dataset, which can be found in [22]. This dataset comprised data from 50 healthy subjects (26 male and 24 female) walking on a walkway in five different speed conditions: C 1 (0.0-0.4 m/s), C 2 (0.4-0.8 m/s), C 3 (0.8-1.2 m/s), C 4 (self-selected; 1.0-1.4 m/s), and C 5 (selfselected fast; 1.4-1.8 m/s). Individuals' 3D motion data was provided via 52 whole-body reflective markers, allowing us to calculate the angular positions and velocities of thigh and torso segments as needed for our model training. Furthermore, ground reaction forces were measured using two force plates, which were used to estimate heel-strike and toe-off. The data was sampled at 100 Hz for markers and at 1.5 kHz for force plates. Forty-two individuals' datasets were randomly selected to be used for model training and validation, while the data from the remaining eight subjects was used for prediction.

B. Linear Labeling Method
Because the human gait cycle is typically defined from heel-strike to subsequent ipsilateral heel-strike, the heel-strike has traditionally been used as a cue of gait initiation [17], [18]. To represent human walking in percentage, the human gait phase (φ ∈ [0, 100]) was linearly interpolated between heel-strikes. However, discontinuity cannot be avoided with the linear function at the heel-strike due to gait initiation (yellow circle in Fig. 2). This discontinuity may cause an unfavorable high loss (i.e., mean squared error), resulting in a bias at heel-strike during model training. As shown in (1), we converted the gait phase percentage (i.e., linear label) into a polar coordinate (θ ∈ [0, 2π]). By using two variables in (2) (i.e., P x and P y ) as the ground truth, we could avoid the unwanted error caused by the discontinuity at heel-strikes.
These sine and cosine variables can be transformed into a linear function with a range of [0,1], which represents the gait cycle, as shown in (3) and (4). This linear gait phase estimator can be utilized for controlling the lower-limb wearable devices [3], [4], [5], [6], [7]. We call this τ as a linear (LN) label in this study.

C. Piecewise Linear Labeling Method
As shown in Section II-B, the LN labeling method has been utilized in the gait phase estimation [3], [4], [5], [6], [7]. However, this method could not consider other gait events (e.g., heel-off and toe-off) between heel-strikes, even though these events may play an important role when estimating the gait phase at different walking speeds. As walking speed increases, for example, toe-off occurs earlier, resulting in a shorter stance phase and a longer push-off [19], [20]. On the other hand, when humans walk slowly, they have a longer stance phase to help them maintain their balance [21], [23]. We propose a PLN label as the ground truth for our model training to account for this variable toe-off timing at different speeds. The proposed PLN label, unlike the LN label, is made up of two linear functions divided on toe-off (φ T O ) (see Fig. 3). Sine and cosine functions are still used to obtain those two linear functions for each phase (i.e., stance and swing), but with a different period for each phase. As shown in (5), of the gait cycle. The PLN functionτ (black) can be represented using two sinusoidal functions,P x (red) andP y (blue), to avoid an undesired discontinuity at heel-strike.
Based on θ st and θ sw , the transformation between polar coordinates and cartesian coordinates is utilized to obtain our new labelsP x andP y in (6). They are represented as continuous sinusoidal functions, which are bounded in [-1,1].
The resulting gait phase estimator should be formed as a monotonic and bounded (i.e., [0,1]) function to be used for controlling the assistive devices [8], [9]. Thus, additional transformations are performed based onP x andP y as explained in (7) and (8). We call the resultingτ as a piecewise linear (PLN) label in this study.

D. Neural Network
Long short-term memory (LSTM) is one method of recurrent neural network (RNN) architecture [24]. The LSTM network is well-known as a remedy for the vanishing gradient problem of the traditional RNN by combining a cell, an input gate, an output gate, and a forget gate in a single LSTM unit [25]. Since LSTM can process an entire sequence of datasets, it has been widely used for estimating chronological data, such as time series prediction [4], [6], [26]. Additionally, bidirectional LSTM (Bi-LSTM) is also widely known to train for the forward and backward data sequences throughout the training process, according to [27]. Fig. 4 depicts our proposed network architecture, which consists of five layers of LSTM and Bi-LSTM. Note that we utilized the same network for LN and PLN labeling methods but used different ground truth labeling as described in Sections II-B and II-C. A sequence known as the sliding window is needed to train the LSTM. This window binds a sequence of a certain size as a unit, and the size of the window is important for successful estimation. However, due to the short length of the obtained data [22], we were unable to avoid a specific upper bound on the window size in this study. As a result, we used a 500 ms window containing 100 data points on our 200 Hz operating system. The first four layers are composed of LSTM and Bi-LSTM alternately, as shown in Fig. 4; the number of units (i.e., dimensions) in each layer is 128, 64, 64, and 32, respectively. The final layer (i.e., fully connected layer) has two dimensions for estimating gait phase with sine and cosine functions; LN and PLN have a two-dimensional output shown in (2) and (6), respectively. The Adam optimizer was used to train the network model, and mean squared error was used as a loss function with a batch size of 64. To avoid over-fitting, the model was trained for a maximum of 100 epochs and was terminated early if the validation loss did not decrease in 10 epochs. The model's trainable parameters were 241,282 (angular positions and velocities of the thigh and the torso). All experiments were carried out on a computer with an Intel i7-10700F (2.9 GHz) CPU, 32 GB memory, and multiple NVIDIA RTX 3090 GPUs. We trained three different models under various speed conditions. The first model, called the general walking model (GWM), was trained using the broadest  range of speed conditions (i.e., C 2 -C 5 ). The slow walking model (SWM) only used slow walking data (i.e., C 2 ) during its training, whereas C 2 was withheld for the normal-fast walking model (NFWM). These models demonstrated the effect of the labeling method under various walking speed conditions. Note that C 1 was excluded from the training process of all three models because C 1 contained extremely slow walking speeds (≤ 0.2 m/s), which were outside the scope of this study.

E. Statistical Analysis
Statistical analysis was performed using RStudio statistical software (RStudio ver. 1.3.1093) to determine the significant trend between the two labeling methods: LN and PLN. To evaluate the training performance, we compared the mean squared error (MSE) between the ground truth and the estimation when two different labels were used during the training (see Fig. 5.A). For the training result, a Paired Samples t-test was independently performed for three trained models: GWM, SWM, and NFWM. To evaluate the prediction performance of each label, we presented three different prediction results: MSE, heel-strike detection error (HDE), and toe-off detection error (TDE), as illustrated in Fig. 5. For each result, a two-way repeated measures ANOVA was respectively performed to identify the effects of the labeling methods and the trained models at four different walking speeds: C 2 , C 3 , C 4 , and C 5 . Note that the MSE can be calculated as follows: where n refers to the length of data, while G i and P i refer to the ground truth and the predicted value at i th data point.
The detection error at heel-strike (i.e., HDE) refers to the difference in time between the actual and the predicted heelstrike (see Fig. 5.B). The TDE refers to the temporal difference between the actual and predicted toe-off, as shown in Fig. 5.C. In multiple comparisons, Bonferroni correction was used as a post-hoc test. In all analyses, a significance level of 0.05 was used, and the statistical significance was denoted as follows: * = p≤0.05, ** = p≤0.01, *** = p≤0.001.

A. Training Results
We validated all three trained models (i.e., GWM, SWM, and NFWM) using two different labeling methods (see Fig. 6). The proposed networks were used to train all of the results in the same environment, and the MSE was used to validate them. Fig. 6 shows that the LN label had a higher MSE than the PLN label in all three trained models. To be specific, the error was reduced by 39.5% when the PLN labeling method was used in GWM (p<0.001). Both SWM and NFWM showed significant error reductions with the PLN label; 12.9% reduction in SWM and 40.7% reduction in NFWM (p<0.001). This implies that the proposed PLN labeling method improves overall training accuracy.

B. Prediction Results
To evaluate the proposed labeling method, the gait phase prediction was performed based on the eight individual's data at four different walking speeds: C 2 , C 3 , C 4 , and C 5 . As given in Fig. 5, we used mean squared error (MSE), heel-strike detection error (HDE), and toe-off detection error (TDE) for the prediction evaluation.
The results of three trained models' gait phase prediction (i.e., MSE) are shown in Fig. 7. When the PLN label was used in GWM, the estimation error was significantly reduced across C 3 -C 5 (C 3 : p = 0.049, C 4 : p = 0.036, C 5 : p = 0.038). To be more specific, error reductions of 37.7%, 43.4%, and 35.2% were found in each speed condition, respectively. At the slowest speed (C 2 ), there was a 27.1% error reduction, but it was not statistically significant. In the case of SWM, only at C 5 did the slow model show a significant difference between the labeling methods, as shown in Fig. 7.D (p = 0.04). In addition, in comparison to the C 2 condition, the estimation error increased at the other speed conditions. This was because the SWM was only trained using the slow walking dataset (C 2 ), which resulted in poor estimation results at faster speeds. As depicted in Fig. 7.C, only at C 4 did the labeling method have a significant effect on gait phase estimation in NFWM (p = 0.031). Regardless of the labeling method, this model appears to have apparently large errors at C 2 when compared to faster speed conditions. This was mainly due to the fact that only data from C 3 to C 5 were used to train the NFWM. In general, GWM outperforms NFWM at slow walking conditions (p = 0.01) and it outperforms SWM under other walking conditions (C 3 : p = 0.006, C 4 : p = 0.034, C 5 : p = 0.001). Fig. 8 shows the error between the ground truth and the prediction from 30% to 50% of the gait cycle (i.e., mid-stance phase) in GWM. In this figure, being closer to the black dashed lines (i.e., no error) represents a higher level of prediction accuracy. It was found that the estimation errors were clearly reduced when the PLN label was utilized across four different walking speeds. Also, the standard deviations of each prediction error became smaller with the PLN label during the midstance phase. The MSE results during this phase are presented in Table. I. According to Table. I, compared to the LN labeling method, the proposed labeling method achieved a greater error reduction during the mid-stance phase: C 2 : 51.5%, C 3 : 76.7%, C 4 : 62.2%, and C 5 : 47.8% reduction. Note that C 3 (p = 0.011) and C 4 (p = 0.043) were statistically significant. Fig. 9 depicts the heel-strike detection results for three trained models using two different labeling methods. None of the labeling methods showed a significant difference   across four walking speeds in all model conditions. However, as with the MSE results in Fig. 7, the HDE increases significantly under certain speed conditions in the case of SWM (at C 3 -C 5 ) and NFWM (at C 2 ). Regardless of the labeling method, GWM achieved a better heel-strike detection than NFWM in slow walking (p = 0.004) and a better detection than SWM in normal and fast walking (C 3 : p = 0.038, C 4 : p = 0.035, C 5 : p = 0.047). Table. II shows the TDE results of GWM. When the PLN method was used, the means and standard deviations of the TDE were reduced across four-speed conditions, but not significantly.

IV. DISCUSSION
The primary purpose of this study is to validate that the new labeling method (i.e., PLN label) having toe-off information would be beneficial in gait phase estimation and to find a feasible model to use with this labeling method at various walking speeds. We compared the LN and the PLN labeling methods using three different models: GWM, SWM, and NFWM. According to Fig. 6, the PLN labeling method consistently showed better estimation across all three walking models in the training result. However, there were some inconsistencies in the prediction results between the three models, particularly SWM and NFWM, as shown in Figs. 7 and 9. Only GWM, for example, demonstrated a significant error reduction with the PLN label across C 3 -C 5 . On the other hand, NFWM showed a meaningful effect with the PLN label only at C 4 , and SWM showed a greater estimation error with the PLN label at C 5 . This may appear to imply that the PLN label had a negligible effect or an even worse estimation due to the results of the SWM and NFWM. However, before concluding the effectiveness of the labeling method, it is also necessary to assess the feasibility of each model to be used for future implementation (e.g., prosthesis control). According to Figs. 7 and 9, both estimation and heel-strike detection errors drastically increase at C 2 in NFWM and at C 3 -C 5 in SWM regardless of the labeling methods. This is primarily due to a lack of data from specific speed conditions during model training for both SWM and NFWM. To be more specific, SWM lacks the data at normal to fast walking speeds, whereas NFWM lacks the data at slow walking speeds. In other words, GWM outperforms NFWM at slow walking speed (i.e., C 2 ), and it outperforms SWM at normal and fast walking speeds (i.e., C 3 -C 5 ). Concerning the practical usage of the prosthesis, accurate gait phase estimation should be guaranteed at various walking speeds. In general, GWM would be a proper choice for stable control of the prosthesis rather than SWM or NFWM across all speed conditions, so we would like to focus more on the results of GWM.
As shown in Figs. 7.B-D, the gait phase prediction errors were surprisingly reduced across C 3 -C 5 with the PLN label in GWM. This implies that having toe-off timing information in model training resulted in accuracy improvements when estimating the user's gait phase during walking. According to [6], the greatest prediction error and standard deviation were found during the mid-stance phase, specifically at slow speeds due to highly deviating sensor input when humans tried to balance themselves in this phase. Thus, we focused on the estimation results during the mid-stance (i.e., 30-50% of the gait cycle), presented in Fig. 8 and Table I. According to the results, the proposed labeling method increased the prediction accuracy during the mid-stance phase, specifically at C 3 and C 4 . Also, the prediction errors were less divergent from each other, implying that the prediction performance was consistently maintained regardless of the given subjects. These results imply that toe-off consideration in gait phase estimation could enhance gait phase prediction during this phase of the gait cycle. There was no significant difference between labeling methods in heel-strike and toe-off detection results ( Fig. 9 and Table. II). Regardless of the labeling methods, the HDE values were less than 30 ms at most in the case of GWM (see Fig. 9). Seeing that the maximum temporal error is less than the short-latency response time of the human lower-limb reflex pathway (i.e., 40-50 ms) [28], those errors are more than acceptable to be used for heel-strike detection. This may be because some important information regarding such gait events was already included in human thigh/torso kinematics data so that we could detect these events regardless of the labeling method. Still, the main objective of this study was to see if having toe-off information while training the model could affect the human gait phase estimation throughout the gait cycle, not the heel-strike or toe-off detection itself. From Figs. 7 and 8, we could see the effect of the labeling method on gait phase estimation throughout the gait cycle.
As stated in Section II-D, we utilized a relatively small size of sliding window (i.e., 500 ms) for the model training compared to our previous study (i.e., 1.5 secs) [6]. This was because the training dataset was captured on a walkway, containing only a single gait cycle at most [22]. This may raise a concern about the estimation accuracy because the level of estimation accuracy could be affected by the sliding window size. It is challenging to directly compare the obtained results to other studies because some of the conditions (e.g., input data and network model) cannot be controlled. However, we could indirectly evaluate our estimation results by comparing them to other studies. It was reported in [6] that the average MSE was 4.540 E-03 when the angular positions and velocities of the torso and thigh were utilized. Compared to this result, we achieved outperforming accuracy with both the LN and PLN labeling methods in GWM ( Fig. 7; LN: 8.507 E-04 vs. PLN: 4.819 E-04). This could alleviate the concern about the sliding window size.
Monotonicity has long been recognized as an important factor in estimating the user's gait phase for lower-limb prostheses. This is because a monotonic function enables time-independent control based on the user's gait phase by parameterizing a user's walking over time [8], [29], [30], [31]. Furthermore, recent studies such as [9] and [32] have addressed the strict monotonicity or linearity of the estimated gait phase. Both strict monotonicity and linearity imply a bijection between the time elapsed during a gait cycle and the estimated gait phase. Failure to adhere to the strict monotonicity resulted in an unexpected pause while walking [32] or an unwilling early knee extension at the end of the gait cycle [33] when controlling the prosthesis. Linearity is an even more strict condition than strict monotonicity. According to [9], losing linearity (i.e., non-linearity) affected prosthesis control, resulting in an uncomfortably high push-off when using the prosthesis. The proposed PLN label, which is piecewise linear, appears to satisfy strict monotonicity but not linearity. However, the underlying assumption in [9] was that all of the control parameters (i.e., impedance parameters) and desired trajectories were optimized based on a linear function, which necessitated linearity for the best performance. Thus, we may not be concerned about the linearity of the PLN labeling method. We could also adjust the gradient of the estimated gait phase based on the estimated toe-off timing to improve linearity, if necessary.
One limitation of this study is that our network model was limited by an offline estimation condition. Thus, future work includes a real-time gait phase estimator using the proposed labeling method. To achieve faster estimation, we plan to develop LSTM combined with a convolutional neural network (CNN). This estimator will be applied to control a custom-designed robotic prosthesis. We intend to compare the proposed learning-based gait phase estimation with the phase variable, which is a popular method for estimating the user's gait phase for prosthesis control [8], [9], [30]. It is critical to provide user-specific control in order to maximize the biomechanical effect of using the prosthesis for each individual. Therefore, future work also includes user-adaptive gait phase estimation for different individuals. We plan to develop a user-adaptive gait phase estimator using transfer learning for user-adaptability enhancement [34].

V. CONCLUSION
A linearly interpolated function has been commonly used as the ground truth in learning-based gait phase estimation. This function is able to estimate the user's gait phase at various speeds, but it cannot account for variable toe-off timings at different walking speeds. In this study, we proposed a piecewise linear (i.e., PLN) labeling method in the model training to enhance speed-adaptability for gait phase estimation. This lets the estimator learn the new ground truth based on variable toe-off timing at different walking speeds. The proposed idea was compared to the conventional linear (i.e., LN) labeling method in four different speed conditions: C 2 , C 3 , C 4 , and C 5 . Consequently, at various walking speeds, the proposed label presented outperforming prediction results when estimating the user's gait phase during walking. The proposed method specifically improved the estimate during the mid-stance phase. We further evaluated the heel-strike and toe-off detection performance while walking. The proposed method maintained outstanding detection performance at the heel-strike and toe-off. This study, therefore, suggests the proposed piecewise linear label could enhance the speedadaptability, thereby improving the accuracy of gait phase estimation at various walking speeds.

APPENDIX A
The datasets and the main code utilized for this study can be found in the GitHub repository for future development: github.com/ulim88/TNSRE_PLN.