1 Introduction

Ventilator-associated pneumonia (VAP) is a common nosocomial infection occurring in ventilator-assisted patients in intensive care units (ICUs). Hospital-acquired pneumonia (HAP) (Self et al. 2013) is a major clinical problem associated with patients subjected to intubation and mechanical ventilation in ICUs (Woodhead et al. 2006; Chastre and Fagon 2002; Morehead and Pinto 2000; Koenig and Truwit 2006). The lower respiratory tract of a normal individual is usually a sterile environment; in intubated and mechanically ventilated patients, the incidence of bacterial infection can be as high as 80% (Fernández-Crehuet et al. 1997). VAP was estimated to account for 20–35% of the total cost burden imposed on hospitals. VAP increases hospitalization costs and may lead to death. Clinical sputum cultures, endotracheal aspirate analysis, and, less frequently, bronchoalveolar lavage are used to diagnose pneumonia; however, these techniques are poor in terms of sensitivity and positive predictive value for diagnosing VAP (Mandell et al. 2007). Reports of the diagnostic sensitivity and specificity of sputum cultures have varied extensively. Furthermore, sputum cultures can be difficult to interpret owing to the upper respiratory tract being colonized by bacteria, in contrast to the lower respiratory tract, which is typically sterile (Campbell and Forbes 2011). Therefore, numerous studies have been conducted on patients with other inflammatory pulmonary diseases, including VAP (Fens et al. 2011; Berkel et al. 2010; Phillips et al. 2010; Bos et al. 2014; van der Schee et al. 2015; Gao et al. 2016; Shafiek et al. 2015).

Exhaled breath contains gas-phase metabolites called volatile organic compounds (VOCs) that are produced by the host and bacteria. Different bacterial strains exhibit distinct patterns of VOCs in vitro and in animal models (Slupsky et al. 2009; Moens et al. 2006; Schöller et al. 1997; Dolch et al. 2012; Shestivska et al. 2012; Thorn et al. 2011). Recently, the breath of patients has been used to detect pneumonia infections (Nayeri et al. 2002; Corradi et al. 2003); the smell from the breath of patients can help detect pneumonia more easily. However, conventional gas-analysis methods require the gas samples to be examined in a laboratory using a gas chromatography–mass spectrometry (GC–MS) analyzer (van den Velde et al. 2008; Zhu et al. 2010). Although GC–MS yields relatively accurate results, it is not suitable for monitoring in daily life because the instruments required are bulky and the procedure is a time-consuming process. Therefore, a device that can rapidly screen for VAP is lacking. Electronic noses (e-noses) are innovative devices for VOC sampling because they facilitate online recognition of complex VOC mixtures. A comparison of the predictive value of e-noses with that of the clinical pulmonary infection score indicated that e-noses could distinguish between infected and uninfected states (Hanson and Thaler 2005). The use of an e-nose to rapidly screen patients for pneumonia is a noninvasive technique that can help in the administering of antibiotic treatment in a timely manner. Therefore, e-noses constitute a suitable alternative for gas identification. An e-nose uses an array of sensors to acquire the specific response pattern of each type of gas and identifies this specific pattern for disease identification (Wilson and Baietto 2011; Pearce et al. 2006; Gardner and Bartlett 1992).

The use of an artificial neural network (ANN) has been proposed in the past (Sadrawi et al. 2015; Liu et al. 2015) as a suitable algorithm for modeling complex nonlinear and nonstationary relationships in medical research. An ANN can also be operated in real time when the weights have been trained and fixed, and it is fault tolerant. A support vector machine (SVM) is another machine learning method that is based on statistical theory (Chapelle and Vapnik 2000); SVMs are used for feature classification and regression. An SVM has many advantages when solving for a small number of samples; moreover, it can solve nonlinear and high-dimensional pattern recognition problems, and it is easy to use and implement in a real system owing to its simplicity (Gold and Sollich 2003; Anguita et al. 2003; Mustafa et al. 2009).

Herein, we propose the installation of a gas detection system in a ventilator to monitor and detect metabolites of pneumonia at an early stage. Unlike in our previous study (Liao et al. 2019), where we used equipment manufactured by Sensigent (i.e., Cyranose 320) to design a detection system through Matlab, in the present study, we independently designed our e-nose system. Specifically, we designed the sensor board, embedded hardware, and Android software for the system. Our data suggest that VOCs in exhaled breath can be used to discriminate intubated and mechanically ventilated patients with Hospital-acquired pneumonia (HAP) from ventilated patients without pneumonia in ICUs with high accuracy.

2 Materials and methods

The e-nose system designed in this study includes a sensor array panel with an air chamber and an e-nose circuit panel, in addition to have data collection, gas detection, and machine learning modules.

2.1 Sensor array panel

