Gait Activity Classification With Convolutional Neural Network Using Lower Limb Angle Measurement From Inertial Sensors

Human gait activity recognition can be crucial to adapt the assistance provided by lower limb exoskeletons, as well as for biomechanical analysis. With this purpose, deep learning techniques can be applied to develop a classifier based on the acquisition of the lower limb kinematics. In this article, we present a 1-D convolutional neural network (CNN) to classify different activities from the hip, knee, and ankle flexion/extension angles, measured with wearable inertial sensors. The proposed CNN classifier achieves 99.56% accuracy with users not involved in the learning process. In addition, the gradient-weighted class activation map (Grad-CAM) and the t-distributed stochastic neighbor embedding (t-SNE) were used to understand the CNN model decision-making. Finally, how the accuracy of the CNN model is impacted by input reduction was analyzed to adapt the CNN model to multiple situations, and it can be concluded that the CNN maintains high accuracy with a single joint angle as input.


I. INTRODUCTION
H UMAN locomotion is a complex and dynamic process that involves the coordination of multiple body segments and muscles.The analysis of human gait can provide valuable information about the health and functional status of an individual [1].In this context, the analysis of human gait can be used to analyze the range of motion (ROM) of the lower limb joints, which may be reduced in patients suffering from neuromuscular pathologies, such as cerebral palsy, Parkinson's disease, or hemiplegia [2], [3].In addition, lower limb kinematics analysis could help make detailed diagnoses, plan optimal treatment, or evaluate the results of rehabilitation therapies [4].However, traditional gait analysis methods require expensive and specialized equipment, and they are also limited by the laboratory setting, which may not reflect the natural and dynamic environment of daily living [5].Therefore, to perform a correct biomechanical analysis in a natural environment, the recognition of the activity that the user has performed is needed.
Gait analysis and activity classification techniques can be used to personalize lower limb exoskeletons, which are wearable devices designed to assist or enhance leg movements [6].These exoskeletons have diverse applications, such as rehabilitation, assistive technology, and human augmentation [7], [8].The exoskeleton must be able to recognize the user's intentions and adjust its parameters accordingly to ensure a natural and comfortable interaction between the user and the device [9].Joint sensors and inertial measurement units (IMUs) are generally used for movement recognition [10], [11], [12].In addition, the activity performed is the most important factor in determining the operation and high-level behavior of assistive walking devices.Different methods have been proposed to detect and adapt the control of lower limb exoskeletons, including cameras [13], [14], infrared distance sensors [15], and a combination of infrared sensors with IMUs.
Machine learning algorithms can be employed to classify various gait activities of daily living (ADLs) based on the information provided by inertial sensors [16].This classification is vital for biomechanical analysis and adaptation of lower limb exoskeleton assistance in a natural environment.Extracting temporal and frequency domain features from the IMUs can be used to train machine learning models for gait activity classification [17].By contrast, deep learning methods can autonomously extract features from the signals collected by the IMUs [18].Convolutional neural network (CNN) is one of the most commonly used models for deep learning in image processing [19].Some authors have transformed accelerometer and gyroscope signals from IMUs into images to apply 2-D CNNs for gait activity classification [20].However, generating 2-D images for the analysis of time series can be computationally expensive.Therefore, a fixed-size time series can be used instead of images to train and recognize ADLs with a 1-D CNN [21].
Although the accelerometer and gyroscope data provided by the IMUs have been used to develop gait ADL classifiers, the use of the angles of the lower limb joints has not been explored.This method can be easily embedded in the control system of the lower limb exoskeletons, since joint sensors are generally used.In addition, this method could also be used to perform biomechanical analysis with wearable measurement devices.In this article, we present a deep learning model that uses the angles of the lower limbs to classify different gait activities.For this purpose, we have developed a 1D-CNN architecture that can effectively extract features and classify several gait activities from the trajectories of the lower limbs measured with wearable IMUs.In addition, we have used the gradient-weighted class activation map (Grad-CAM) and the t-distributed stochastic neighbor embedding (t-SNE) to understand the decision-making of the developed 1D-CNN model.Finally, we have analyzed possible variations of the model, so that it can be adapted to multiple lower limb exoskeletons as well as to perform a biomechanical analysis from one to three joints.

