Self Adaptive Fuzzy Controller for Supplementary Oxygen Supply to the Respiratory Distress Patients

In this paper, respiratory irregularities of humans are investigated, and a self Adaptive Fuzzy Logic-based Proportional plus Derivative Controller (AFLPDC) is designed to provide a controlled supply of oxygen to the patient, suffering from breathlessness. The Fuzzy Logic-based Proportional plus Derivative Controller (FLPDC) is tuned, by implementing an adaptive scheme, which provides desired control action according to the process parameter variations. The electrical equivalent model of the respiratory system is developed, and the model is validated with the help of a Spirometer and MATLAB System Identification Toolbox. To build up this model, the respiratory tract is well thought out into four sections: the nasal cavity, trachea, bronchi, and finally, the alveolar sacs. Each of these sections is represented as a series of combinations of Resistance, Inductance, and Compliance. The control capability of the proposed AFLPDC is investigated on the derived respiratory model. The supply of the desired level of supplemental oxygen by AFLPDC to the patients suffering from the diseases like Bronchitis and Emphysema during respiratory dysfunction is observed in the MATLAB SIMULINK environment without human intervention. The response revealed by AFLPDC is compared with the responses of the conventional PD controller and the Fuzzy Logic-based PD controller (FLPDC).


Introduction
The human respiratory system is highly non-linear and dynamic and its functioning is governed by numerous factors, be it within the body or outside the body of the individual [1]. From the knowledge of control systems, the human respiratory system can be considered to be a regulatory one and under certain conditions can behave in an oscillatory manner exhibiting both damped and sustained oscillations [2]. Several works have been done to develop mathematical models of the human respiratory system that represent states of airflow interruption [3,4]. Any kind of interruption or obstruction in the airway results in a slump in the level of oxygen that is required for normal respiration and in that situation, the individual may require an additional supply of oxygen to regain and maintain the adequate level of oxygen needed for tissue oxygenation [5,8]. The method of supplying external oxygen in a controlled manner is referred to as Oxygen Therapy [9,10]. The lungs comprise about 24 generations starting with the trachea and ultimately terminating in the alveolar sacs [11]. Adding to this, the consideration of numerous internal and external governing factors also makes the proper and accurate modeling extremely difficult. The unavailability of an accurate mathematical model causes conventional control to fail to deliver the desired results [12,13]. Several control schemes have been suggested earlier which can provide a suitable dosage of oxygen to the patient in a simple ON/OFF manner or control the amount of oxygen input as per the need of the patient using conventional as well as fuzzy logic control schemes [14,15]. This work proposes a simple yet realistic electrical RLC model of the respiratory system developed in MATLAB Simulink and also suggests a completely automatic adaptive fuzzy logic proportional plus derivative control (AFLPDC) scheme to control the supply of supplemental oxygen whenever required and also ensuring minimum human intervention [10,15]. The tuning of a Fuzzy Logic Controller (FLC) is time-consuming as several parameters like the scaling factors (SFs), type of the membership functions (MFs), also database and rule generation need precise attention to obtain highly satisfactory results [16]. The SFs have a global influence on the system and to be specific, the output SF requires extreme attention as it is directly related to the system stability. In comparison, the conventional PI, PD or PID control schemes require only two or three parameters to be tuned but their response while dealing with highly complex, non-linear systems is not satisfactory [16,17]. On the other hand, FLC thrives on the notions of imprecision, partial truth, ambiguity, inaccuracy, and vagueness to come to any sort of control conclusion [18,19], so, the use of FLC while dealing with the respiratory system is justified. This manuscript presents an Adaptive Fuzzy Logic PD Control technique that can be put to good use to control the adverse effect of breathlessness in an individual. A comparative study between conventional PD control, FLPDC, and the proposed Adaptive Fuzzy Logic PD Controller (AFLPDC) technique has been presented to treat cases of respiratory diseases like Bronchitis and Emphysema. AFLPDC response shows its effectiveness over others like conventional PD and FLPDC [20].

