On Predicting Transitions to Compliant Surfaces in Human Gait via Neural and Kinematic Signals

Walking surfaces of varying compliance are encountered frequently in everyday life C, and transitions between them are usually not a challenging task for most people. The human brain, based on feedback from the environment, as well as previous experience, controls the lower limb dynamics to transition to new surfaces ensuring stability and safety. However, this is not always possible for people with lower limb impairments, especially those using wearable (orthotic) or prosthetic devices. Current control methodologies for lower limb wearables and powered ankle prostheses have successfully replicated conditions for walking on rigid surfaces. However, agility and walking stability on non-flat and compliant surfaces remain a significant challenge for individuals with gait disabilities. C There is therefore the need to incorporate the human wearer in the loop and proactively adjust their control to transition to surfaces of different compliance. This work proposes a subject-specific pattern recognition (PR) and classification strategy using kinematic data and surface electromyographic (EMG) signals to recognize user intent to transition from a rigid to a compliant surface. Using a k-Nearest Neighbors (k-NN) methodology in combination with an Artificial Neural Network (ANN), our strategy can accurately predict upcoming surface stiffness transitions C in real time. C This would allow for a fast parameter control of the prosthesis C or wearable device and for adaptation to the new terrain. Classification results after employing the proposed strategy reach a prediction accuracy of up to 87.5%, proving that C predicting transitions to compliant surfaces in real time is feasible and efficient. The proposed framework can lead to increased robustness and safety of lower-limb prosthetic C or wearable devices that will eventually improve the quality of life of individuals living with C a lower limb impairment.

