Analysis of the Cardiorespiratory Pattern of Patients Undergoing Weaning Using Artificial Intelligence

The optimal extubating moment is still a challenge in clinical practice. Respiratory pattern variability analysis in patients assisted through mechanical ventilation to identify this optimal moment could contribute to this process. This work proposes the analysis of this variability using several time series obtained from the respiratory flow and electrocardiogram signals, applying techniques based on artificial intelligence. 154 patients undergoing the extubating process were classified in three groups: successful group, patients who failed during weaning process, and patients who after extubating failed before 48 hours and need to reintubated. Power Spectral Density and time-frequency domain analysis were applied, computing Discrete Wavelet Transform. A new Q index was proposed to determine the most relevant parameters and the best decomposition level to discriminate between groups. Forward selection and bidirectional techniques were implemented to reduce dimensionality. Linear Discriminant Analysis and Neural Networks methods were implemented to classify these patients. The best results in terms of accuracy were, 84.61 ± 3.1% for successful versus failure groups, 86.90 ± 1.0% for successful versus reintubated groups, and 91.62 ± 4.9% comparing the failure and reintubated groups. Parameters related to Q index and Neural Networks classification presented the best performance in the classification of these patients.


Introduction
Mechanical Ventilation (MV) is a life support treatment in the Intensive Care Unit (ICU), that aims to replace the artificial form of the respiratory system. MV is becoming one of the most important scientific issues in the COVID-19 crisis because patients requiring critical care were mechanical ventilation within 24 hours of admission [1,2]. When a patient is assisted by MV, one of the main objectives of clinical practice is the recovery of spontaneous breathing in the shortest possible time. Around 40% of patients who come to an intensive care unit need mechanical ventilation [3,4], being dramatically increased with the COVID-19 [1,2]. The prolonged use of ventilatory support increases the morbidity and mortality of these patients [5][6][7], the risks of contracting other diseases, and the hospitalization cost. On the other hand, early disconnection of the mechanical ventilator, in addition to being annoying for the patient, can cause cardiopulmonary disorders. According to the literature, following the actual clinical protocols in the disconnection process, up to 25% of these patients suffer respiratory distress severe enough to have to be reintubated [3].
The weaning process of a patient can take more time than it has needed to solve the clinical problem of respiratory failure. This process becomes more difficult when respiratory assistance has been prolonged in time without the need [8]. Therefore, the study signals were recorded between January 2003 and April 2006, in the Intensive Care Units at the Santa Creu i Sant Pau Hospital, Barcelona, Spain, and the Getafe Hospital, Getafe, Spain. All patients were studied in accordance with the corresponding protocols, approved by each clinical research ethics committee (CEIC-HSant-Pau, and CEIC-HGetafe). The ECG signal was recorded using a SpaceLabs Medical monitor. The respiratory flow signal was obtained by a Datex-Ohmeda pneumotachograph (Validyne Model MP45-1-871 variable reluctance transducer), connected to the patient through an endotracheal tube. The signals were recorded at a sampling frequency of 250 Hz. Patients considered clinically viable for weaning underwent the T-tube test, with spontaneous breathing for 30 minutes through the endotracheal tube. According to the clinical criteria, from the weaning test, patients were classified into three groups: successful group (SG) with 94 patients (61 male, 33 female, aged: 65 ± 17 years) who were able to maintain spontaneous breathing after extubating for a minimum of 48 hours; failure group (FG) with 39 patients (24 male, 15 female, aged: 67 ± 15 years) who could not maintain spontaneous breathing during the test and were reconnected again to mechanical ventilation; and re-intubated group (RG) with 21 patients (11 male, 10 female, aged: 68 ± 14 years) that were successful in the T-tube test, but before 48 hours had to be re-intubated and reconnected to the ventilator. Figure 1 presents an excerpt of ECG and respiratory flow signals of a patient for each group in the extubating process. The respiratory flow signal present different levels of variability, according to the clinical condition of each patient. Electrocardiogram (ECG-lead II) and respiratory flow signals of 154 patients under-101 going weaning from mechanical ventilation (WEANDB database) were analyzed [21]. The 102 signals were recorded between January 2003 and April 2006, in the Intensive Care Units 103 at the Santa Creu i Sant Pau Hospital, Barcelona, Spain, and the Getafe Hospital, Getafe, 104 Spain. All patients were studied in accordance with the corresponding protocols, ap-105 proved by each clinical research ethics committee (CEIC-HSant-Pau, and CEIC-HGet-106 afe). The ECG signal was recorded using a SpaceLabs Medical monitor. The respiratory 107 flow signal was obtained by a Datex-Ohmeda pneumotachograph (Validyne Model 108 MP45-1-871 variable reluctance transducer), connected to the patient through an endotra-109 cheal tube. The signals were recorded at a sampling frequency of 250 Hz. Patients consid-110 ered clinically viable for weaning underwent the T-tube test, with spontaneous breathing 111 for 30 minutes through the endotracheal tube. According to the clinical criteria, from the 112 weaning test, patients were classified into three groups: successful group (SG) with 94 113 patients (61 male, 33 female, aged: 65 ± 17 years) who were able to maintain spontaneous 114 breathing after extubating for a minimum of 48 hours; failure group (FG) with 39 patients 115 (24 male, 15 female, aged: 67 ± 15 years) who could not maintain spontaneous breathing 116 during the test and were reconnected again to mechanical ventilation; and re-intubated 117 group (RG) with 21 patients (11 male, 10 female, aged: 68 ± 14 years) that were successful 118 in the T-tube test, but before 48 hours had to be re-intubated and reconnected to the ven-119 tilator. Figure 1 presents an excerpt of ECG and respiratory flow signals of a patient for 120 each group in the extubating process. The respiratory flow signal present different levels 121 of variability, according to the clinical condition of each patient. 122 123 Figure 1. Excerpt of ECG and respiratory flow signals from patients undergoing extubation process 124 of (a, b) a patient from the successful group, (c, d) a patient from the failed group, and (e, f) a patient 125 from the reintubated group. 126

