# DNN-Based FES Control for Gait Rehabilitation of Hemiplegic Patients
## 2 Methods
### Control of the FES Based on Reference EMG
#### 2.2.1 Mapping from EMG to FES  
Mathematical models of the musculoskeletal system have been commonly employed to estimate the joint torque from the reference EMG [37]. However, through this model-based approach, computing the muscle activities of musculoskeletal models from EMG signals is difficult [22]. Recently, machine learning techniques have been employed as an alternative to model-based approaches for joint torque estimation. Machine learning is an algorithm type that enables a computer to learn by itself without any specific guidelines for training conditions, and this approach has shown prowess in identifying an underlying pattern hidden inside a highly noisy dataset [26]. Among a variety of machine learning techniques, deep learning  
Figure 3: Feature points and functionalized envelop of soleus and TA in the percentile gait cycle; (**a**) feature points of soleus, (**b**) feature points of TA, (**c**) envelope function of soleus, (**d**) envelope function of TA. has become popular owing to its effectiveness in handling nonlinear problems with anti-noise robustness. DNNs are a type of artificial neural network (ANN) model based on multi-layer perceptron (MLP) and deep learning training. As a type of DNN model, a CNN, featuring convolution and pooling layers, has the strength in the extraction of key features of input data. While CNN is commonly used for two-dimensional input data such as images, one-dimensional CNNs (1D CNNs) are also effective in analyzing time-series data, such as EMG signals. To estimate the required joint torque from the reference EMG, a combination of a 1D CNN and a fully connected MLP were employed in this study. The structure of CNN-MLP model is illustrated in Figure 4. In the network model, there were three 1D CNN layers in the series. Each 1D CNN had a convolution and pooling layer. The three convolution layers had a kernel size of 16 and a filter size of 128, and the three pooling layers had pooling sizes of 6, 4, and 2. The three 1D CNNs compute the convolution with stride lengths of 1, 0, and 1. After the 1D CNNs, the flattened layer was located to match the dimensions of the dataset. Following the flattening layer, five fully connected MLPs with layer sizes of 129, 128, 128, 64, and 1 were used in the series. For the activation functions of MLPs, the first four MLPs used rectified linear unit (ReLU), whereas the last MLP used a hyperbolic tangent function (Tanh) to take nonlinearity into account. For model training, the Adam optimizer was employed, which was stable and effective in training a DNN. To train the CNN-MLP model, the training data were acquired from isometric contraction tests using a customized apparatus described in Section 3.2.2, where the EMG at the soleus and TA and the corresponding ankle torque were measured. The dataset was divided into training, evaluation, and test sets with a ratio of 6:2:2. To avoid overfitting of the model, the training ended after it reached the fifth epoch of the dataset. The final root means square error (RMSE) value evaluated using the test dataset was 4.966. The developed CNN-MLP model was employed to estimate the ankle joint torque from the reference EMG envelopes for the soleus and TA. Figure 5a-c show the foot-ground contact information at the heel and toe on the paretic side, the reference EMG envelopes for the soleus and TA, and the estimated ankle joint torque, respectively. Using the modulated EMG profiles as input, the CNN-MLP model estimated the joint torque at the ankle on the paretic side. As can be observed from the EMG data in Figure 2, the co-activation of the soleus and TA is rarely observed during gait, with the exception of the gait in the low-speed range (below 2 km/h). Under this assumption, the positive torque in Figure 5c indicates the plantar flexion solely by activation of the soleus, and the negative torque indicates dorsiflexion solely by the activation of the TA. The developed CNN-MLP model computes the joint torque to produce the desired motion on the paretic side.