effectively respond in space and time to meet different needs. Individual gait patterns are strongly influenced by age. To be exact, the prevalence of gait disorders increases with age, from around 10% between the ages of 60 and 69 years to more than 60% in those over 80 years [1]. Altered gait patterns can also be attributed to conditions related to lower-limb amputation. In the US alone, it is estimated that over two million individuals live with an amputation, with lower limb loss ranking as the most common type of amputation, accounting for 65% of the total cases [2], [3]. Gait impairments and loss of either one or both lower limbs entail a series of long-term physical and psychological challenges for individuals, with major issues pertaining to balance, falling, and the fear of falling, among others [4], [5].
Being the most critical joint for gait stability and propulsion, research focus around wearable devices and prosthetic limbs has been concentrated on the ankle joint [6], [7]. Walking stability and agility in non-flat and compliant surfaces is a significant challenge, especially for individuals with lower limb amputation, primarily due to the lack of distal muscles and sensory feedback from the lower limb, as well as the lack of intuitive control of the mechanical impedance of the prosthesis. Agility requires a smooth transition between different gait speeds and directions, while stability requires a reliable physical interaction of the prosthesis over terrains with different profiles and compliances. Previous studies on control methodologies for powered ankle prostheses and wearable technologies have successfully replicated conditions for walking and running [8], [9], [10], however environmental information regarding the type of walking terrain and ground stiffness has been generally overlooked [11]. Considering that adaptation to terrain constitutes a particularly important aspect of walking, adapting to changes in compliance of the walking surface and replicating natural walking in more complicated conditions have yet to be addressed in depth. To advance the current state-of-the-art lower limb prosthetic and wearable devices, it is thus necessary to adapt performance at a level of intelligence seen in human walking.
Human control of locomotion requires information about the walking environment, which is usually obtained via proprioceptive mechanisms preceding movement execution. Humans specifically seem to anticipate the future state of the walking terrain and integrate this information when preparing motor responses by taking conservative measures such as increasing minimum toe clearance to improve stability on complex surfaces and thereby reduce the likelihood of falls [12]. Overview of the proposed research framework. The last segment of the flowchart (high-level controller) is marked with dashed lines because it is not included in this paper, however, is included in the flowchart to show how the proposed methods could be used for the control of a wearable or prosthetic device.
Able-bodied humans thus have the ability to predict and adjust their next step to the walking terrain prior to transitioning from a rigid to a compliant surface.
Studying the mechanisms involved in healthy human locomotion during such transitions can reveal important information to enable prosthesis/orthosis wearers to ambulate smoothly and adapt to changing environments. This knowledge is reflected in early muscle activation indicated by anticipatory muscle responses [13]. Previous research actually shows that subjects become aware of an upcoming transition and fixate on a transition target as early as four steps ahead [14], [15].
Early muscle activation has been studied extensively during walking tasks involving obstacle avoidance and tasks requiring a change in the mode of ambulation [16], [17], as well as during running activities [18], [19]. These works on anticipation and user intent prediction appear to primarily focus on locomotion-mode identification using electromyography (EMG) signals, mechanical data or fusion of the latter two. Transitioning from level ground walking to stair ascenddescend is a common example of a locomotion mode transition that could be compared to transitioning from a rigid to a compliant surface. Results relevant to such locomotion mode changes reveal the existence of anticipatory activity, both in terms of body mechanics and muscle activation as early as two gait cycles ahead [20]. But although rigid-compliant surface transitions might be similar to the stair ascenddescend case, the prediction of the former presents more challenges. The greatest challenge is the close resemblance of the muscle activation and body mechanics between rigid and compliant surface transitions, while natural variability in a subject's walking pattern can increase the difficulty of the task.
Latest findings involving early lower-limb muscle activation are reported during transitions from rigid to compliant surfaces [21], [22], [23]. Results indicate the existence of anticipatory muscle responses for both legs and that significant activity changes are present just before and immediately after an individual encounters a compliant surface. These results constitute qualitative proof of the existence of anticipatory muscle tensing in both legs prior to transitioning from a rigid to a non-rigid surface. The observation of characteristic EMG signatures paves the way toward the identification of user intent when transitioning from a rigid to a compliant surface, while the unexplored quantitative interpretation of these results could reveal distinct signal patterns indicating varying muscle responses for different surface stiffness levels. These results are significant as they can be used for tuning the control parameters of powered prostheses and relevant wearable devices to adapt to new surfaces, Fig. 2. Layout of the experimental protocol. The sequence of the changes in surface stiffness for the left leg was: 20 sets of 1 rigid surface cycle (excluded from any data processing), 51 sets of 9 rigid surface cycles followed by 1 compliant surface cycle (resulting in 510 gait cycles), and finally 20 sets of 1 rigid surface cycle. The right leg was always on high stiffness (i.e. rigid) ground. and therefore contribute to increased gait performance and stability.
Identifying user intent in a timely manner is thus a priority when attempting neural control. The goal is to eventually achieve natural and robust walking over non-rigid surfaces for individuals living with gait impairment. To this end, this work proposes a subject-specific pattern recognition (PR) and classification strategy using kinematic data and surface EMG signals to accurately predict transitions to compliant surfaces in real time. Since the proposed approach can predict those transitions before they actually happen, i.e., the foot lands on the new surface, the developed framework could be embedded in an advanced, high-level controller for powered ankle-foot prostheses and lower-limb wearables, capable of recognizing user intent to transition from a rigid to a compliant surface. The classification results after employing the proposed PR strategy reach a prediction accuracy of up to 87.5%, proving the feasibility and efficiency of our control strategy. To our knowledge, this is the first attempt to identify and classify lower-limb EMG and kinematic signals aiming to predict user intent to transition from a rigid onto a compliant surface.

II. METHODS
We propose a subject-specific PR and classification strategy using kinematic data and EMG signals from several muscles of both lower limbs to predict transitions to compliant surfaces in real time. The suggested approach combines surface EMG and kinematic data with a phase-dependent PR algorithm for identifying cases of traversing rigid and compliant terrains and is tested in such scenarios using a unique robotic setup. A flowchart of the proposed framework is shown in Fig. 1.