127
ECG and respiratory flow signals were preprocessed to reduce outliers and artifacts, 128 and the linear trends were removed. Time series of these signals were extracted using 129 custom algorithms, based on detection of zero crossing, and maximum and minimum val-130 ues of the events of the signals. To characterize the respiratory pattern, the following time 131 series were obtained from the respiratory flow signal: inspiratory time ( ), expiratory 132 Figure 1. Excerpt of ECG and respiratory flow signals from patients undergoing extubation process of (a,b) a patient from the successful group, (c,d) a patient from the failed group, and (e,f) a patient from the reintubated group.

Preprocessing of Signals
ECG and respiratory flow signals were preprocessed to reduce outliers and artifacts, and the linear trends were removed. Time series of these signals were extracted using custom algorithms, based on detection of zero crossing, and maximum and minimum values of the events of the signals. To characterize the respiratory pattern, the following time series were obtained from the respiratory flow signal: inspiratory time (T I ), expiratory time (T E ), duration of the respiratory cycle (T Tot ), tidal volume (V T ), inspiratory fraction (T I /T Tot ), mean inspired flow (V T /T I ), frequency-tidal volume ratio ( f /V T ), where f is the respiratory rate. In addition, from the ECG signal, the cardiac beat to beat interval (RR) was obtained [15][16][17]. Figures 2 and 3 illustrate an example of T TOT and RR time series of a patient from each group: SG, FG and RG, respectively.
2 Hz, 2.5 Hz and 3 Hz, applying linear interpolation. To determine the best frequency that 140 maintains the spectrum of these new signals, the mean square error (MSE) of the power 141 spectral density (PSD) was compared between the original and the resampled respiratory 142 and cardiac time series. According to the results, a loss of less than 2% was obtained in 143 the MSE at a frequency of 2 Hz for all series, so the cardiac and respiratory time series 144 were resampled to 2 Hz.  To analyze the behavior of the respiratory and cardiorespiratory system at the same 138 time, all these time series were resampled considering frequencies of 0.5 Hz, 1 Hz, 1.5 Hz, 139 2 Hz, 2.5 Hz and 3 Hz, applying linear interpolation. To determine the best frequency that 140 maintains the spectrum of these new signals, the mean square error (MSE) of the power 141 spectral density (PSD) was compared between the original and the resampled respiratory 142 and cardiac time series. According to the results, a loss of less than 2% was obtained in 143 the MSE at a frequency of 2 Hz for all series, so the cardiac and respiratory time series 144 were resampled to 2 Hz. To analyze the behavior of the respiratory and cardiorespiratory system at the same time, all these time series were resampled considering frequencies of 0.5 Hz, 1 Hz, 1.5 Hz, 2 Hz, 2.5 Hz and 3 Hz, applying linear interpolation. To determine the best frequency that maintains the spectrum of these new signals, the mean square error (MSE) of the power spectral density (PSD) was compared between the original and the resampled respiratory and cardiac time series. According to the results, a loss of less than 2% was obtained in the MSE at a frequency of 2 Hz for all series, so the cardiac and respiratory time series were resampled to 2 Hz.