The sensor array is a key component of the e-nose system; it consists of 28 sensors. Table 1 lists the sensor manufacturer, target gas, and detection range. All 28 sensors are of the metal oxide semiconductor (MOS) type, such as TGS2600, TGS2602, TGS2603, TGS2610-C00, TGS2610-D00, TGS2611-C00, TGS2611-D00, TGS2612-D00, TGS2620, TGS3870, TGS2444, and TGS8100. MOS-type sensors have a simple structure, long life cycle, and low manufacturing cost; moreover, they are easy to miniaturize and are highly responsive. MOS-type sensors are composed of reactive materials such as Tin oxide (SnO2), Zinc peroxide (ZnO2) (Ji et al. 2010; Young et al. 2014; Liu et al. 2014; Chen et al. 2013), Tungsten trioxide (WO3), Palladium (Pd), Carbon nanotube (CNT) (Young and Lin 2018) as a substrate and noble metals such as platinum, gold, tungsten, or palladium as a catalyst (Lin et al. 2015). The catalyst shortens the response time of the sensor to the chemical reaction equilibrium and expedites the response of the sensor.

Table 1 Specifications of the 28 sensors

2.2 E-nose circuit panel

Figure 1a shows the location of the 28 sensors (S1–S28) in a chamber sensor designed to enclose sensors of the same type. Figure 1b shows the block diagram of the sensor module comprising AD5144 analog potentiometers. The AD5144 potentiometers control by Inter-Integrated Circuit (I2C) bus and provide a nonvolatile solution for 256-position adjustment applications, and their resistance ranges from 10 to 100 kΩ; they ensure low resistor tolerance errors of ± 8%. The circuit controls the sensor resistance load and maintains the analog to digital converter (ADC) sampling voltage base in half maximum range to preserve each sensor’s resistor as well as quality and health for long-term use. The central processing Unit (CPU) used is Freescale i.MX6, which has a single core running up to 1.0 GHz with 512 kB of L2 cache and 32-bit double data rate 3 (DDR3) with synchronous dynamic random access memory (SDRAM) support. Furthermore, it can integrate low voltage differential signaling (LVDS), a mobile industry processor interface (MIPI) display, MIPI camera port, and high definition multimedia interface (HDMI) v1.4.

Fig. 1
figure 1

E-Nose circuit panel block diagram a Sensor placement, b Sensor module block diagram

The hardware framework of the e-nose system includes a valve, pump, gas chamber, temperature humidity control, sensor array, CPU mainboard, and control circuit (Fig. 2). The solenoid valve controls the inlet gas path and the pump initiates the gas flow, which is monitored using a flow sensor to monitor the flow ratio. A flow sensor from Sensirion is used to monitor the inlet gas operation in normal digital output. This facilitates long-term stability and precision even when the flow rate is slow. Furthermore, the gas chamber includes a sensor board that consists of 28 sensors and a potentiometer to attenuate the sensor output voltage and monitor the sensor resistance status. A high-precision 16-bit sigma–delta ADC with a low-noise programmable gain amplifier is used. The ADC includes TI LMP90080, which is a highly integrated multichannel, low-power 16-bit sensor analog front end chip. Finally, the e-nose system must be calibrated before use. The calibration procedure can be performed using standard gases, such as carbon monoxide gas or ethanol gas, to obtain the sensor array response curve. If this curve is within the tolerance range, the e-nose system can be used. However, the pump flow rate, temperature, and humidity of the chamber of the e-nose system are still needed to calibrate in regular intervals to make sure every parts of e-nose system within accurate values. Furthermore, even after the e-nose system is in use, we must still ensure that the pump flow rate, temperature, and humidity of the chamber are within a certain range, which can serve as a control system.

Fig. 2
figure 2

Framework of e-nose system hardware

2.3 Breath samples and collection method

The single inclusion criterion for the patients to be part of the study was that they had to be on mechanical ventilation for more than 24 h Cardiopulmonary surgery patients and patients who previously received mechanical ventilation during the same hospitalization were excluded. The exhaled gas was sampled within 24 h after the patient was admitted into the ICU. The sampling method is illustrated in Fig. 3.

Fig. 3
figure 3

Setup for collecting exhaled breath samples from VAP patients

In this study, the bacterium Pseudomonas aeruginosa (P. aeruginosa) was collected in a sterile vacuum bottle connected to a respirator. The e-nose system equipped with 28 sensor arrays was then used offline to screen the patterns of respiratory gases in the sterile bottle, as shown in Fig. 4.

Fig. 4
figure 4

Setup for e-Nose breath sample reading

The sampling equipment was approved by Taiwan Food and Drug Administration (TFDA) product code 001903. The sterile bottle was provided by Xindong Co., Ltd., and the medical equipment intravenous (IV) set was used to connect the two sides. The sterile vacuum bottle was connected to the other side of the respirator. To ensure patient safety, the sampling process was performed by a medical professional and the sampling time was limited to 10 s.

