# Detecting Fatigue during Exoskeleton-Assisted Trunk Flexion Tasks: A Machine Learning Approach
## 2 Materials and Methods
### Data Pre-Processing and Feature Engineering  
The Nexus 1.7.1 (VICON, Hauppauge, NY, USA) software was used to export data from each sensor/marker of the EMG, Force Plate, and motion capture systems in a single (.csv) file that represented 30 cycles of repetitive bending. We developed a custom MATLAB code to import data from the excel file. Data obtained from the force plate and the motion capture system will be filtered using a second-order lowpass digital Butterworth filter with a normalized cutoff frequency of 10 Hz. Meanwhile, the EMG was filtered using a Butterworth filter in the 30 Hz and 300 Hz band [62; 63]. To evaluate variations across the bending/retraction cycles, we segmented the activity using the position in the z direction of the upper back marker by detecting bending start/end and retraction start/end portions. To ensure consistency, the middle 40% of the range of movement, scaled from 0-1, was selected as shown in Figure 2. Each repetitive bending task was divided into 30 distinct bending (BD), retraction (RT), and transition (TS) portions. The TS portion was defined as the spatial movement from the detected end of bending to the detected start of retraction, which represents the portion where participants switched from bending to retraction.  
After segmenting the repetitive bending cycles into distinct portions based on spatial location of the trunk, we calculated measures from the EMG, force plate, and motion data. As the raw EMG data cannot be directly used for processing, correlation, or comparison, we calculated the Root-Mean-Square (RMS) of the signal. Using the RMS, we determined peak amplitude of muscle activity in each of the four muscle groups (LES, RES, LBF, and RBF) for each portion (bending/transition/retraction) of each trunk flexion cycle. Normalization was performed using peak values for each EMG sensor on the back and legs obtained from MVC trials. Time-series data were converted to the frequency domain using the Fast Fourier transform (FFT) to calculate the median frequency of the signal. Values for the first trunk flexion cycle were taken as a reference to calculate change in normalized peak amplitude and median frequency for each subsequent trunk flexion cycle. This led to a total of 48 features that represented muscle activity.  
For the trunk movement measure, a total of 54 features were extracted from 3 trunk markers located on the center of upper back, lower back, and hip. First, the norm of velocity and acceleration was calculated based on position of each of the three markers. Using the segmented portions, maximum, mean, and variance were calculated for both norm of velocity and acceleration for each portion of each trunk flexion cycle. Lastly, stability measures included features extracted from the Ground Reaction Forces (GRF) and Center of Pressure (COP) location. Specifically, exported files from the VICON Nexus software included COP locations and GRF for each of the two force plates, as well as combined COP and GRF values. Using COP coordinates, we calculated the maximum deviation from the mean values over each portion of each trunk flexion cycle, as well as velocity (based on position data in the horizontal plane). Mean, peak, standard deviation, and variation in the velocity of COP and GRF were then calculated per portion of each of the 30 cycles for all trials performed by all study participants. Obtained results for all three measures were exported as a separate Excel (csv) file with each column representing a feature, and rows representing each trunk flexion cycle. Table 2 shows the total number of features extracted from measures of trunk movement, muscle activity, and whole-body stability.  
Figure 2: Schematic showing segmentation of each bending and retraction cycle from the upper back marker during 30 cycles of a repetitive trunk flexion task based on type of spatial activity categorized as bending, retraction, or transition movement.