Processing of the Time Series Signals
To characterize the respiratory pattern and its cardiorespiratory interaction through the time series T I , T E , T Tot , V T , T I /T Tot , V T /T I , f /V T , RR, its power spectral density (PSD) was obtained and then calculated each peak amplitude (PA), peak frequency (PF), interquartile range (IQR), and power value (P) at 98%. For each patient, 32 new variables were obtained that make up data set 1 (Dataset1). Figure 4 is a schematic representation of the analyzed dataset.

152
To characterize the respiratory pattern and its cardiorespiratory interaction through 153 the time series , , , , / , / , / , RR, its power spectral density (PSD) 154 was obtained and then calculated each peak amplitude (PA), peak frequency (PF), inter-155 quartile range (IQR), and power value (P) at 98%. For each patient, 32 new variables were 156 obtained that make up data set 1 (Dataset1). Figure 4 is a schematic representation of the 157 analyzed dataset. The continuous Wavelet transform is given by: being the scale factor and the translation in time. The scale factor 1 √ ⁄ normalizes 167 the energy. The scale and position varies continuously over the real domain. For 168 small values of , the Wavelet is contracted over the time, generating information about 169 the details of the signal. For high values of , the Wavelet transform is expanded and 170 illustrates the approximations of the signal. Thus, the scale-frequency relationship can be 171 seen as a conglomerate of cells, where small scales correspond to high frequencies, and 172 high scales correspond to low frequencies. The inverse relationship between time and fre-173 quency causes each of the cells to have the same area and be different from zero. 174 The discrete Wavelet transform (DWT) allows a multiresolution analysis, applying a 175 bank of high-pass G(z) and low-pass H(z) filters in cascade, followed by a sub-sampling 176 stage ( Figure 5). Each pair of filters represents a level of decomposition. The reconstruc-177 tion of the original signal is made from a bank of synthesis filters, introducing zeros be-178 tween the samples of the signal, computed with high-pass G'(z) and low-pass H'(z) filters. 179 This reconstruction process allows the recovery of the original signal if the coefficient is 180 not altered [20]. The approximation coefficients (AC) and detail coefficients (DC) are ob-181 tained from the decomposition stage of the signal implementing the DWT. The 182

Wavelet Transform
The continuous Wavelet transform is given by: being a the scale factor and τ the translation in time. The scale factor 1/ √ a normalizes the energy. The scale a and position τ varies continuously over the real domain. For small values of a, the Wavelet is contracted over the time, generating information about the details of the signal. For high values of a, the Wavelet transform is expanded and illustrates the approximations of the signal. Thus, the scale-frequency relationship can be seen as a conglomerate of cells, where small scales correspond to high frequencies, and high scales correspond to low frequencies. The inverse relationship between time and frequency causes each of the cells to have the same area and be different from zero.
The discrete Wavelet transform (DWT) allows a multiresolution analysis, applying a bank of high-pass G(z) and low-pass H(z) filters in cascade, followed by a sub-sampling stage ( Figure 5). Each pair of filters represents a level of decomposition. The reconstruction of the original signal is made from a bank of synthesis filters, introducing zeros between the samples of the signal, computed with high-pass G'(z) and low-pass H'(z) filters. This reconstruction process allows the recovery of the original signal if the coefficient is not altered [20]. The approximation coefficients (AC) and detail coefficients (DC) are obtained from the decomposition stage of the signal implementing the DWT. The approximations correspond to the low frequency components of the signal, and the details with the high frequency components [20,29]. t. J. Environ. Res. Public Health 2023, 20, x FOR PEER REVIEW approximations correspond to the low frequency components of the signal, a with the high frequency components [20,29].