A. Experimental Protocol
To investigate the mechanisms of human locomotion during ambulation in dynamic environments, we recruited eight Fig. 3. Representative subject on the VST platform used in the experiments. Subject instrumentation, including EMG electrodes and reflective motion capture markers, is shown along with the body-weight support (BWS) that was used for participants' safety. The EMG electrodes with the corresponding recorded muscles are shown.
subjects (age 26.6 ± 2.2 years, height 174.2 ± 8.7 cm, mass 70.8 ± 12.3 kg). The subjects were free from any orthopedic or neurological pathology. All participants were asked to walk on the Variable Stiffness Treadmill (VST). The VST is a unique split-belt treadmill with a walking surface that can interactively and dynamically change its vertical compliance [24], [25], [26]. Specifically, one side of the treadmill is able to lower its stiffness to simulate walking on a soft surface. The VST offers control over a wide range of stiffness levels that can be modified during the gait cycle and by extension allows the induction of multiple force perturbations to the leg.
For the purposes of this study, the right side of the treadmill remained rigid for the entire duration of our experiments, while expected stiffness perturbations were applied unilaterally to the left leg (Fig. 2). The stiffness on the left side of the treadmill dropped from 1000 k N /m, which simulates rigid ground, to 40 k N /m, which simulates a compliant surface. In order to test our hypothesis that anticipatory locomotion mechanisms can be identified and classified solely on the basis of the ground stiffness, we experimented using one compliant stiffness value which corresponds to a stiffness estimate for a range of outdoor soft dynamic environments encountered daily, such as wet grass or sand [27]. The change in the stiffness of one belt was based on the assumption that transitions between surfaces in everyday life activities are first experienced by one leg. For the purposes of our study, the leading leg transitioning between surfaces was the left leg. The stiffness perturbations occurred periodically every ten rigid gait cycles and all subjects were verbally informed as early as three steps before an upcoming perturbation. The timing of each ground stiffness change ensured that the left leg was always experiencing a walking surface with a stiffness of 40 k N /m on a perturbed gait cycle.
Before data collection began, the subjects were given the chance to choose a comfortable walking speed. Different treadmill speeds between 70 and 100 cm/s were tested until each subject found a suitable pace that closely resembled their normal, everyday walking patterns. For all 8 subjects, the chosen speed was 90 cm/s.
In total, each subject walked on the VST for 554 gait cycles, which corresponds to approximately 12 minutes. The purpose of the first 20 gait cycles was to introduce the subjects to walking on our treadmill and familiarize them with the setup. Data pertaining to these gait cycles were omitted from any further processing. A body harness that did not offset any of the subjects' weight was used during all experiments, solely for safety purposes (Fig. 3).
1) Kinematics: Each subject was instrumented with 23 reflective motion capture markers attached to their pelvis, thighs, shanks, feet, spine, and torso. The markers were used for tracking the motion of the subjects' legs and for extracting upper body parameters. Kinematic data for both legs were obtained at 100 H z using a VICON motion capture system that is integrated with the VST [25]. Kinematic data were utilized for timing the changes in the treadmill surface stiffness with the subject motion.
2) Electromyography: The muscle activity of both legs was obtained using twelve wireless surface EMG electrodes (Trigno, Delsys Inc.). The surface electrodes were placed on six major muscles of the lower limbs following SENIAM recommendations [28]. The monitored muscles included the tibialis anterior (TA), gastrocnemius (GA), soleus (SOL), rectus femoris (RF), vastus lateralis (VL), and biceps femoris (BF) (see Fig. 3). The selection of the muscles was based on their primary role in ankle motion and stability, in which the TA produces dorsiflexion of the foot, while the GA and SOL muscles produce plantar flexion of the foot [6]. In the absence of ankle plantar flexor power, as seen in transtibial amputees, hip extensors and flexors, as well as hip external rotators have been shown to become the major power generators [29]. The RF, BF, and VL muscles were thus selected to study how knee and hip EMG signals contribute to identifying transitions from rigid to compliant surfaces. The EMG signals were sampled at 2 kHz and were synchronized with the motion capture data.
The experimental protocol was approved by the University of Delaware Institutional Review Board (IRB ID# 1544521-7) and informed consent from the subjects was obtained at the time of the experiment.

B. Data Processing
The raw kinematic and muscular activity data were synchronized by utilizing the real-time Foot VErtical & Sagittal Authorized licensed use limited to the terms of the applicable license agreement with IEEE. Restrictions apply. Position Algorithm (F-VESPA) for heel-strike detection [30]. Heel-strike detection allowed for the data to be segmented into gait cycles following the convention that each gait cycle begins and ends at Left Heel Strike (LHS) (Fig. 4). Outlier gait cycles including sensor noise or other artifacts in the recorded data were identified after the application of a newly developed outlier detection method for periodic data [31]. On average a total of 9 ± 2 outlier gait cycles were found per subject and excluded from the total data. EMG raw data were first filtered with a 4th-order Butterworth band-pass filter with low and high frequencies at 50 H z and 500 H z, respectively. The data were then full-wave rectified. The linear envelope of the signal was computed and the data were filtered with a 4th-order Butterworth low-pass filter with a 4 H z cut-off frequency. The final processed EMG data were normalized to the maximum value of each muscle during the experiment. Temporal normalization of EMG data is necessary given that muscle activity during walking is highly dependent on the phase of the gait cycle [32]. Therefore, the data were also temporally normalized to percent gait cycle, where 0% and 100% correspond to the heel strike of the left leg at two successive gait cycles. The EMG recordings acquired during rigid surface walking were separated from the gait cycles before, during, and after each compliant surface transition. Each gait cycle was specifically labeled as either i) rigid (R) if the subject was walking on a rigid surface preparing to step on a rigid surface, ii) transition (T) if the subject was walking on a rigid surface preparing to step on a compliant surface, iii) perturbation (PT) if the subject was walking on a compliant surface, iv) recovery (RC) if the subject was walking on a rigid surface following a perturbation (Fig. 4). The PT and RC data were excluded from the data analysis and we focused on the comparison between the R and T cases, which pertain to the anticipatory component of our study.
C. Data Analysis 1) Continuous Window Segmentation: EMG signals are time-varying. Specifically, EMG recordings from the lower limbs show large variations within the same gait class. Therefore, utilizing the data of an entire gait cycle as input to a classification algorithm might result in overlaps of features among classes, and therefore, low PR accuracy. In real-time applications, this approach is inadequate for safe and robust prosthetic control. For this reason, we employed a sliding window approach (Fig. 5). Following the recommendation of works related to upper limb EMG recordings, EMG signals were segmented into windows ranging from 50 to 250ms [33]. Within these time windows, EMG signals can be modeled as stationary and subsequently provide features for a reliable PR design. We decided to conduct our analysis with a window duration of 150ms. A 50% window overlap between the segments was chosen for continuous feature extraction. Since some natural variability in the gait is expected, the number of samples in each gait cycle varies per subject. We, therefore, re-sample the EMG and kinematic data to the average number of samples observed in each subject before proceeding with the windowing segmentation. The goal is to ensure a uniform number of samples per window for all gait cycles within the same subject. Statistically significant changes (using a t-test) in EMG activation and kinematics were observed mainly during the terminal stance and swing phases. We, therefore, concentrated on the data from the Pre-LTO (55% of GC) up to the Pre-LHS (100% of GC) phases of each gait cycle (Fig. 4). This observation is aligned with our hypothesis that the prediction accuracy of the classifier will be higher toward the end of each gait cycle, as the subjects approach the compliant surface. The window segmentation was applied exclusively on the 55-100% of the gait cycle, resulting in overall six overlapping analysis windows. The following analysis steps were done separately for each of the segmented windows.
2) Feature Extraction and Selection: Feature extraction and selection are the most important steps in achieving optimal classification performance. The feature classification can be carried out in the time domain (TD), frequency domain (FD), and time-frequency domain (TFD). Due to their implementation and computational simplicity, TD features are frequently used in pattern recognition as they satisfy the requirement of fast time-response and were thus used in this framework. For the electromyographic data, we studied six muscles: the TA, VL, BF, and RF of the left leg, and the SOL, and GA of the right leg. The other muscles were excluded from the analysis, because of the lack of activation or lack of statistically significant differences between the R and T cases during the Pre-LTO and Pre-LHS phases of each GC. We extracted 12 EMG features, according to their prominent use in the literature, as a non-exhaustive compilation of myoelectric signal features employed in pattern recognition for prosthetic control (Table I). Extracted was a total of 72 EMG features per segmented window, which correspond to 12 features for each of the 6 muscles used.  For the kinematic data, we studied the flexion/extension of the hip, knee, and ankle of both legs, as well as the velocity of the latter two joints. We extracted the maximum, mean, and minimum values of these kinematic variables. Extracted was a total of 30 kinematic features per segmented window. a) Particle swarm optimization (PSO): After feature extraction, the result is a 102 (features) × 6 (windows) = 612 elements wide feature vector per GC and subject. Highdimensional feature vectors lead to information redundancy, which results in a decrease in classification accuracy and an increase in computational complexity. We thus continue by reducing the dimension of the feature input vector. We apply a feature selection method that preserves the important characteristics of the dataset but decreases the complexity of our system. We utilize the PSO algorithm to select a subset of relevant features for use in model construction, in order to make predictions faster and more accurate. PSO is an algorithm influenced by the habit of bird flocking or fish schooling used for generating an optimal number of features to be used for a certain task like classification [34].
The PSO algorithm searches in the space of an objective function by adjusting the trajectories of individual particles in a quasi-stochastic manner. Each particle, combining its own best experience in the history of the search with the global best solution of the swarm, adjusts its velocity and position (Algorithm 1). The PSO parameters were initialized according to values widely used in literature and the final values were optimized for our problem. According to existing literature, selecting a population size between 10-30 renders optimal results [35]. After cross-validation, the value M = 30 was selected as it provided both fast and accurate algorithm convergence. The acceleration constants c 1 , c 2 define the ability of the group to be influenced by the best local (particle personal) solutions found over the iterations and the ability of the group to be influenced by the best global solution found over the iterations respectively. We chose c 1 = c 2 = 2 to allow for equal exploration and exploitation dynamics. The maximum number of iterations was set to Max I t = 100. As an optimization method, PSO takes all of the existing features into account, runs an optimization scheme in order to minimize or maximize a cost function and it finds the combination of features that achieves this goal. For the current study, the objective function is formed as a combination of two aims: (i) maximizing the classification accuracy of the classifier, (ii) minimizing the number of features that the PSO selects.
3) Classification: Our original hypothesis is that transitioning between walking surfaces of variable stiffness results in alterations in the activation pattern of different muscles and gait kinematics. In order to verify that these changes are significant and detectable, we attempt to build a classification problem. Our hypothesis can then be rephrased to that a classifier can be trained to differentiate between rigid and compliant surface transitions based on a fusion of neural and kinematic features. The present study employs the k-Nearest Neighbors (k-NN) method to identify and classify walking patterns on transitions from rigid to rigid surfaces and from rigid to compliant surfaces using kinematic and EMG data from both lower limbs [36]. The data at hand is separated into two classes, which correspond to a step between (1) rigidrigid surface (R), and (2) rigid-compliant surface (T). Since we classify between two classes, we develop binary classifiers that separate data into one class or the other. a) Data augmentation: Our experimental data and features extracted as explained above were split into the training and testing set following the 70/30 rule. Due to the experiment protocol (see Fig. 2), the R cases were significantly more (approx. 90%-majority class) than the T cases (approx. 10%-minority class), leading to an imbalanced classification problem. In order to minimize the effect of the data imbalance, we applied an oversampling technique in our training set and an undersampling technique in our test set. The Synthetic Minority Oversampling TEchnique (SMOTE) was employed to increase the number of T cases relative to the R cases during the training of the classifier and decrease the bias towards the majority class in the data [37], [38]. SMOTE oversamples the minority class by creating "synthetic" examples rather than by over-sampling with replacement. The minority class is over-sampled by taking each minority class sample and introducing synthetic examples along the line segments joining any/all of the k ′ minority class nearest neighbors. Depending on the amount of over-sampling required, neighbors from the k ′ nearest neighbors are randomly chosen. Our implementation currently uses k ′ = 5 nearest neighbors. A random R case undersampling was applied to balance the testing data set to 50% R -50% T, and thus enable the use of common metrics for classifier performance evaluation. Undersampling does not insert any type of bias in the evaluation of our classifier. b) k-NN: The k-NN algorithm is a supervised learning classifier, which uses proximity to make classifications or predictions about the grouping of an individual data point. A class label is assigned on the basis of a majority vote from the k nearest neighbors of the specified data point. The label that is most frequently represented around the neighborhood of a given data point is used. In order to determine which data points are closest to a given query point, we use distance metrics to form decision boundaries and partition query points into different regions. Our implementation utilizes Euclidean distance d between a test and a training data point, in combination with an inverse distance weight (w = 1 d ). The k value in the k-NN algorithm defines how many neighbors will be checked to determine the classification of a specific query point. We chose k = 9 as the optimal for our dataset after running trials with a series of different k values and cross-validating this choice. For algorithm implementation, the built-in Matlab (Mathworks) function fitcknn() was used. Each predictor variable was centered and scaled by the corresponding weighted column mean and standard deviation. For each segmented window, a separate classifier was trained, resulting in overall six separate classifiers and decisions per gait cycle. c) Artificial neural network (ANN): A pattern recognition neural network (NN) was developed to deduce a final decision per gait cycle, by combining the individual six decisions of the window classifiers. Our network implementation was based on the built-in Matlab (Mathworks) function patternnet() with 1 hidden layer of 100 nodes. Using the trained window k-NN classifiers, we used the existing training data to extract a binary decision per window for each gait cycle. The binary decisions were then fed to the ANN for training purposes. The testing data that were used to evaluate the window classifiers were used for evaluating the ANN performance as well.
The pattern recognition network was applied serially in consecutive combinations of the window classifiers beginning from data only from window 1, continuing to data from windows 1 and 2, 1 and 2 and 3, leading up to all six windows. The window combinations are tested to evaluate how fast within the gait cycle our algorithm can make a decision regarding the walking surface of the next step. The pattern recognition network serially combines the information of the independent k-NN classifier windows in an effort to evaluate how many windows are necessary to make an accurate prediction between the R and T cases. The number of the k-NN windows included in each combination defines the speed of the prediction, with combination 1 being the fastest, as there is only information from the first window classifier involved, and combination 1+2+3+4+5+6 being the slowest case, as the algorithm needs information from all windows to reach a decision. Adding the ANN to our research strategy aims in developing a robust, accurate, and prompt real-time user intent recognition framework. Real-time classification requires a decision to be made prior to LHS and therefore before stepping on the new surface, either rigid or compliant. We hypothesize that a serial combination of the distinct classifier decisions will contribute to higher accuracy and faster predictions. 4) Performance Evaluation -Classification Metrics: In order to evaluate the performance of our classification algorithm, we define a series of metrics that are based on the structure of the confusion matrix. A confusion matrix is a tabular visualization of the ground-truth labels versus model predictions. Each row of the confusion matrix represents the instances in a predicted class and each column represents the instances in an actual class (Fig. 6). We designate the R cases as the positive class and the T cases as the negative class. The metrics that were chosen to evaluate our model are: • Precision: It measures how many observations predicted as R are in fact R.
• Sensitivity: It measures how many observations out of all R observations have been classified as R.
• Specificity: It measures how many observations out of all T observations have been classified as T.  Table I). Kinematic features are grouped together.
• F1-score: It is the harmonic mean between precision and sensitivity.
• Balanced Accuracy: It is the arithmetic mean of sensitivity and specificity. This metric was chosen over simple Accuracy to eliminate any bias on performance evaluation due to the data imbalance.
Bal Acc = 1 2 (S + S P) Balanced Accuracy and F1-score, as they combine the other metrics well, were chosen as representative quantities to measure average subject-specific classification performance.