II. RELATED WORK
Human activity recognition (HAR) is a complex problem that has many practical applications, such as human-robot interaction, rehabilitation, or health monitoring [22].With recent advances in wearable technology, analyzing human biomechanics and recognizing different ADLs has become more affordable, accurate, and feasible.
Vision-based approaches have been explored to perform activity recognition and adapt lower limb exoskeletons or prostheses.Varol and Massalin [23] study the feasibility of using a depth camera placed on the leg to adapt lower limb prostheses.The authors detected five different situations (standing, running, ground-level walking, ascending stairs, and descending stairs) using a support vector machine (SVM) with a 99% accuracy.On the other hand, Laschowski et al. [24] proposed to use a chest-mounting camera, which provides less relative body movement than head or lower limb mounting.In that work, the authors used a deep learning model to analyze the images from the camera to detect ground-level walking and ascending/descending stairs with a 94.85% accuracy.
In addition to vision-based methods, the use of inertial sensors for HAR has also been widely studied.Pham et al. [25] used accelerometers embedded inside the insoles of the shoes to recognize different activities.They used accelerometer signals as inputs of a CNN to recognize six activities with a 93% accuracy (running, walking, cycling, kicking, standing, and jumping).
Other authors propose to use the IMU of smartphones to recognize different activities.Ronao and Cho [26] used the gyroscope and accelerometer signals as inputs of a 1D-CNN, where the proposed model achieved a 95.57% accuracy using the fast Fourier transform of the input signals.Another example is the model proposed by Lee et al. [21], where they used the Euclidean norm of the accelerometer signals to detect different activities, with a 92.71%.Moreover, Yi et al. [27] propose to classify different activities by extracting statistical features from the accelerometer of smartphones, achieving a 95.89% accuracy with a CNN model.
More related to our work is the approach proposed by Badawi et al. [28], where they used the public dataset HuGaDB [29] to classify different gait ADLs.The authors trained a random forest model using as inputs different extracted features from the accelerometer and gyroscope signals placed over the thigh, shank, and foot, achieving an accuracy of 98.6%.Instead of extracting features to train the models, in [20], a deep learning approach was used.Makihara et al. [30] transformed the accelerometer and gyroscope signals from the OU-ISIR public dataset to use a 2D-CNN.They show that their trained model achieved a 93% accuracy when detecting ground-level walking, ascending/descending a ramp, and going down/up stairs.In addition, Semwal et al. [31] used a single IMU placed at the center of mass position of each user to recognize different gait activities (jogging, groundlevel walking, standing, and climbing stairs).The authors employed a hybrid model based on ensemble learning, and they achieved an accuracy of 99.34%.However, the main limitation of this approach relays on the computational cost, since the ensemble learning approach is composed by four deep learning models, which would be not suitable for realtime inference.In addition, the authors do not include, in the work, an evaluation with users who were not participated in the learning process of the models.Hence, it is not clear how accurate this method would be if used with different users.
In addition to only employing inertial sensors, some studies propose to perform HAR by fusing the IMU data with other sensors.Liu et al. [32] propose to employ an IMU placed over the waist together with laser measurements to recognize the terrain for adapting powered lower limb prostheses.They used a decision tree to perform a terrain classification with a 98% accuracy.Another sensor fusion approach is presented in [33], where pressure insoles and IMUs placed on the thigh and shank were used.An intelligent fuzzy algorithm was used to recognize different gait ADLs with an accuracy of 95.52%.Another approach is presented in [34], where several IMUs and strain gauges placed on the lower limbs were used to classify different gait activities.The authors used an autoencoder to perform dimensionality reduction, followed by a deep learning model that combined convolutional and recursive layers, achieving an accuracy of 98.9%.
Despite different methods for HAR using wearable sensors have been proposed, they all come with certain limitations.Vision-based techniques are computationally expensive due to the need for image analysis to detect user activity.In contrast, the use of IMUs seems to be portable and cost-effective, and the computational cost is affordable enough to perform HAR with wearable devices.Nonetheless, in the IMU-based methods proposed, accurate placement of IMUs is essential, as any error in the IMU positioning may cause disturbances in the signals, thus reducing the accuracy of the activity classification.
To the best of our knowledge, no study has explored the use of the angles of the lower limb joints to perform HAR.In order to propose an affordable approach, while solving the possible errors due to IMU positions, we have implemented a method to measure the angle of the hip, knee, and ankle in the sagittal plane, which does not depend on the position and location of the IMUs.Therefore, variations in IMU placement on the lower limbs would not impact the classification accuracy.While previous studies have proven effective in HAR, the use of explainability methods to understand model operation is not common in this field.Thus, we have used the t-SNE method and Grad-CAM to determine how our model extracts features and which parts of the input are most critical.