Extraction of Parameters
In the time-frequency analysis of the signals from the DWT, the follow families were implemented: Daubechies (1:45), Coiflets (1:5), Symlets (1:2 Biorthogonal family the models 1.1, 1.3, 1.5, 2.2, 2.4, 2.6, 2.8, 3.1, 3.3, 3.5, 3. and 6.8. In order to obtain the best mother Wavelet and level, the results o analyzed by comparing the MSE obtained between the original signal an structed one, implementing the maximum level of decomposition allowed b criteria, according to the methodology applied in [29]. Table 1 presents the M Wavelets for each time series of the total of level decomposition. The family nal Wavelets presents the smallest error for each of the analyzed data series. the corresponding Wavelets for each time series, the approximation ( ) an coefficients for each level of decomposition were obtained. For each appro detail coefficient, the mean statistics (X ̅ ), standard deviation (S), skewness (K) and interquartile range (IQR) were obtained. Finally, a total of 640 Wa that characterize the respiratory and cardiac pattern were obtained.

Dimensionality Reduction
To reduce the dimensionality of the data, a novel Q index based on the a of the probability to obtain statistically significant differences (p < 0.05) betw parameters is proposed. The statistical significance of the parameters is obtai

Extraction of Parameters
In the time-frequency analysis of the signals from the DWT, the following Wavelets families were implemented: Daubechies (1:45), Coiflets (1:5), Symlets (1:29) and of the Biorthogonal family the models 1.1, 1.3, 1.5, 2.2, 2.4, 2.6, 2.8, 3.1, 3.3, 3.5, 3.7, 3.9, 4.4, 5.5 and 6.8. In order to obtain the best mother Wavelet and level, the results of these were analyzed by comparing the MSE obtained between the original signal and the reconstructed one, implementing the maximum level of decomposition allowed by the entropy criteria, according to the methodology applied in [29]. Table 1 presents the MSE of the best Wavelets for each time series of the total of level decomposition. The family of biorthogonal Wavelets presents the smallest error for each of the analyzed data series. Implemented the corresponding Wavelets for each time series, the approximation (AC j ) and detail (DC j ) coefficients for each level of decomposition j were obtained. For each approximation and detail coefficient, the mean statistics (X), standard deviation (S), skewness (SK), kurtosis (K) and interquartile range (IQR) were obtained. Finally, a total of 640 Wavelet indices that characterize the respiratory and cardiac pattern were obtained.

Dimensionality Reduction
To reduce the dimensionality of the data, a novel Q index based on the average values of the probability to obtain statistically significant differences (p < 0.05) between different parameters is proposed. The statistical significance of the parameters is obtained applying the Mann-Whitney U Test. For this study, 640 parameters obtained through the discrete wavelet transform have been analyzed. This new index relates the sum of the occurrence probability of each parameter with p < 0.05 with respect to its total occurrence probability and the number of elements used in the comparison. Q index is applied to approximation AC j and detail DC j coefficients of each decomposition level j, respectively, as follows: being n 1 and n 2 the number of patients corresponding to each group compared, respectively. In the dimensionality reduction process, the maximum value of the Q index is selected. This index indicates the best decomposition level and its corresponding approximation or detail coefficients of the time series computed with their corresponding statistics (X, S, SK, K and IQR) values. Table 2 presents the characteristics that obtained the best value of the Q index, when comparing (1) SG vs FG, (2) SG vs RG and (3) FG vs RG, respectively. All these parameters make up data set 2 (Dataset2).

Classifications Techniques
The paper compared two classification systems: neural networks (NN) and linear discriminant analysis (LDA). NN was implemented because it has demonstrated an exceptional learning capability in high dimensionality systems, even with collinear variables, allowing to adjust the parameters to avoid overfitting, improving the bias and variance of the final system. LDA is a very good contrast method as it allows the adjustment of the system hyperparameters by Bayesian methods to increase the performance avoiding system overfitting.

Neural Networks
Neural networks are mathematical models that use learning algorithms inspired by the brain to store information. A pattern is represented by a number of features that form a vector x of dimension d within a space X ∈ Rd. A classifier maps the input space X to a finite set of classes C = {1, ..., l}. An NN is trained to execute a classification task in a set S = {(xµ, tµ), µ = 1, ..., M} using a supervised learning algorithm. The training set S consists of a vector of M features, with x µ ∈ Rd, each tagged to a class t µ ∈ C [30]. Several NN architectures and training algorithms were implemented, and the best results were obtained with a 3-hidden-layer system and one output unit. Logistic and tangential functions were implemented to activate the hidden layer and the output layer respectively. The system was trained using backpropagation method validated through the 4-fold cross-validation technique with 150 runs, this allows an accurate estimation of the error in the test data with a good balance between bias and variance, without the need to increase the computational cost. To analyze the performance of the classification, the mean accuracy of 600 trials was obtained, and to improve its generalization the Bayesian Regularization technique was implemented [30]. The feature selection was carried out applying the wrapper sequential method of elimination of characteristics forward selection and bidirectional search [31][32][33].
Due to the imbalance of the SG, FG and RG groups, the rand resampled methodology [34] was implemented to equalize the classes.

Linear Discriminant Analysis
Let us a problem with two classes C1 and C2 and p variables, with n1 items in C1 and n2 items in C2. X 1 is the average vector of the observed items in C1 and X 2 is the corresponding average vector items in C2 [28]. Let µ 1 and µ 2 identify the means of the population of the predictor variables in each class and let us assume the simplification property that the covariance matrices for both classes are the same i(∑ 1 = ∑ 2 = ∑).
The linear discriminant analysis (LDA) is made explicit by assigning an item X to the C 1 if: where µ i can be approximated by the simple means and ∑ by the simple covariance S calculated as: If S 1 y S 2 are the covariance matrix for each class, we get the Linear Discriminant Function.
In the LDA, the system was trained and validated through the 4-fold cross-validation technique with 150 runs, obtaining the mean of the accuracy of 600 trials as performance measure classification. The feature selection was carried out applying the wrapper sequential method of elimination of characteristics forward selection and bidirectional search [31][32][33]35]. Due to the imbalance of the SG, FG and RG groups, the rand resampled methodology [34] was implemented to equalize the classes.