Model of the Respiratory System
The human respiratory system can be broadly classified into four sections beginning with the nasal cavity through which air at normal atmospheric pressure enters the body. Air, then passes through the trachea which is the second section and can be considered to be generation "zero" of the airway tree. As shown in Fig. 1, after passing through the trachea air enters the bronchial tree with the pair of bronchi comprising the first generation and extending up to the generation '19' and constituting the third section. Finally, air enters the numerous alveolar sacs (alveoli) in the lungs which are the site for actual gaseous exchange in the human body and are considered together to be the final or fourth section and represent generations '20 to 23' of the airway tree as shown in Fig. 1. In this model, each branch of a given generation is further subdivided into two identical daughters; therefore generation 'n' has 2 n branches [21,22].
There are a total of about 300 million alveolar sacs present in both the lungs of an adult human being [8]. Each of these sections has its characteristic Resistance which refers to the obstruction offered by the section to the flow of air through it (cmH 2 OL -1 s -1 ), Inertance refers to the obstruction to the change in airflow through the section (cmH 2 OL -1 s -2 ) and Compliance means the extent to which the concerned section can expand or contract (LcmH 2 O -1 ). Electrical terms like resistance (R), inductance (L), and capacitance (C) are used in analogy with these properties respectively to develop an electrical representation of the physical system [23,11]. So, each one of these sections can be considered to be a series combination of these three electrical components as shown in Fig. 2.  The Transfer Function (TF) of each section is determined by considering Fig. 2 which comes out to be in this form after executing the Laplace transform, with all initial conditions to zero [1/(s 2 LC+sRC+1)], where R, L, and C are the characteristic values of Resistance, Inductance and Capacitance of the section concerned [24]. The necessary calculations of R, L, and C to reflect it for the different generations of the respiratory system are shown in Table 1. Using Table 1 for 'generation 0', generation 1 to 19, and generation 20 to 23 correspond to the trachea, bronchi, and alveolar sacs respectively [10,[21][22][23]. The derived values of R, L, and C are tabulated in Table 2. The transfer functions for the different parts of the respiratory system are modelled by putting R, L, and C values in the developed electrical equivalent model as depicted in Fig. 2 [19].
Where, TF N , TF T , TF B, and TF A are the respective transfer functions of the nasal cavity, trachea, bronchi, and alveoli. In this electrical analogy model of the respiratory system, air pressure is considered analogous to voltage whereas current represents the rate of airflow within the concerned section. Each of these sections is connected one after the other as shown in Fig. 2, hence a cascade combination of the transfer functions of these four sections is made to obtain the final respiratory system model (TF M ), as in "Eq. (5)".

Validation of the mathematical model
The    The respiratory models (TF M and TF R ) are derived by two different techniques and analyzed with the same input as shown in Fig. 6. The responses of both the models are compared and then validated, with the same breathing input signal (Fig. 5) for 4 secs. (Inhalation period =1.5 s and exhalation period =2.5 s).
From Fig. 6, it is observed that the theoretical model TF M as in "Eq. (5)" and the realtime model TF R as in "Eq. (6)" are look alike. The similarity measure is done by calculating the correlation coefficient (R).

R =0.9986
Where, (d n , σ n ) and (d s, σ s ) are the data set and their standard deviation corresponds to the healthy respiratory model and spirometry respiratory model respectively. The correlation coefficient value of 0.9986 i.e., towards +1 (but less than +1) is an indicator of good validation.

The Input signal/ Normal breathing pattern
The nasal cavity is the gateway of air into the respiratory system. The difference between air pressure within the body (alveolar spaces) and the surroundings causes air at atmospheric pressure (1033 cm of H 2 O) which is rich in O 2 content to flow into the respiratory tract (inspiration). When the air pressure within the alveoli exceeds the atmospheric pressure, then the CO 2 -rich air is blown out from the lungs (expiration). In the simulation study, the desired breathing pattern to test the developed respiratory model is shown in Fig. 5 [25,26]. During expiration, the air rich in CO 2 content will retrace the same path initiating from the alveoli, bronchi, trachea, and back to the nasal cavity and finally out of the body, the graph will ensure a gradual fall-off nature. In Fig. 5, total breathing cycle is of 4 seconds, in which t 1 (inspiration time) = 1.5 seconds and t 2 -t 1 (expiration time) = 2.5 seconds. In the plot, the time segment 0 ≤ t ≤ t 1 of the input signal represents the inspiration, and the time segment t 1 < t ≤ t 2 represents the expiration process.

Mathematical model of oxygen supply
The pictorial view of the supplementary oxygen supply (CMC, Vellore) is pitched in Fig.  7. An oxygen cylinder/plant along with its valve, when connected to a patient can be considered to be a first-order control system [16,23,24]. In Fig. 8, P 1 , P 2 , q, R, and C are the input oxygen pressure (oxygen source pressure), output oxygen pressure (patient input pressure), oxygen flow rate, resistance in the flow path (valve resistance), and capacity of the system in terms of patient oxygen requirement respectively. All the parameters are to be measured and monitored regularly to make sure a healthy requirement for the patient. . The oxygen supply to the patient is modelled from the electrical analogy drawn in Fig. 8 as follows: (7) From "Eq. (7)", the transfer function of the Oxygen supply is derived as:

The Proposed Control Scheme
The respiratory behaviour of a person who is affected by any respiratory disease will deviate from the respiratory behaviour of a healthy individual. Such respiratory diseases result in obstacles in the respiratory path and hence, the amount of air that enters the lungs is less than what is required for normal respiration to take place. This in turn increases the time required to attain the peak value of the response of each respiratory cycle. Proper medical treatment by medical practitioners is one of the foremost requirements for the cure of internal damage. It is considered here that this has already taken place and in addition to this supplemental oxygen also needs to be supplied so that a normal breathing process is restored. Considering the entire prerequisite is maintained and monitored by the expert before application of the proposed controller to the patient. At first, a conventional PD controller is used to control the desired level of oxygen in the patient but it fails to reach a satisfactory result. It has to be ensured that the oxygen must be supplied in a controlled manner as per the requirement of the patient, or else in case of excess dosage i.e. if the oxygen supplied is more than what is required by the patient, this problem often gets aggravated.
To overcome the shortcomings of the PD control scheme and also to maintain the oxygen level within the acceptable range, fuzzy logic is incorporated along with the PD control (FLPDC) scheme because it deals with qualitative aspects of a system rather than the quantitative features and also takes care of any sort of vagueness and ambiguity in the information [18,19].

Development of the fuzzy logic PD controller
The PD-type FLC has been shown in the feedback path in Fig. 9 which works on two inputs, "error" (e) and "change of error" (∆e) [11,15,18,19]. Error is measured by comparing the output response of a healthy system with the output response of a pretentious system. The multiplier blocks "G Δe " and "G e ' are the scaling factors for the two inputs into the FLC, '∆e' and 'e' respectively. The block 'G u ' is the scaling factor of the output (u) of the controller.
Considering the importance of the work, 49 fuzzy if-then rules are developed and its control surface is studied in Fig. 10. The fuzzy rule base represents the control strategy in a planned manner as depicted in Table 3 [11,15,19]. Triangular MFs with equal basewidth have been considered for the inputs (e & ∆e) and output (u) variables as presented in Fig. 11. The input-output span is divided by seven fuzzy linguistic terms negative big (NB), negative medium (NM), negative small (NS), zero (ZE), positive small (PS), positive medium (PM), and positive big (PB). Mamdani implication and Centroid defuzzification strategies are implemented for FLC design.
The FLPDC generates the output 'Y', as shown in Fig. 9 which controls the valve opening of the oxygen supply path, thereby controlling the amount of O 2 that is supplied to the patient.    11. MFs for "e," "Δe" and "u" for both FLPDC and AFLPDC. It is well known that there is no fixed methodology or neither any well-established criterion that can be followed while tuning an FLPDC. For the betterment of the controlling experience of FLPDC, a new adaptive tuning scheme is proposed [27][28][29]. This scheme generates an additional corrective signal (1+k|e|) at every instant, which coalesces with the FLPDC output "Y' and collectively controls the O 2 supply as shown in Fig. 12. The value of the factor 'k' is chosen in such a way that the best possible response from the system is obtained. This non-fuzzy adaptive tuning scheme does not require any kind of modification of the rules nor did any additional rules and works simultaneously with the FLC, thereby ensuring that no additional time is consumed [30,31]. In this scheme, the error 'e' is effectively processed twice, once by the FLC and simultaneously by the adaptive section. The output (Y net ) of the AFLPDC is adjusted according to the dynamic variation of the process parameters.

Development of the AFLPDC scheme
(10) Fig. 13. The control surface of AFLPDC.
The study of the control surface of FLPDC and AFLPDC in Figs. 10 and 13 reveal that the control surface of AFLPDC is smoother, which is essential for the effective operation of a control valve.

Respiratory Diseases and Results
This work concentrates on respiratory diseases namely Bronchitis, and Emphysema.

Bronchitis
A person affected by bronchitis suffers from inflammation of the mucus membrane within the bronchial passages in the lungs (Fig. 14). The mucus membrane swells and grows thicker and thereby shutting off the tiny airways in the lungs. Hence, the free flow of air through the bronchial passage is hindered, resulting in coughing, accompanied by breathlessness [32]. This condition can be represented in the electrical model by an increase in the resistance (R B ) of the bronchial section and often this increment is by about 2000 times.
In an RLC circuit, Inductive Reactance: X L =1/2πfL and Total Impedance At normal conditions, the resistance of the bronchial section was equal to 0.0087 cm H 2 OL -1 s -1 as per the value shown in Table 1, and thus for 2000 times increment, the resistance will be 2000*R B and the model of the bronchial section represented by "Eq.
(3)" will be transformed into the model: (12) Where refers to the transfer function of the bronchial section of a human being affected by bronchitis. Figs. 16 and 17 demonstrate how and to what extent, Bronchitis affects the normal respiratory behavior of a healthy person. This disease impedes the O 2 intake and also slows down the respiratory process. The proposed AFLPDC shows a better response as compared to the response obtained by the conventional PD and the FLPDC control scheme.

Emphysema
The alveolar sacs resemble several bunches of grapes. Due to smoking, these air sacs get filled with air. Long-term smoking causes air to build up within these sacs thereby making them expand to the extremity and ultimately the walls of the sacs rupture to form larger airbags with holes in them. Thus, the effective surface area required for the gaseous exchange process decreases, and the patient experiences tribulations in respiration. It is a kind of Chronic Obstructive Pulmonary Disease (COPD) (Fig. 15).
This disease can be represented in terms of an increment in the capacitance (C) of the alveoli by about 5000 times. This increment in capacitance value changes the alveoli model which is now represented as: (13) Where refers to the transfer function of the alveolar section of a human being affected by Emphysema. This increment in capacitance increases the damping factor and decreases the reactance capacitance and thereby making the system deviate from the normal response.
In an RLC circuit, the Capacitive Reactance and damping factors are, respectively. In the case of emphysema, it is observed that the PD controller is unable to supply desired oxygen, and to overcome this problem FLPDC and AFLPDC are applied. The study of the AFLPDC scheme with different time constants in the Emphysema model reveals that the time constant value of 0.25 s yields a nearly exact response as shown in Fig. 18. Respiratory response by the proposed AFLPDC as shown in Fig. 19 shows better results compared to conventional PD and FLPDC controllers in the case of Emphysema.        Comparative study of the different controllers' output with the help of error analysis in terms of MSE and correlation coefficient are illustrated in Figs. 20 and 21 and calculated data are presented in Tables 4 and 5 respectively. Tables 4 and 5 reveal that the MSE values are minimized by the proposed AFLPDC and also the correlation coefficient values for the AFLPDC is towards positive (close to unity) which indicates the superiority of the proposed controller.

Conclusion
Developing a well thought human respiratory model and suggesting a new adaptive scheme for the fuzzy controller, are the two main areas of this paper. It is practically impossible to attain a model that will exactly match the real respiratory system given the fact that it is not viable to consider the numerous contributing parameters and precise quantitative as well as qualitative analysis of the respiratory system. The model developed is validated with a human respiratory system, and it matches up to 95.63 % to the model of the real respiratory system. A simple auto-adaptive tuning scheme is proposed in this paper, which will track the respiratory parameter variations and supply the required oxygen to patients suffering from respiratory illness. On comparing the responses obtained by applying the three control schemes to the two diseases model, it is clear that the proposed AFLPDC is more effective in oxygen supply compared to the conventional and normal fuzzy controller. The AFLPDC will serve in a better way as the imprecision and assumptions in the model developed will be taken care of by the real-time parameter adjustment. The proposed AFLPDC scheme is completely automatic and thus requires minimal human intervention. The proposed adaptive scheme for the fuzzy controller is independent of the processes; therefore it can be tested in other complex industrial processes in the future.