A. Lower Limb Joints Measurement
An IMU-based algorithm was used to measure the flexion/extension angles of the hip, knee, and ankle joints.The joint motion analysis method proposed by Seel et al. [35] was applied to estimate the lower limb joint angles during gait.This method does not require the knowledge of the IMUs' position and orientation on the user's lower limb, and it only assumes that each joint has two inertial sensors on its upper and lower segments and uses the measured accelerations and angular rates.
To align the IMU reference systems with the joint axis, some methods in the literature require specific and accurate calibration movements [36].On the other hand, the method by Seel et al. [35] determines the location of the sensors on the joint they measure by using arbitrary calibration movements and joint movements during gait, taking advantage of kinematic constraints.The direction vectors j1 and j2 of the hip, knee, and ankle joints' flexion/extension axes are found using gyroscope data in the local coordinates of the IMUs during the calibration.The acceleration data are also used to estimate the joint position coordinates o1 and o2.
The method by Kumar et al. [37] has demonstrated a rootmean-squared error between 3 • and 5 • in flexion/extension movements.This suggests that the method is accurate enough for gait analysis and gait ADL detection.In addition, Seel et al. [35] demonstrated that this method conserves the accuracy even at low acquisition rates.Therefore, this method is robust and suitable to perform real-time measurements.

B. Experimental Session
Twelve non-disabled participants (nine male and three female) aged 23-52 years old (29.8 ± 7.4), with heights ranging between 165 and 187 cm (176.2 ± 7.4 cm) and weights between 56.1 and 90.2 kg (76 ± 12.5 kg) participated in the experiment.They provided written, informed consent before participating in the experimental session.
Four gait activities were simulated to collect lower limb movement data using four XSens Dot IMUs at 60 Hz.In order to simulate and collect data during various ADLs, we used an h/p/cosmos 150/50 treadmill to simulate ground-level walking, ramp ascent, and ramp descent.A stair treadmill was used to simulate stair climbing.The experimental setup and the ADLs performed are shown in Fig. 1.
The IMUs were attached to the pelvis, thigh, shank, and foot using elastic triggers and stickers.The participants calibrated the IMUs by moving their legs for 30 s and walking on the treadmill for 1 min at their preferred speed.
After the calibration concluded, the angles of the hip, knee, and ankle were measured during four different activities: 1) ground-level walking at 4.5 km/h for 5 min; 2) 12% positive slope walking at 2.5 km/h for 5 min; 3) 12% negative slope walking at 2.5 km/h for 5 min; 4) climbing stairs at 50 stairs/min for 3 min.We followed the INESCOP Footwear Technology Center protocols for footwear certification to set the walking speeds and slope.The stair-climbing time was shortened to 3 min to prevent excessive fatigue.

