1 Introduction

The weaning process is used to discontinue the use of mechanical ventilators (MVs) for patients with respiratory distress in intensive care units (ICUs). It depends on the strength of patient’s respiratory systems [1]. Twenty percent of ventilated patients will fail at their first attempt at weaning [2, 3]. Thus, the patients must spend more time in ICU before they can be weaned off MVs. Prolonged MV use may cause some complications such as infection, pneumonia, and barotraumas [4,5,6,7,8,9,10]. However, if the clinicians cannot predict the right time to start weaning, the patients may need reintubation, and this failure may increase the percentage of morbidity and mortality [4, 11,12,13]. Many researchers have attempted to reduce the duration of MV use. The studies on the ventilator-weaning process have proposed reducing the weaning times via their defined protocols rather than the usual intensive care protocols [14,15,16,17,18,19].

There are three weaning predictors commonly described in published literature. These are the rapid shallow breathing index (RSBI), the pressure time index (PTI), and the Jabour weaning index (JWI) [19]. Owing to its ease of calculation, RSBI is widely used in ICUs. Over a period of 1-min spontaneous breathing by the patient, RSBI calculates the ratio of frequency to tidal volume. If this value is below the threshold of 100 (breaths per/min)/L, RSBI predicts weaning success with an accuracy of up to 97% [20]. However, prolonged MV decreases the sensitivity of RSBI, and the state of the disease influences its specificity [21]. The other predictors used in the weaning process require more detailed respiratory parameters, and so, they are not preferred by the staff of an ICU.

It is known that if physicians decide the weaning from MV, the success of weaning is only 35–60% [22]. Some researchers developed their predictor algorithms to increase weaning success above predictors described in published literature. Nemoto et al. implemented a process to wean patients’ off ventilator with fuzzy logic by using parameters such as heart rate, tidal volume, breathing rate, and the percentage of oxygen saturation of arterial blood (SaO2) [23]. They tested their developed algorithm on 13 patients with severe chronic obstructive pulmonary disease (COPD). They compared their algorithm with the decisions made by a physician. Hsu et al. developed a clinical decision support system by using a support vector machine (SVM) to predict the right weaning time [24]. In their study, frequency to tidal volume ratio, inspiratory tidal volume, expiratory tidal volume, and respiration rate were used to determine the weaning time. Kilic and Kilic developed a fuzzy decision support system for weaning off mechanical ventilators; their fuzzy input variables were hemoglobin, mean arterial pressure, arterial oxygen saturation, arterial CO2 partial pressure (PCO2), arterial pH, fractional inspired oxygen (FiO2), negative inspiratory pressure, and tidal volume of spontaneous ventilation. They compared its results against weaning predictors found in published literature [25].

As can be seen, the developed algorithms and protocols in literature have generally ignored some parameters such as hemodynamic stability and the psychological status of patients. It is not possible to start weaning without evaluating these parameters. The predictors used in the literature are based on mathematical formulas. However, it is known that weaning process requires human experience and knowledge instead of certain mathematical formulas. Thus, there is no weaning protocol broadly accepted by everyone. Fuzzy logic which is an expert knowledge-based system is more suitable to determine weaning process. In this paper, the goal is to develop a new knowledge-based weaning algorithm that eliminates the disadvantages of the current predictors. Twenty clinical scenarios were generated using Monte Carlo simulations and Gaussian distribution methods to test the performance of the developed algorithm. The developed knowledge-based algorithm and RSBI predictor were applied to the generated scenarios. In addition, a clinician evaluated each generated scenario independently according to the 16 parameters generated. The Studentʼs t test was used to show statistical differences between these results. According to the results obtained, there is no statistical difference for a 96.1% probability between the proposed methods and the clinician’s evaluation. However, there is a statistical difference at a probability of 25.2% between the proposed methods and RSBI and a statistical difference at a probability of 30.6% between the clinician’s evaluation and RSBI.

2 Methods

The system designed contains 16 parameters, which are easy to collect in practice, and use them to evaluate acid–base balance, adequate oxygenation, adequate pulmonary function, hemodynamic stability, and psychological status for weaning. Here, a knowledge-based weaning algorithm was designed using Fuzzy-LabVIEW software for decision making when weaning patients off MVs. To test and show effectiveness of the algorithm, clinical scenarios were generated using Monte Carlo simulations and Gaussian distribution methods for 16 vital parameters. These parameters are pH, carbon dioxide partial pressure (PaCO2), oxygen saturation (SpO2), PaO2/FiO2, PEEP, the oxygen saturation (SaO2), hemoglobin (Hb), maximum inspiratory pressure (MIP), tidal volume in spontaneous breathing (TVS), respiratory minute volume (VE), heart rate, the respiratory rate per minute (RPM), body temperature, mean arterial blood pressure (MAP), glasgow coma scale (GCS), and sleep level. Fuzzy logic-based algorithms were designed to predict weaning probability, and the performance of the algorithm was tested using a Monte Carlo simulation in which random values for fuzzy inputs were taken from Gaussian distributions [26]. The Gaussian distribution equations used in this algorithm are given in eqs. 1, 2 and 3,

