## 2 Materials and Methods
### Data Analysis
#### 2.4.2 Work of Breathing Estimation
The algorithms used in each of the cases, classification of the respiratory muscular pattern and WOB level, are specified. LDA: Linear Discriminant Analysis, SVM: Support Vector Machine, KNN: K-Nearest Neighbor, NN: Neural Network. The stacking algorithm has two levels (see Figure 4), the single classifiers (\(\mathrm{C_{k}}\)) on the first level where the indexes are the inputs (\(\mathrm{F_{n}}\)) and the correct classes are the outputs (\(\mathrm{G_{n}}\)); at this level the single classifiers predict the classes (\(\mathrm{\varphi_{k}}\)), which will be the inputs for the meta-classifier (supervised method) on the second level, where the outputs are also the correct classes [38]. The meta-classifier implemented in this study was a KNN model and the predicted classes (\(\mathrm{\Phi}\)) were compared with the correct classes. Once the hidden layer size was determined for the fourth implemented classification algorithm, NN, one thousand neural networks were tested using a different randomized segmentation for training and validation dataset (80% and 20% respectively). Also, the initial weights were randomized for each one. The best NN was selected based on its relation to training and validation loss function. The accuracy, specificity and sensitivity were calculated for the best algorithms according to [PERSON] et al. [39]. In the case of the WOB level classification, the calculus was as follows:  
_Accuracy:_ number of samples correctly classified/number of total samples  
_Specificity:_ number correctly classified as normal WOB/number of total normal WOB. _Sensitivity (Group 2 only):_ number correctly classified as medium WOB/number of total medium WOB. _Sensitivity (Group 3 only):_ number correctly classified as elevated WOB/number of total elevated WOB. _Sensitivity (Group 2 and Group 3):_ number correctly classified as high WOB/number of total high WOB. \(\bullet\) Modeling to Estimate the WOB  
From previous patient observations [15; 17], our research group state the following hypothesis: \"high work of breathing implies high respiratory muscle activity, differentiating the diaphragm activity from accessory muscles\". Equation (6) is proposed in this article as a model to quantify work of breathing from the muscular activity of two accessory muscles and diaphragm. \[WOB_{e}=\ \frac{\alpha_{1}\times\ MaxAmp\mathrm{Dia}\ +\alpha_{2}\times( MaxAmp\mathrm{Int}\ +\ MaxAmp\mathrm{Strn}\ )}{MaxAmp\mathrm{Dia}\ +\ MaxAmp\mathrm{Int}\ +\ MaxAmp\mathrm{Strn}} \tag{6}\]  
where MaxAmpDia, MaxAmpInt, and MaxAmpStrn are the maximum amplitudes of the surface electromyographic signals of the diaphragm, intercostal and sternocleidomastoid muscles respectively. \(\alpha\)1 and \(\alpha\)2 are coefficients that express the contribution of the main and accessory muscles respectively to achieve the necessary work of an inspiratory cycle. Figure 4: Stacking algorithm representation. In the first level, the features of the sEMG signals enter into the single classifiers (LDA, SVM or KNN); the results of these classifiers are the entry features of the metaclassifier, in this case, a KNN classifier. Surface electromyography is a technique sensitive to size and type of tissue over the muscle, which influences the level of attenuation of the signal [18]. The standardization of Equation (6) by the sum of the maximum amplitudes was done to know the contribution of each muscle to the ventilatory process, reducing the effect of different anatomy structures in the surface electromyography recording. \(\bullet\) Optimization of Model Parameters  
An optimization algorithm based on sequential quadratic programming (SQP) was applied to find \(\alpha_{1}\) and \(\alpha_{2}\) values in each WOB group (G). Equation (7) was the function to be minimized.