Data were collected from selected patients with VAP infection and those without infection. The present research received approval from the Institutional Review Board at Taipei Medical University Hospital (TMUH), Taiwan. Written informed consent was obtained from the 40 patients participating in the study. Of the 40 patients, 20 contracted pneumonia at TMUH and the remaining did not have pneumonia (Table 2). Patients in the ICU are usually those that have undergone neurosurgery without any evidence of infection or lung disease. Raw data of 120 samples per patient were collected to obtain 4800 raw data points. To avoid bacterial variation caused by treatment implementation, respiratory gases from patients not injected with antibiotics were collected to constitute an experimental database.

Table 2 Patients with infection P. aeruginosa and without infection

2.4 Detection process

Figure 5 shows the architecture of the e-nose system. The system architecture shows the overall system flow in relation to external auxiliary systems.

Fig. 5
figure 5

System architecture

The detection process is automatically controlled by the e-nose system. Figure 6 shows the timing sequence of the motor solenoid valve and sensor control. The detection procedure is divided into four phases, each defined as a flag:

Fig. 6
figure 6

Timing sequence of motor solenoid valve and sensor control

  • Flag 0—Baseline phase (600 s): Each sensor baseline is recorded, which is used in data analysis.

  • Flag 1—Breath gas injection phase (30 s): The pump is turned on. A breath gas sample is drawn from the airbag to the air chamber at constant speed. The sensor signal begins to respond to the injected target expiratory gas.

  • Flag 2—Sensor reaction phase (30 s): The pump is turned off. The sensor continues to react with components in the breath gas. The response of the MOS sensor reaches its maximum value.

  • Flag 3—Cleaning phase (600 s): The pump is turned on again and draws clean air into the air chamber for 600 s. The sensor response gradually returns to the baseline. After the response becomes stable, the device is ready to measure the next sample.

The responses of the sensors (S1–S28) in the four phases are illustrated in Fig. 7. The response remains stable during the baseline phase (Flag 0) and changes during the injection phases (i.e., Flags 1 & 2). Each sensor reaches its maximum response at least once during the sensor reaction phase (Flag 2). Finally, during the purge phase (Flag 3), the sensor response gradually returns to the baseline when clean air is injected into the chamber. After the entire process, the digitized breath sample is represented by 28 response curves. Each response curve has 120 data points. The data samples are then used for further analysis.

Fig. 7
figure 7

Response curves of 28 sensors

2.5 Machine learning methods

2.5.1 SVM architecture

The SVM technique was introduced by Vapnik, and in recent years, it has been further developed. Several studies have reported that an SVM is usually able to achieve higher classification accuracy than other existing classification algorithms. In the past decade, the SVM has emerged as an important learning technique for solving classification and regression problems in various fields. A novel kernel function called the radial basis polynomial kernel (RBPK), which combines the characteristics of the radial basis function (RBF) kernel and the polynomial kernel, is defined as

$$ K(x_{i} x_{j} ) = \exp \left( {\frac{{\left| {x_{i} x_{j} + c} \right|^d}}{{\sigma^{2} }}} \right)\quad {\text{where}}\;c\; > \;0,\;d\; > \;0 $$
(1)

The RBPK function has good predictive ability from the polynomial kernel function and good learning ability from the RBF kernel function.

2.5.2 ANN architecture

The ANN algorithm is a machine learning algorithm that mimics human neural networks, and it is used for prediction, clustering, and pattern recognition based on past and current training data. An ANN allows for the inclusion of a large number of variables, and each variable can be assigned a different weight to produce an output that is very close to the predicted result. A typical classification network consists of an input layer, a hidden layer, and an output layer. In addition, the data are usually divided into training, validation, and testing sets. In previous studies (Liu et al. 2015), nonlinear and nonstationary medical data have been used with a backpropagation network having four layers: an input layer, two hidden layers with 17 and 10 neuron nodes each, and an output layer. Recently, deep learning has been extended to contain more layers; for example, CifarNet contains 5 layers, AlexNet contains 8 layers, and VGGNet contains 15–19 layers (Liu et al. 2019). For our study, since the dataset was of only 40 patients, we selected only four layers: an input layer, two hidden layers with 30 neuron nodes each, and an output layer.

2.5.3 Evaluating the predictive performance of machine learning methods

The receiver operating characteristic (ROC) curve analysis is a statistical method that has been widely used in medical diagnosis for evaluating the performance of classifiers (Ottenbacher et al. 2001; Yeh et al. 2009). Furthermore, the area under the ROC curve (AUC) is the main performance index of a classification system. An AUC of 1.0 typically implies perfect discrimination; however, this is an ideal case and would not occur in the real world. An AUC of 0.5 is equivalent to a random model. An AUC of less than 0.5 implies that an alternative method would be required to build the model, as it would mean that the classifier does not fit the real situation. Therefore, in this study, the ROC curve and AUC analysis were used to evaluate the predictive performance of the machine learning methods (i.e., the SVM and ANN). Moreover, the sensitivity (SEN), accuracy (ACC), and positive predictive value (PPV) of the methods were calculated using Eqs. (2)–(4) as follows:

$$ SEN = \frac{TP}{TP + FN} , $$
(2)
$$ ACC = \frac{TP + TN}{TP + FP + TN + FN}, $$
(3)
$$ PPV = \frac{TP}{TP + FP} $$
(4)

where TP is a true positive classification, FN is a false negative classification, TN is a true negative classification, and FP is a false positive classification.

3 Data analysis and results

3.1 Data preprocessing

Data preprocessing has a major effect on the performance of e-nose systems. A good signal preprocessing method not only reduces noise but also reduces recognition complexity and errors, thereby improving system identification performance. Accordingly, in this study, we implemented a hardware first-order low-pass RC filter. A nonlinear log–sigmoid activation function was used, which is defined in Eq. (5), where a is the output of the nonlinear log–sigmoid function and n is the input of the nonlinear activation function. The training and testing data are normalized in the range of 0–1

$$ a = f(n) = \frac{1}{{1 + e^{ - n} }} . $$
(5)

3.2 Predictive ability of ANN and SVM ROC models

The concept of cross-validation is to generate k-fold cross-validations of equal size. One data fold is used as the validation set, and the other folds are used for training to generate a neural network model. This process is repeated k times, and for each repetition, the validation sets are selected from the k-fold; the sets are never used twice. This process generates a k number of neural networks that are averaged to generate the final prediction.

To estimate the generalized prediction abilities of the ANN model, testing data were applied to the model, and the outputs were used to generate the ROC curve. Table 3 summarizes the ROC curve analysis results for the ANN and SVM models. To evaluate the performance of the models, we employed fivefold cross-validation. The results revealed that the ANN model had good VAP recognition rates, and the average ACC, SEN, and PPV values were 0.8547 ± 0.0214 (mean ± SD), 0.6779 ± 0.1133, and 0.6408 ± 0.1583, respectively. The results also showed that the SVM model exhibited high VAP recognition rates, and the average ACC, SEN, and PPV values were 0.9208 ± 0.0302, 0.8439 ± 0.0303, and 0.8145 ± 0.0660, respectively. Therefore, the SVM model performed better than the ANN model in terms of detecting VAP. The optimized SVM model shown in Fig. 8 was established with the ideal combination of parameters of C = 10, σ = 0.001, to achieve better performance in VAP detection.

Table 3 ROC curve analysis results by test dataset for ANN and SVM models
Fig. 8
figure 8

SVM search results for choosing the best parameters

The ROC curves (Fig. 9) for the ANN and SVM models were analyzed. The average AUC obtained from fivefold cross-validation tests for the ANN model was 0.868 ± 0.04868 (mean ± SD). In addition, the average AUC obtained from fivefold cross-validation tests for the SVM model was 0.926 ± 0.0167. The high mean values and the low SD values of SVM model confirm the uniformity and reliability of the results.

Fig. 9
figure 9

ANN and SVM average ROC curve

4 Discussion

In this study, an e-nose system consisting of 28 gas sensors was developed and tested on 40 patients. Our experience of each type of sensor consists of at least 3 sensors which could get good stability and performance. Furthermore, sensors need filter to use target gas to screen and define sensor quality. Moreover, each sensor module needs aging over 168 h to ensure stability.

The proposed system has a high degree of automation, has a relatively low environmental impact, has low artificial effects, improves the repeatability and reliability of tests, and can be integrated with or customized for various test methods to meet different needs. In addition, the advancement of system software functions along with improvements in identification technology will improve the performance of the system.

5 Conclusion

In this study, machine learning was used to predict whether patients were infected with major bacteria P. aeruginosa in the ICU. The ANN and SVM models were trained and tested separately. ROC curve analysis showed that the ANN and SVM models had a high pneumonia identification rate. The SVM model was more accurate than the ANN model. Because only 40 patients were included in this study, the ANN model may not have had sufficient data for training. If we were to include more data in the future, the ANN model would outperform the SVM model because the nonlinear mapping for the ANN is higher than that for the SVM. The designed system utilizes a low-cost microarray e-nose that is easy to install into a mechanical ventilation system in the ICU to facilitate the collection of breath samples from VAP patients. In the future, data collected from multiple hospitals can be tested not only with the traditional ANN (or shallow learning) but also with deep learning (e.g., convolutional neural networks) (Esteva et al. 2017; Rajpurkar et al. 2017; De Fauw et al. 2018), which can be applied to VAP detection systems.