## 2 Materials and Methods
### Data Analysis
#### 2.4.2 Determining Muscle Synergies: Non-Negative Matrix Factorization (NNMF)  
Muscle synergies were identified using non-negative matrix factorization (NNMF). NNMF motor module analysis of muscle coordination [17; 21] was implemented here but adapted to suit the specific context of our study. NNMF is a technique that assumes the set of measured data is composed of linear combinations of a smaller number of underlying elements. The NNMF process represents the original sEMG data as a linear combination of vectors called muscle synergies (\(W\)) and activation coefficients (\(H\)) as shown in Equation (1). \[M=WH=W(m\times n)H(n\times t)=\sum_{m=0}^{7}W_{mn}H_{nt} \tag{1}\]  
The matrix \(M\) defines spatial patterns of muscle activation across multiple muscles, or muscle synergies. This matrix is represented as the \(W\) matrix, where \(m\) is the number of muscle EMGs recorded (in this case 8) represented as rows and \(n\) is the number of synergies represented as columns. The values of \(H\) are between 0 and 1 as they are coefficients for normalized data. The matrix \(H\) describes the activation of the muscle contributions (or coefficients) over time, where \(n\) is the number of synergies represented as rows and \(t\) is the duration of each trial in samples represented as columns. The resulting (reconstructed) muscle activation, \(M\), is then predicted. A schematic is shown in Figure 2.  
Figure 2: Schematic showing data processing workflow involving the following: (**a**) muscle synergies (W (left)) and activation coefficients (H (right)) for eight muscle groups; (**b**) optimized muscle synergies (W\({}_{\text{opt}}\) (left)) and corresponding activation coefficients (H\({}_{\text{opt}}\) (right)) for each optimized muscle synergy; and (**c**) normalized average reconstructed muscle activation for rectus femoris (RF), tibialis anterior (TA), bicep femoris (BF), and medial gastrocnemius (MG), right side (red) and left side (blue). Implementing NNMF began with using a search algorithm with MATLAB, starting with a set of muscle synergies (where \(n\) is the number of muscle groups, and the max number of muscle synergies is \(n-1\)). The normalized synergy vectors and the corresponding weight coefficient were estimated using the MATLAB \"nnmf(0)\" function. For example, a schematic for one participant, FW pre-training, is shown in Figure 2. Figure 2a (left) displays muscle synergies represented for linear combination with the activation coefficients (Figure 2a, right) corresponding to each muscle, prior to this iterative approach. An iterative approach, varying between 1 and 7 synergies, was used to determine the appropriate number of muscle synergies to reconstruct the EMG data. The >98% variability accounted for the (VAF) threshold with >90% confidence interval (CI) for each muscle data vector guided the computation to yield the number of optimum muscle synergies, W\({}_{\text{opt}}\), to represent and reconstruct the muscle activation data (Figure 2c). Muscle synergy values at this threshold were deemed valid to reconstruct the data. For the 98% benchmark, for example, three components were considered applicable to reconstruct the data as seen (Figure 2b). In this step, NNMF was further applied to the EMG data and reconstructed with three (optimal) muscle synergies (Figure 2b, left) and activation coefficients (Figure 2b, right). The reconstructed muscle responses are the resulting net activation of each muscle by all the muscle synergies recruited during each movement task (Figure 2c). As an example, a comparison of actual muscle activation and reconstructed muscle activation using 98% VAF is shown in Figure 3. A MATLAB code was generated to compute and plot the muscle synergy data over the average time it took to complete two gait cycles for each group (healthy or stroke) for each walking condition (FW, FT-W, BW, BT-W). Reconstructed synergies were computed for healthy and stroke participants for two gait cycles.