A. Feature Extraction and Selection
The PSO algorithm was able to reduce the dimensionality of the input feature vector by 75% on average. Specifically, the initial 102 features per window were reduced to approximately 22 ± 5 across subjects. The variation in the number of selected features is due to the fact that each window corresponds to a different classifier, while a natural variability between the subjects' features is also to be expected. Analyzing the frequency of appearance of each feature across windows and subjects could result in useful conclusions regarding the features that are more informative and distinct between the two analyzed cases. Results regarding the frequency of the features across windows are shown in Fig. 7. Specifically, we observe that some features were chosen by the PSO consistently for more than 1 subject. For example, in window 6, there are two features that were selected for six out of the eight study participants. This strongly indicates that besides the subjectspecific algorithm developed in this paper, a generalized  pattern recognition strategy is feasible by extracting a set of features appearing consistently in the majority of the subjects.
Moreover, the selected features are ranked in descending order according to their selection frequency among the subjects in Fig. 8 and 9, showing EMG and kinematic features respectively. Overall, these results show that the number of features could significantly be reduced without losing generality across subjects. This is important because selecting a subset of the features contributes to reducing the channels of information that are used per experiment, increasing computational efficiency and facilitating the classification process.
Regarding the available channels of information for the case of lower-limb amputees, the fact that we can further reduce the set of features computed per muscle is very promising. The chosen group of muscles used for classification consists of generally bigger muscles parts of which are highly likely to be found as residual muscles in subjects with transtibial amputations. Assuming that the leading (left) leg is the amputated limb, it is very exciting to note that the EMG features are all derived from intact hip muscles (LRF, LBF, LVL). On the contrary, signals from below the knee (RSOL, RGA) are extracted only for the trailing (right), non-amputated limb. This finding is particularly important since hip muscles become more significant for stabilizing the lower limb during walking for amputee patients.