C. Acquired Data
This section describes the IMU data acquisition and processing to be used as inputs of the classifier model.This procedure is shown in Fig. 2, which is based on previous studies [38], [39].Fig. 2. IMUs placed on the lower limbs were used to measure acceleration and angular velocity for the estimation of the flexion/extension angles.We also detected the foot-ground contact from the hip acceleration, which is used to segment the joint angles into steps and gait cycles.We normalized each gait cycle (0%-100%) and fed them to the CNN as inputs.The hip, knee, and ankle flexion/extension joints are normalized between their minimum and maximum to be introduced as inputs of the model.The proposed model is composed of three 1-D convolutional layers with a kernel size of 3 and 64 filters.Also, a padding operation is applied to have feature maps with lengths equal to the inputs.The ReLu is used as the activation function of the convolutional layers, and batch normalization is applied.A global average pooling layer is used to reduce the generated feature maps connected to the output layer.
Acceleration and angular rate data were used to measure the flexion/extension angles of the hip, knee, and ankle.To perform a gait analysis, kinematics data are usually transformed from the time domain to the gait cycle domain (0%-100%), which requires identifying the start and end of each gait cycle.Therefore, we applied this transformation to all signals.We used the hip acceleration [40] to detect the ground-foot contact and applied a forward-backward low-pass filter [41] with a 2-Hz cutoff.The local maxima in the filtered signal correspond to the left and right foot contacts.We followed the convention of using the right foot contact to calculate the gait cycle.
It is important to note that the CNNs require a fixed window size as input.In our case, as we want to classify each step within one of the ADLs, it seems reasonable to use a window size of 100 joint values calculated from the gait cycle.Therefore, we will use, as CNN inputs, three windows of size 100, with the values of hip, knee, and ankle flexion/extension angles during a step.

D. Gait Activity Classifier
1) Proposed CNN Architecture: As introduced, we plan to train a CNN model to detect four gait activities.Typically, 1D-CNN classifiers consist of two parts [42]: the convolutional and pooling layers, and the fully connected layers or multilayer perceptron (MLP).
In the first part of the model, the CNNs have an input layer of N × k, where N is the length of the univariate time series and k is the number of input series.After the input layer, convolution and pooling operations are used to generate deep features of the inputs.In the convolutional layers, convolution operations are performed on the time series of the previous layer with convolutional filters (kernel), whose final output is known as a feature map.In addition, a nonlinear function, such as the rectified linear unit (ReLu) function, is used after each convolution operation.In the pooling layers, the feature maps are divided, and each segment is represented by its average or maximum value.Finally, after the convolution and pooling layers, the original time series is represented by a series of feature maps.
The feature maps are usually connected to an MLP in the second part of the model.The classification task is performed by these layers based on the features and filters of the previous layers.A global average pooling layer can replace this part, which aims to produce one feature map per class [43].The average of each feature map is taken by this layer, and the resulting vector goes straight to the softmax layer.The global average pooling layer also fits better with the convolution structure by creating correspondences between feature maps and categories, and it prevents overfitting at this layer, since it has no parameter to optimize.
The architecture of the CNN model proposed to classify four gait activities is a fully CNN (Fig. 2).The hip, knee, and ankle flexion/extension angles are introduced as the CNN inputs, which have been normalized by their maximum and minimum values.We have used three convolutional layers, and 64 filters are applied with a kernel size of 3.Moreover, we applied padding on the convolution operations to have feature maps with a length N equal to the inputs.After each convolutional layer, we operate with the ReLu as the activation function, and batch normalization is applied.After the convolution operations, we used a global average pooling layer connected to a dense layer with four neurons (one per gait ADL) with the softmax as the activation function.The number of convolutional layers, the number of filters, the size of the kernels, and the rest of the hyperparameters of the model have been tuned to achieve the highest performance.
Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.

2) Preprocessing and Model Training:
We divided the data from 12 participants into three subsets to evaluate the performance of the model.Time series from nine users were randomly divided by steps to train and to validate the accuracy of the model with (intraparticipants): 80% was used for training and 20% for validation.Data from the remaining three users were used to evaluate model accuracy with participants not involved in the learning process (interparticipants).In addition, the training data were scaled between the minimum and maximum angle values of the hip, knee, and ankle, so that the values of the inputs are between 0 and 1.The training scaler was also used to evaluate the model with the intraparticipant and interparticipant data.
The proposed 1D-CNN model has been trained with the Keras Python Library.The model was trained for 50 epochs and a batch size of 8. To adjust the weights of the network, we used the Adam algorithm as the optimizer, and the categorical cross entropy (CE) was used as the loss function, defined as follows: where y i is the actual class, ŷi is the CNN score for each class, and C is the number of classes.

