## 2 Human Subjects and Methods
### Analysis
#### 2.3.2 Similarity through Dynamic Time Warping Algorithm  
Figure 3, reproduced with permission from [14], copyright from Professor [PERSON] 2023, shows a comparison between DTW [15] and Euclidean distance. Dynamic time warping is a method of calculating a more accurate distance than Euclidean distance. It has an advantage over Euclidean distance if the data points are shifted between each other, and we want to look instead at its shape. Thus, two time series do not have to be equal in length. The Euclidean distance takes pairs of data points and compares them. The DTW calculates the smallest distance between all points, enabling a one-to-many match. Since the Euclidean distance matches the timestamp regardless of the feature values, we should note DTW, a method for matching distinctive time-series patterns. Figure 2: A three-step flow chart for the rehabilitation of patients after the surgery: first, data acquisition to measure data with the force plate, then data analysis to classify whether the gait pattern of the patient is close to the standard group or not and to recognize in which step the abnormality has occurred, and finally personalized training to improve the gait pattern. More formally, the optimization problem writes:  
\[DTW_{q}(x,x^{{}^{\prime}})=\min_{\pi\in A(x,x^{{}^{\prime}})}(\Sigma_{(i,j)\in \pi}d(x_{i},x^{{}^{\prime}}_{j})^{q})^{\frac{1}{q}}. \tag{1}\]  
Here, an alignment path \(\pi\) of length \(K\) index pairs (\((i_{0},j_{0}),\cdots,(i_{K-1},j_{K-1})\)) and as \(A(x,x^{{}^{\prime}})\) is the set of all admissible paths, a path should satisfy the following conditions in order to be considered admissible:  
* Time series are matched at the beginning: \[ \begin{array}{c}\pi_{0}=(0,0)\\ \pi_{K-1}=(n-1,m-1)\end{array} \] (2)
* The sequence is monotonically increasing in both \(i\) and \(j\), and all time-series indexes should appear at least once, which can be written as: \[ \begin{array}{c}i_{K-1}\leq i_{K}\leq i_{K-1}+1\\ j_{K-1}\leq j_{K}\leq j_{K-1}+1\end{array} \] (3)  
Another method, the warping path to minimize the cumulative distance between two time-series paths is to use a binary matrix whose non-zero entries correspond to matching between time-series elements. That means that the simple method is to compare the two paths. \[(A_{\pi})_{i,j}=\left\{ \begin{array}{ll}1&if(i,j)\in\pi\\ 0&\text{otherwise}\end{array} \right. \tag{4}\]  
Equation (4) is illustrated in Figure 4, reproduced with permission from [14], copyright from Professor [PERSON] 2023, where the dots represent non-zero entries in the binary matrix, and the plot on the right in Figure 4 is generated using the matched equivalent sequence. Using matrix notation, DTW can be written as the minimization of a dot product between matrices:  
\[DTW_{q}(x,x^{{}^{\prime}})=\min_{\pi\in A(x,x^{{}^{\prime}})}<A_{\pi},D_{q}(x, x^{{}^{\prime}})>^{\frac{1}{q}} \tag{5}\]  
where \(D_{q}(x,x^{{}^{\prime}})\) stores distances \(d(x_{i},x^{{}^{\prime}}_{j})\) at the power \(q\). Figure 3: A comparison between dynamic time warping (DTW) and Euclidean distance, reproduced with permission from [14], copyright from Professor [PERSON] 2023. Note that the two time series have a similar overall shape but are not aligned on the time axis. Euclidean distance, which assumes the \(i\)th point in one sequence is aligned with the \(i\)th point in the other, may produce a pessimistic dissimilarity measure. The non-linear dynamic time warped alignment allows a more intuitive distance measure to be calculated. The gait data used in this experiment are time-series data obtained during the stance phase. The DTW algorithm was applied to these data to compare patients' and healthy people's data to confirm whether there was a difference between the two data. For the patient's data, the distance values obtained by applying the DTW per patient data based on the average value of the entire data set of healthy people were obtained and averaged.