B. Classification
a) k-NN: The performance of each window classifier confirms our initial hypothesis that the prediction accuracy will be higher toward the end of each gait cycle as we approach the last segmented windows. Performance evaluation of our best subject results showed that Balanced Accuracy steadily increased by 41.7% between window 1 (45.8%) and window 6 (87.5%) (see Fig. 10). All the measured metrics presented a similar upwards trend towards the last segmented windows, confirming an improvement in classifier performance as the subject approached the end of each gait cycle. The study of all five metrics ensures that no bias has been introduced due to data imbalance and shows that our results can be accurately quantified with common metrics found in the literature.
This trend was also confirmed for all subjects by studying the average subject performance for each window classifier shown in Fig. 11. We observe that the mean subject values for the F1-score and Balanced Accuracy metrics present an ascending trend as the window (classifier) number increases. The standard deviation calculated for each window shows the dispersion of the metric values among the subjects. b) ANN: Applying the ANN methodology to the resulting k-NN window classifiers, we shift our focus to serial combinations of windows rather than single window classifiers. Again we observe that the trend of the ascending metrics remains while the F1-score and Balanced Accuracy values  increase as window classifiers are added (Fig. 12). An important observation is that the standard deviation calculated per combination is significantly smaller compared to the single window cases. This finding indicates a narrower dispersion of the metric values around the mean and supports the hypothesis of more robust predictions across subjects. Both of the studied metrics also present similar profiles, showing that although the F1-score tends in general to favor the positive class, in our case the metric closely resembles the balanced accuracy which accounts equally for both the positive and negative classes. Although window combinations 1-4 and 1-5 present on average 8% lower metric performance than combination 1-6, they manage to maintain a similar, stable profile, while maintaining a small standard deviation of values in contrast to the respective single k-NN window classifiers. We, therefore, understand that there is a trade-off between classification accuracy and fast prediction time; we could utilize window combinations 1-4 and 1-5 to make a prompt decision about user intent approximately 300ms to 150ms before foot-contact respectively, however compromising an average of 8% accuracy. It should be emphasized that since the developed strategy focuses on subject-specific classification, this trade-off will depend on the subject parameters. Overall, the addition of the ANN in our research strategy was able to increase the classification accuracy by 4.82% and the F1-score by 6.78% between the k-NN classifier 6 and the classifier combination including windows 1 to 6 as shown in Fig. 13. For reference, a majority vote was also tested against the ANN training to verify whether training a network offers better results than a simplified majority decision. Indeed, although the majority vote (Bal Acc = 70.42%, F1 = 74.03%) technique performs better than the single k-NN classifier 6 (Bal Acc = 68.03%, F1 = 69.36%), it fails to reach the accuracy level of the ANN (Bal Acc = 72.85%, F1 = 76.14%). Besides being less accurate than the ANN, a majority vote also presents challenges relating to the number of windows involved in the selection process. An even number of windows as in our case requires further subject-specific data thresholding in the case of a tie.
The inherent difficulty of our prediction task is that both classes involved in the classification pertain to walking on rigid ground. The differentiating factor is whether the next step happens on a rigid or a compliant surface. The resemblance of the R and T cases makes prediction a challenging task, which our algorithm successfully tackles by achieving a classification accuracy up to 87.5%. Although to our knowledge other works on stiffness predictions are not available, our work can be related and compared to studies on locomotion mode predictions (e.g. stair ascend-descend). A relevant representative work studies the identification of locomotion modes using EMG signals and reports an average prediction accuracy of 94.8 ± 3.7% during the Pre-HS phase using EMG signals from 16 different muscles of the lower limbs [39]. Our PR strategy reaches an average prediction accuracy of 72.85 ± 9.3%, however only using EMG signals from 6 different muscles of the lower limbs, utilizing a limited amount of neural information compared to [39]. In spite of this, our strategy is still able to successfully predict transitions between surfaces of variable stiffness and reduce the channels of information necessary to do so. However, due to the innate differences between stair ascend-descend and compliant surface transitions at both muscular and kinematic levels, we believe that comparison with works related to locomotion mode changes is not accurate or particularly insightful.