E. Model Explainability
It is common to think of machine learning models as black boxes, since insights into decision-making are mostly opaque to humans.However, understanding decision-making can be critical in areas, such as healthcare.In our particular case, it may be interesting to know how the trained CNN model discriminates between the four ADLs performed during the experimental session.Some methods have been proposed to explain model predictions to solve the black-box problem.We used the Grad-CAM algorithm [44] to examine the class activation map [45].The Grad-CAM method has been used to explain deep learning models in image analysis by noting the impact of the pixels on the prediction.Extending this method to time-series analysis with a CNN, we can use Grad-CAM to highlight segments of the joint trajectories to understand how our model distinguishes each gait activity.In addition, in Section IV-C, the contribution of the hip, knee, and ankle flexion/extension trajectories will be analyzed.

A. Model Evaluation
In Fig. 3, the hip, knee, and ankle flexion/extension angles have been represented during the ADLs performed during the experimental session.
We evaluated the performance of the CNN model trained with data from the intraparticipants and interparticipants.The inference process was made in a PC with an Intel 1 Core 2 i7-1165G7 at 2.80 GHz with 16 GB of RAM, and each inference took 1 ± 0.37 ms.In addition, the performance of the proposed model is compared with four state-ofthe-art models proposed in different studies: ResNet [46], t-LeNet [47], MCDCNN [48], and Time-CNN [42].Table I collects the accuracy and the CE with the intraparticipant and interparticipant data with the proposed model and the state-of-the-art models.The results show that our classifier achieves an accuracy of 99.65% and a CE of 0.0054 with intraparticipant data, and an accuracy of 99.56% and a CE of 0.0025 with interparticipant data.For a better comprehension 1 Registered trademark. 2Trademarked.
Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.

TABLE I ACCURACY AND CE OBTAINED WITH THE INTRAPARTICIPANTS AND INTERPARTICIPANTS
Fig. 4. Confusion matrices obtained with the proposed CNN classifier for intraparticipants and interparticipants.The rows of the matrix show the ADL that was performed, and the columns show the ADL that was predicted.The matrices include the four gait ADLs that were done in the experiment: walking on a flat surface, going up a ramp (Up), going down a ramp (Down), and climbing stairs.
of the classification results, confusion matrices are represented in Fig. 4 with the intraparticipant and interparticipant data.The results show that CNN could confuse ground-level walking, ascending a ramp, and descending a ramp.For the intraparticipants, 99% of the descent ramp steps are classified correctly, where 0.32% of the steps are confused with ground-level walking, and 0.97% is confused with ascending a ramp.The interparticipant results show similar behavior, since 1.5% of the descent ramp steps are classified incorrectly as groundlevel walking.

B. Model Interpretability
We applied the t-SNE to project the 64-D feature map obtained by the convolutional and global average pooling layers into a 2-D graph [49].Fig. 5 shows the representation of the generated feature maps for two intraparticipants and two interparticipants, using perplexity and early exaggeration values of 50.This graph shows diverse groups of points, also known as clusters, where each point represents the feature map obtained by the CNN for each step, and clusters represent a group of similar steps.
In Fig. 6, we have represented the mean joint trajectories of the lower limbs during the four gait ADLs over the class activation maps obtained with Grad-CAM for the last convolutional layer.The activation map is represented as a heatmap that highlights the important parts of the inputs.Blue parts of the graph can be seen as low attention parts of the inputs, and red values as high attention parts.The ground-level walking activation map shows high activation during the terminal stance phase (45%-65%), the swing phase, and the initial contact; the ascending ramp activation map shows strong activation during the loading response and mid stance phase (around 10%-50%) and the terminal swing phase; the descending ramp activation class shows high activation during the terminal swing phase (75%-90%), and the climbing stairs activation map has an strong activation during the swing phase (70%-90%).
In addition, the Grad-CAM method could also help us to understand why some steps are classified incorrectly.Fig. 7 collects two steps classified wrongly as descending Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.

C. Model Adaption
Several models have been trained with the same proposed architecture, but changing the number of inputs of the models to check the feasibility of adapting the CNN model presented.With this purpose, we have trained seven 1D-CNN models for a different number of epochs, all of them with the architecture proposed.
In Tables II and III, the accuracy of the models is shown according to the number of inputs and training epochs.
As detailed in the previous sections, the results show that the model trained with all the angles of the lower limb joints achieves accuracy close to 100% for all the range of epochs with the intraparticipant and interparticipant data.