Results
In this study, the patients from the Weandb database are analyzed considering the following classification:

Successful vs failed patients (SG vs FG), Successful vs reintubated patients (SG vs RG) Failed vs reintubated patients (FG vs RG).
Classification by NN s and LDA, were implemented in conjunction with forward selection and bidirectional search dimensionality reduction techniques [32][33][34][35][36] for the Dataset1 and Dataset2, separately. To perform the classification, 80% of the data were randomly chosen to find the system model, and the remaining 20% of the data were used as test data. The 80% of the data used was validated through the 4-fold crossvalidation technique, where each run the groups were randomized again, generating 600 different models, obtaining the accuracy of the 150 runs implemented. The accuracy was implemented because the clinical interest of importance of the classes is equal, and it is not convenient to give more weight to one class. The multiclass training problem was not performed because of the clinical medical interest of facing the classes in a paired way, to obtain the indexes that allow us to separate the classes that clinically have a greater problem of correct classification, to perform a later study with the relevant variables of the classes faced, to give a physiological explanation and to know more about the etiology of the problem. Tables 3-5 present the parameters with the best accuracy results, in terms of mean ± standard deviation, for each comparison group. For both, Dataset1 and Dataset2, the NN s and LDA classification methods were implemented applying forward selection and bidirectional techniques. Accuracy corresponds to 20% of the remaining data. Table 3. Parameters with the highest accuracy (mean ± standard deviation), when comparing the groups of patients SG vs FG.  From the results it is highlighted, in general, that the highest values of accuracy are achieved with the information of the dataset2, in addition the neural network algorithm presents a higher percentage than the LDA algorithm, these results are because the Q index allows to establish the coefficients of the wavelet transform that have more information, in addition, the processing of the data in the time-frequency domain allows establishing descriptors that characterize the extubating process. In this study we have obtained three reliable models for the prediction of the extubating process. With the model presented in Table 3, it can be determined if the patient should remain connected to mechanical ventilation. If they belong to the SG group, a second diagnosis can be performed with the model in Table 4, since in RG patients there may be information that the SG group does not present. Table 5. Parameters with the highest accuracy (mean ± standard deviation), when comparing the groups of patients FG vs RG.