IV. DISCUSSION
The current study yields specific results for a subject pool of healthy adults, yet this does not mean that results for people with transtibial amputations will necessarily be the same. Relevant studies show there are differences between the intact and amputated limbs of clinical participants with respect to muscle activation and muscle heterogeneity [40]. Additionally, selective muscle atrophy in people with lowerlimb amputations has been shown to affect the muscle volume of certain muscles [41], which may subsequently lead to changes in EMG signal strength. The quality of the acquired EMG recordings is also highly dependent on the level of amputation of each individual, as well as the respective surgical intervention they have undergone. In spite of these limitations, previous works support that EMG patterns are consistent from stride to stride in people with transtibial amputation, irrespective of the high inter-subject variability in recruitment patterns in amputees [17]. The benefit of our algorithm, therefore, lies in that it is a subject-specific framework, which is trainable to each subject's signals, taking into account the distinct EMG and kinematic parameters of each individual subject under two different conditions: rigid-rigid and rigidcompliant. We thus believe that although classification results are expected to differ among different subject populations, the proposed algorithm should be able to yield comparable experimental results for rigid and compliant surface transitions in populations not tested in this analysis, e.g., transtibial amputees.

V. CONCLUSION
This paper introduces a novel pattern-recognition algorithm predicting the user's intent to transition from a rigid to a compliant surface via the use of EMG and kinematic data. The proposed PR strategy effectively reduced the number of extracted features by 75% and selected only the relevant predictor variables as input to our classifiers. The selected features not only contributed to increasing classifier performance and minimizing feature redundancy, but were also consistently selected across subjects. This finding is particularly promising for developing a more generalized approach that is not subjectspecific. The ANN PR component allows for a robust and fast prediction that does not exclusively depend on a single classifier decision but incorporates past knowledge from within the gait cycle as locomotion progresses. Our classification strategy was able to robustly and accurately predict user intent to step on a rigid (R) or a compliant (T) surface, achieving an accuracy of up to 87.5%.
The results of this work are particularly exciting and interesting, as the classification takes place between two classes that both involve walking on a rigid surface. The fusion of EMG signals with kinematic data was able to distinguish between the two cases solely on the basis of user intent to step on another rigid or compliant surface. The developed framework can be used as part of a high-level controller that will inform the prosthesis or lower extremity device and tune its parameters in real time. Such implementation can lead to a new generation of prosthetic and wearable devices that will incorporate the human wearer in the loop and proactively adjust their control to transition to surfaces of different compliance. The latter will lead to increased robustness and safety of lower-limb prostheses and wearables that will eventually improve the quality of life of individuals living with a gait impairment or lower limb amputation.