V. DISCUSSION
We trained a CNN to recognize four gait ADLs: groundlevel walking, ramp ascent, ramp descent, and stair climbing.Several authors have proposed using accelerometer and gyroscope data from IMUs to recognize different gait activities [20], [21], [25], [26], [28], [29], [32], [33].We propose a different approach from other studies, since we used multiple IMUs to capture the joint angles of the lower limb in order to classify the gait activities.This way, we can do a biomechanical analysis and also adjust the assistance given by lower limb exoskeletons.Hence, the hip, knee, and ankle flexion/extension angles were introduced as inputs to a 1D-CNN.Our method, based on the study of Seel et al. [35] approach, has the advantage of estimating joint angles without depending on the position and orientation of the IMUs.This means that variations in sensor placement do not affect the error in gait activity classification.Furthermore, the calibration method of this algorithm is simple, and it does not require accurate movements, as it only requires walking and performing random leg movements for a short period of time.
We can extract features describing the gait using the angles of the lower limb joints to distinguish between activities.However, we decided to use a CNN model, since deep learning methods can extract features autonomously from the input data [18], also known as feature maps.The 1D-CNN proposed shows promising results, with 99.65% accuracy for intraparticipants and 99.56% accuracy for interparticipants (Fig. 4).In addition, the results collected in Table I show that our model outperforms other state-of-the-art architectures with the interparticipant data.However, it must be noted that the accuracy and the CE are in a similar range for all the trained models.These results suggest that introducing the lower limb joint trajectories is a robust method for gait ADL recognition, outperforming other approaches proposed previously (Section II).Furthermore, the computational time results with our model are around 1 ms for each inference on a laptop, suggesting that our method can be employed to perform HAR in real time.Despite our CNN model achieved high accuracy with both intraparticipants and interparticipants, the ground-level walking and walking on a ramp are sometimes classified wrong, which can be observed in the confusion matrices.The t-SNE and Grad-CAM methods could be the basis to clarify this behavior.
In Fig. 5, we have represented the projection of the 64-D feature maps extracted with the proposed CNN model with data from four users: two intraparticipants and two interparticipants.The resulting graph shows diverse groups of points (clusters), where each point represents the feature map obtained by the CNN for each step, and clusters represent a group of similar steps.The feature maps generated by our CNN model for climbing stairs are grouped in four different clusters, while the rest of the clusters could be composed of one or two ADLs.This could be explained by the similarity in the joint trajectories during the ground-level walking and walking on a ramp (Fig. 3).In addition, although there are Authorized licensed use limited to the terms of the applicable license agreement with IEEE.Restrictions apply.
clusters formed with two ADLs, the ADLs are joined into four different groups, which can be observed in the graph.The number of groups coincides with the number of users in the projection.This could mean that each participant has a unique gait pattern, so the feature maps generated by the CNN would not be equal for all the users.However, one might wonder why a good classification result is achieved when t-SNE does not show a clear separation of the extracted features.This may be because neural networks can recognize nonlinear boundaries, so that ADL can be separated in the 64-D space.
The t-SNE embedding method can help us understand how the features extracted by the CNN are grouped.However, it cannot verify which parts of the joint trajectories are important in determining the user's gait ADL.To examine which parts of the joint trajectories are crucial in classifying each gait ADL, we can use the Grad-CAM method.In Fig. 6, the class activation maps for each gait ADL over the hip, knee, and ankle flexion/extension angles are represented.For instance, in the case of climbing stairs, the highest activation is produced during 70%-90% of the gait cycle.When we compare the hip, knee, and ankle trajectories during those periods with the rest of the gait ADLs, there is a notable difference.However, the t-SNE graph and confusion matrices show that wrong classifications occur more often during ground-level walking, ascending a ramp, and descending a ramp.Specifically, certain steps descending a ramp are misclassified as ground-level walking or ascending a ramp.
The Grad-CAM method can be a powerful tool to understand why our CNN model makes incorrect predictions.To this end, we can use joint trajectories and activation maps for two incorrect classifications, as shown in Fig. 7.The left graph represents a step performed while descending a ramp but classified as ground-level walking.The class activation map shows high activation between 40% and 50%.This activation occurs around the peak of the ankle angle, which suggests that the gait pattern is more similar to flat walking.This is because, at this instant, the ankle angle is greater than the hip angle, which does not occur when walking on a descent ramp.In the case of the step classified as ascending a ramp, a high activation can be observed during the loading and stance phase, which is from 10% to 50%.This activation corresponds to the activation map of the ascending ramp steps and could be due to the similarity of the knee trajectory during this section of the gait cycle.
The feasibility of reducing the number of inputs to the 1-D CNN was also examined.The results collected in Tables II and III show that high accuracy can also be achieved by reducing the number of inputs.It should be noted that by introducing a single input of the 1-D CNN, the model achieves an accuracy of 97.82% (intraparticipants) and 98.28% (interparticipants) when using the hip angle, and an accuracy of 93.21% (intraparticipants) and 85.77% (interparticipants), and an accuracy of 99.91% (intraparticipants) and 97.55% (interparticipants) for the ankle angle trajectory.Although the accuracy is reduced compared with the introduction of hip, knee, and ankle flexion/extension, these results suggest the feasibility of adapting the model to different situations.Thus, the 1D-CNN classifier could be adapted to analyze the biomechanics of a single lower limb joint as well as to detect gait activities for different types of lower limb exoskeletons.
Although the results obtained by adapting the model suggest that our method can be used with exoskeletons, it must be noted that we intend to further develop and test the proposed method.Furthermore, we intend to integrate this HAR system to adapt the assistance of active lower limb exoskeletons and to provide adequate assistance on different types of surfaces.