$$ f\left(x;\mu; {\sigma}^2\right)=\frac{1}{\upsigma \sqrt{2\uppi}}\ast {e}^{\frac{-{\left(x-\mu \right)}^2}{2{\sigma}^2}} $$
(1)
$$ z=\frac{\mathrm{x}-\upmu}{\sigma } $$
(2)
$$ \mathrm{x}=z\sigma +\upmu $$
(3)

where x is the new data, z is the standard normal distribution, μ is the mean value, σ2 is the variance random value, and σ is the standard deviation. The fuzzy system development was designed in LabVIEW software. The reason for preferring the LabVIEW program is its graphic-based structure and the ease with which a user can interface to it. The schematic outline of the developed algorithm is given in Fig. 1.

Fig. 1
figure 1

The schematic outline of the developed algorithm

2.1 Acid–base balance

In the developed algorithm, pH, PaCO2, and SpO2 were used to determine the acid–base balance for patients. The input membership functions of PaCO2, SpO2, and pH are shown in Fig. 2. Twelve rules were created for the acid–base balance. The membership function and histogram for the acid–base balance are given in Fig. 3.

Fig. 2
figure 2

The membership function for PaCO2, pH, and SpO2

Fig. 3
figure 3

The output membership function for acid–base balance, and histogram of acid–base balance

2.2 Adequate oxygenation

The four parameters of PaO2/FiO2, PEEP, SaO2, and Hb were used to determine the oxygenation levels of patients. The input membership functions for PaO2/FiO2 rate, PEEP, SaO2, and Hb are illustrated in Fig. 4, and Fig. 5 shows the output for adequate oxygenation and a system histogram.

Fig. 4
figure 4

The membership function for PaO2/FiO2, PEEP, SaO2, and Hb

Fig. 5
figure 5

The output membership function for adequate oxygenation and histogram of adequate oxygenation

2.3 Adequate pulmonary function

MIP, TVS, and VE parameters were chosen as fuzzy inputs for adequate pulmonary function. The membership functions for input are shown in Fig. 6, and the output membership function and system histogram are given in Fig. 7.

Fig. 6
figure 6

The membership function for MIP, TVS, and VE

Fig. 7
figure 7

The output membership function for adequate pulmonary function and histogram of adequate pulmonary function

2.4 Hemodynamic stability

Heart rate, RPM, body temperature, and MAP were used to determine hemodynamic stability in the developed system. The membership functions of these four parameters are illustrated in Fig. 8, and membership function of hemodynamic stability and system histogram is shown in Fig. 9.

Fig. 8
figure 8

The membership function for heart rate, RPM, body temperature, and MAP

Fig. 9
figure 9

The output membership function for hemodynamic stability and histogram of hemodynamic stability

2.5 Psychological status of patient

The GCS and sleep level for the patient were chosen to determine the patient’s psychological status. The input membership functions for GCS and sleep level of the patient and the output membership function and system histogram are shown in Fig. 10.

Fig. 10
figure 10

The membership function for GCS and sleep level of patient and the output membership function for for psychological status of patient. b Histogram of psychological status of patient

2.6 Blood gas level and body function

Acid–base balance and adequate oxygenation were chosen to determine blood gas level percentage of the patient, and adequate pulmonary function and hemodynamic stability were used to evaluate body function percentage. Figure 11 shows the output membership function for blood gas levels and the output membership for body function.

Fig. 11
figure 11

a The output membership function for blood gas level. b The output membership function for body function

The developed algorithm description involves many block diagrams and front panels. Some of these front panels and block diagrams are shown in Figs. 12, 13, 14, and 15.

Fig. 12
figure 12

The developed front panel for acid–base balance

Fig. 13
figure 13

The developed final front panel of the system

Fig. 14
figure 14

The developed fuzzy systems for adequate oxygenation

Fig. 15
figure 15

The developed fuzzy systems for weaning probability

Sixteen parameters are used to estimate the percentage probability for weaning of patients. Some of these parameters have been grouped together in the developed system; otherwise, the fuzzy system would have nearly 300,000 rules. Such unmanageable rule tables could not possibly be generated by an expert clinician. In the developed system, the numbers of total rules generated are 135. Grouping some related parameters together decreases the huge rule tables for the system. The final rule table for the weaning probability for a patient is given in Table 1. In the system, all the rules are created by an expert clinician.

Table 1 The final rule table for weaning probability of patient

3 Results

Twenty clinical scenarios were randomly generated using Monte Carlo simulations and Gaussian distribution methods to test the weaning probability. Each clinical scenario represented a patient in the system. Sixteen vital parameters for each scenario were used to make a decision about weaning in the developed predictor. The weaning probabilities obtained, RSBI results, and the percentages obtained from the clinician’s evaluations for each scenario are given in Table 2.