Discussion
A novel methodology based on the calculation of the PSD and its parameters was implemented, together with the DWT in the cardiorespiratory time series. The new Q index to reduce the dimensionality of the data was applied to the parameters extracted from the DWT and their statistical-spectral. According to the results, the maximum value of Q was obtained with the statistical expressions of parameters such as common CD1-TI between SG vs FG and FG vs RG groups, CD1 − f /V T common between SG vs RG and FG vs RG groups, and CD2-RR, CD4 − T E and CD3 − V T /T I that are common between SG vs RG and FG vs RG groups. Furthermore, parameters related to approximation coefficients of CA7 − f /V T and CA1 − T E , and detail coefficients of CD2 − T I /T Tot , are only in SG vs FG classification group; approximation parameter CA1 − V T is only in SG vs FG classification group; while in the FG vs RG classification group all parameters are related to the other two comparisons. Neural Network method allows modeling complex functions [30] with the Forward Selection and Bidirectional Search techniques allowing a good subset of input features to obtained. Both with the NN s and the LDA classification techniques, a reduced number of parameters with optimal results were obtained, when classifying the three groups of patients. When comparing SG vs RG groups, the bidirectional dimensionality reduction technique presented the highest scores to classify these patients. The parameters X(CD1 − f /V T ) and IQR(CD3 − V T /T I ) presented the best accuracy score, being X(CD1 − f /V T ) the most recurrent in all the bests accuracy results, comparing these groups. The bests results, depending on the accuracies, were obtained by applying the NN s method and Wavelet transform in Dataset1: 84.61 ± 3.1% when comparing SG vs FG groups, 86.90 ± 1.0% when comparing SG vs RG groups, and 91.62 ± 4.9% when comparing FG vs RG groups. The results showed that the most relevant information to differentiate between the groups, is concentrated in the first level of the detail coefficients of the Wavelet Analysis.
Similar studies have been done, but they differ in database and methodology. Kwong et al., [37] conducted a review of the state of the art, identifying the following databases: MIMIC-II, MIMIC-III and MIMIC-IV (publics databases), Weandb (used in this study) and other studies were based on data collected in ICU units based in UK hospitals (adult general ICU of the Sheffield Royal Hallamshire Hospital and neonatal ICU of the Royal Liverpool University Hospital). The most common machine learning algorithms are the neural network, the support vector machine (SVM) and the Adaptive Neuro Fuzzy Inference System (ANFIS); some of the ventilator variables used in these studies are inspiratory time, expiratory time, tidal volume, positive end expiratory pressure, fraction of inspired oxygen, cardiac interbeat duration (RR-interval), oxygen saturation, respiratory rate. Ossai and Wickramasinghe [38], conducted a study aimed at reviewing the efficacy of different techniques in the mechanical ventilation process using machine learning. The main parameters for the classifier design were determined with logistic regression, backward feature selection, and recursive feature elimination; successful weaning results ranged between 44% to 92%. The results of the design of three classifiers are shown in [39]: artificial neural networks, k nearest neighbors and support vector machine (SVM), the input variables to the system are the pressure signal, flow and ventilatory volume, during invasive mechanical ventilation of patients at Hospital San Vicente Fundación; five statistics were determined for each signal: mean, standard deviation, kurtosis, interquartile range, and skewness. The classification system can recognize respiration levels with up to 80% accuracy using the SVM algorithm. A recent study on adult ICU patients is presented in [40], the database included patient demographics, medical records, time series and respiratory events; a comparison was made between three classifiers: logistic discriminant analysis, SVM and gradient boosting method. The best classifier was SVM, which predicts extubation with an accuracy of 94.6%. As future work, it is proposed to study new techniques in the time and frequency domain of WEANDB signals to extract features that serve as input to classifiers based on the theory of convolutional neural networks. In [41], the multi-synchrosqueezing extraction transform (MSSET) method was proposed for the time-frequency analysis of electrocardiogram signals, this method allows higher accuracy in detection of peaks in the spectrum. In [42] the design of a convolutional neural network (CNN) to predict the extubation process is presented. The algorithm is validated with historical data from the MIMIC-III database. The model achieved an accuracy of 86% and an area under the receiver operating curve (AUC-ROC) of 0.94. It is important to incorporate these machine learning techniques into a real-time monitoring system that analyzes ventilatory pattern signals, seeking to reduce the burden on medical staff and clarify the MV decision scenario to which subjects undergo. The results of the classification system are similar, and in some cases, superior to those reported in the literature, with the advantage that the data required by the algorithm correspond to information on the temporal behavior of the cardiorespiratory system, information that can be recorded with biomedical equipment located in an ICU.
Regarding the clinical problem, it is of special interest to study the patients who must be reintubated during weaning process, due to their clinical implications, among others. The behavior of these patients begins by being successful and then ends by being a failure. Consequently, the diagnosis of these patients might require greater knowledge of their conditions. The results suggest the parameter ( f /V T ) as a good indicator to classify the reintubated patients when compared with successful and failed groups. This result agrees with the clinical study carried out in [38], confirming its usefulness in the analysis of the physiological differences between these groups, improving the success rate in the weaning process. With this study, we suggest that detailed coefficients indices from discrete Wavelet transform can contribute to identify and classify weaning patients. We have introduced a novel model that could contribute to stratifying these patients, with the new Q index to identify the best parameters for the classification. The Q parameter can be applied to different biomedical signal classification problems that require analysis in the time-frequency domain because this index indicates the best decomposition level and its corresponding approximation or detail coefficients of the calculated time series, corresponding to the coefficients that make a greater contribution to the energy of the original signal. This study has allowed combined these techniques to describe the cardiorespiratory pattern of these patients, analyzing the interaction between 640 parameters. However, these results should be validated with a greater number of patients, especially in the reintubated group. In addition, other clinical parameters could be included in the model. Finally, the best model has been obtained with the most relevant parameters to classify each group of patients in the weaning process. One limitation of this work is related to the clinical condition and comorbidities of the patients, although there are several factors associated with weaning failure, factors such as respiratory physiological parameters, modes of mechanical ventilation, endocrine and metabolic dysfunction, ICU-acquired weakness or diaphragm dysfunction could not be fully examined in the study, because this was performed retro-spectively, therefore, future prospective multicenter studies of patients undergoing SBT are necessary taking into account the factors related above.