VI. CONCLUSION
This work presents a deep learning model to perform HAR during gait.The classifier is based on a 1D-CNN and uses the flexion/extension angles of the hip, knee, and ankle measured with IMUs.It is worth noting that the method used in this study to measure the lower limb angles does not depend on the position or location of the sensors, making the method very reliable.
The CNN classifier proposed achieves high accuracy with intraparticipants (99.65%) and interparticipants (99.56%), so it can be assumed that the proposed model presents a high generalization.The t-SNE and Grad-CAM algorithms were used to understand this behavior, and it can be concluded that this is due to anomalous steps or a high similarity of joint trajectories between activities.
Furthermore, we have trained the 1D-CNN varying the number of inputs.The results suggest that the 1D-CNN architecture proposed could be adapted to analyze the biomechanics of a single lower limb joint as well as to detect gait activities for different types of lower limb exoskeletons.

Fig. 1 .
Fig. 1.Setup and performed gait activities during the experimental session.The left image shows the positions of the attached IMUs used to measure joint angles.The participants walked on a treadmill to simulate ground-level walking, as well as ascending and descending a ramp of 12% slope.In addition, stair climbing was simulated using a stair treadmill.

Fig. 3 .
Fig. 3. Collected kinematics data during the experiment.The flexion/extension angles of the hip, knee, and ankle joints (top, middle, and bottom row) for different types of walking (flat surface, ascent ramp, descent ramp, and stairs) are shown and normalized by the gait cycle.The figures above show the median of the 12 participants, and the shaded areas indicate the range between the first and third quartiles.

Fig. 5 .
Fig.5.Two-dimensional representation of the feature map generated by the CNN model proposed for two intraparticipants and two interparticipants.The projection was obtained using the t-SNE embedding.Each gait ADL is represented by a color: blue for ground-level walking, red for ascending a ramp, green for descending a ramp, and yellow for climbing stairs.

Fig. 6 .
Fig. 6.Mean lower limb joint trajectories during ground-level walking, ascending a ramp, descending a ramp, and climbing stairs overlaid with the mean class activation maps.The class activation maps have been obtained with the Grad-CAM method, where blue parts represent low activation and red parts represent high activation.

Fig. 7 .
Fig. 7. Descending ramp steps classified incorrectly as ground-level walking and ascending ramp steps.The class activation maps and the joint trajectories are represented, and the softmax values for the predicted and actual classes are collected.