Table 2 The obtained results from the developed algorithm and clinician’s evaluation

Figure 16 shows box and whisker plots for the developed algorithm, RSBI, and the clinician’s evaluation. In this figure, it can be shown that the developed algorithm performs better than the RSBI predictor’s results in terms of the median value and the upper and lower ends of the boxes. In addition, the developed algorithm produces results that are very close to the clinician’s evaluation according to the generated scenario.

Fig. 16
figure 16

Box-and-whisker plots of the developed algorithm, RSBI, and clinician’s evaluation

The results show that the developed algorithm gave a different decision than RSBI for the 3rd, 6th, 7th, 11th, 13th, and 19th scenarios. In these scenarios, when the algorithm developed and clinician decided to start weaning process, it was not possible to wean the patient from MV according to the RSBI results. The developed algorithm’s results and the clinician’s evaluation were the same for those scenarios. The Student’s t test for p < 0.05 was applied to the percentage of weaning probability obtained, the RSBI result, and the percentage from clinician’s evaluation. The Student’s t test was used to determine statistical difference because it assesses whether the means of the three groups are statistically different from each other. This test is appropriate whenever a person wants to compare the means of two or more groups [27,28,29]. Equations 4, 5, and 6 were used to calculate the statistical difference.

$$ \overline{X}=\frac{\sum x}{n} $$
(4)
$$ {s}^2=\frac{\sum {\left(x-\overline{x}\right)}^2}{n-1} $$
(5)
$$ t=\frac{\left(\overline{x_1}-\overline{x_2}\right)}{\sqrt{\frac{s_1^2}{n_1-1}+\frac{s_2^2}{n_2-1}}} $$
(6)

where \( \overset{-}{x} \) is the arithmetic mean, S 2 is the variance, t is the test formula, x is the investigated group, and n is the number of data points in the group. According to the results from the t test, there is no statistical difference for 96.1% probability between the percentage of developed algorithm results and evaluations by the clinician. In addition, there are statistical differences at 25.2 and 30.6% between the percentages of the developed algorithm results and the RSBI results and between the RSBI results and the percentages from the clinician’s evaluation, respectively.

4 Discussion

In ICUs, clinicians try to promptly withdraw ventilator support when patients no longer need this support. This decreases complications, costs, and prolonged mechanical ventilation. Thus, many studies about weaning prediction algorithms and protocols have been carried out. Currently, there are many weaning protocols such as RSBI, PTI, and JWI. RSBI is a widely used protocol for weaning patients off MVs. Since these algorithms and protocols have generally ignored some parameters such as hemodynamic stability and the psychological status of patients, there is no weaning protocol broadly accepted by everyone. In this study, all the individual parameters used in literature were taken into account to estimate the weaning probability percentage for patients. Sixteen vital parameters were used to determine the weaning decision in the fuzzy systems. Since there were so many parameters used in this study, related parameters were grouped together to decrease the numbers of rule tables in the fuzzy system. Three parameters, pH, carbon dioxide partial pressure (PaCO2), and oxygen saturation (SpO2), were used to determine acid–base balance percentage. Four other parameters were used to determine the percentage for adequate oxygenation. These parameters were PaO2/FiO2 rate, the oxygen saturation (SaO2), the hemoglobin (Hb), and the positive end-expiratory pressure (PEEP). The three parameters, maximum inspiratory pressure (MIP), tidal volume in spontaneous breathing (TVS), and respiratory minute volume (VE), were used to determine the percentage required for adequate pulmonary function. In addition, heart rate, the respiratory rate per minute (RPM), the body temperature, and MAP were used to determine the percentage of hemodynamic stability. The Glasgow Coma Scale (GCS) and sleep level were used to evaluate a percentage for the psychological status of the patients. After this calculation, the acid–base balance and oxygenation determined the blood gas level. Adequate pulmonary function and hemodynamic stability were used to determine the level of body function. Then, the blood gas level, the level of body function, and psychological status of patients were used to determine the percentage probability to commence weaning. The all algorithms were implemented in LabVIEW software. In this study, the generated clinical scenarios were firstly applied to the developed algorithm and RSBI, and then, a clinician determined the weaning probability percentage for patients according to each scenario. According to the results obtained, the developed algorithm and the clinician’s evaluation gave nearly identical results, but RSBI failed to accurately estimate the weaning probability. The results show valuable proof of concept for the role of fuzzy logic in the management of the weaning process.

5 Conclusion

The weaning process is an important issue for patients and clinicians. If clinicians do not start the weaning process at the right time, it may result in prolonged mechanical ventilation, and it may cause some complications including infection, pneumonia, and barotraumas. Thus, the knowledge-based weaning process can determine the right time to start weaning, and it can be said that the developed algorithm may create a future research-driven protocol for weaning patients off the ventilators.