Conclusions
Weaning can be defined as the process by which the work of breathing performed by the MV is gradually transferred to the patient, and the patient resumes spontaneous breathing. Withdrawal of respiratory support is a delicate process, which must be performed promptly to avoid indefinite patient dependence on ventilatory support, decrease morbidity and mortality, and reduce the cost of health care. The article presents the design of a classifier that can be implemented in ICUs when performing a spontaneous breathing test, providing support to the physician when establishing whether a patient can remain connected to a mechanical ventilator. Although artificial intelligence applied in these processes may present a risk of bias due to the availability of data for training the models, its implementation will facilitate the interpretation of the different variables that are recorded during an SBT process. As training data for the proposed algorithm, the information recorded during the 30-minute SBT test was used. It is recommended to carry out a study to establish the best time intervals to determine the characteristics of the respiratory cycle, which will allow establishing indicators to determine whether a patient can be disconnected from a MV. Further, these results can also be analyzed using information from the clinical condition and the correlation with these signals.  Institutional Review Board Statement: All procedures performed in studies involving human participants were in accordance with the ethical standards of the institutional and/or national research committee and with the 1964 Helsinki declaration and its later amendments or comparable ethical standards.

Informed Consent Statement:
The database used in this publication has been used in different scientific publications. This database was recorded between January 2003 and April 2006, with patients from the Intensive Care Department at the Santa Creu i Sant Pau Hospital, Barcelona, Spain and the Getafe Hospital, Getafe, Spain. All patients were studied in accordance with the corresponding protocols, approved by each clinical research ethics committee (CEIC-HSant-Pau, and CEIC-HGetafe). The clinical protocol was directed by Dr. Salvador Benito from the Santa Creu i Sant Pau Hospital (currently retired), a physician responsible for the clinical part and coordinator of the processes carried out in the two hospitals. Furthermore, Dr. Beatriz F. Giraldo (co-author of this manuscript) oversaw and saved the records and processed the signals. All data, clinical information and records, were de-identified and coded.

Data Availability Statement:
The data that support the findings of this study are available from Dr. Beatriz F. Giraldo, but restrictions apply to the availability of these data, which were used under license for the current study, and so are not publicly available. The dataset is not publicly available due to the conditions that were set when the protocol was defined, and the patients were recorded.