Methods of signal processing and construction of diagnostic matrixes onset by sleep apnea treatment equipment N V Ivakhno1, S I Zykin1 and S V Antsibor1 1 Tula State University, Lenina ave. 92, Tula, Russia, 300012 Abstract. The paper deals with the problem of data processing in adaptive detection of inspiration / expiration by machines for treating sleep apnea using statistical decision theory and based on preliminary analysis of human respiration. The authors establish a law of noise distribution and develop an inspiration and expiration detection algorithm which envisages calculation of the likelihood ratio, which is compared with the threshold values, at each step. As a result, a conclusion is drawn, and a decision is taken on the need to initiate the treatment of sleep apnea with the machine. The use of this algorithm reduces the detection time by 2-3 times, making it possible to carry out preliminary adjustment of parameters for each patient. The problem of definition of person s respiratory system condition with the use of the methods based on a task of the dosed values of resistance/pressure of switching in a respiratory contour with the subsequent creation of diagnostic matrixes state, in which every line characterizes parameters value at a certain loading for the throttle and relay modes of complexes correcting influence is solved. 1. Introduction Sleep apnea is the cessation of pulmonary ventilation (respiratory arrest) during sleep for more than 10 seconds. Usually it lasts for 20–30 seconds, though it may be as long as 2–3 minutes [1,2]. Apnea can be classified as central, obstructive, or mixed. In the first case, the respiratory arrests during sleep are caused by the disorder of brain function caused by congenital abnormalities or brain injuries. Obstructive sleep apnea (OSA) is a sleep disorder that occurs when the soft tissues in the back of the throat (upper airway) become narrow, and the muscles naturally relax [1,3,4], which results in reduced supply of oxygen to the lungs. Various devices are used to detect apnea [1,2], which make it possible to identify respiratory pauses, episodes of oxygen starvation, snoring, and other symptoms. For the treatment of sleep apnea [1, 2], they mainly use the respiratory ventilation mode known as positive airway pressure (PAP). A CPAP machine is a small compressor supplying a constant flow of air into the respiratory tract at a predetermined pressure through a flexible tube and an airtight nasal mask [2,3], which prevents the respiratory tract from occluding and blocking the flow of air (and thus of oxygen the organism needs). A crucial role during treatment is played by CPAP equipment. Speedy recovery of the patient depends to a great extent on the effectiveness and reliability of medical equipment. The advisability of real-time pressure adjustment is predetermined by the fact that therapeutic pressure changes depending on the body position and the sleep stage. During the stage of deep sleep, as well as when the person is sleeping on the back, a significantly greater pressure is required to open the airway as compared with the stage of surface sleep and sleeping on the side, respectively. Thus, in order to control the motor of IV International Conference on "Information Technology and Nanotechnology" (ITNT-2018) Data Science N V Ivakhno, S I Zykin and S V Antsibor the CPAP machine, it is necessary to provide adaptive functioning of the algorithms adjusting to each individual patient. Analysis suggests that the existing models of CPAP machines do not take into account changes in the human condition, as well as the interaction processes taking place in the biotechnical system “machine – patient”. The treatment of sleep apnea syndrome requires high precision adjustment of the initial parameters and synchronization of the functioning of the CPAP machine and the patient. One of the modules providing the determination of the initial parameters of the system and affecting the accuracy of synchronization is the detector of the onset of inspiratory and expiratory activity functioning as part of the operation modes of a sleep apnea treatment machine. 2. Model of the process of recognizing the onset and end of respiratory activity Recognition of the beginning and the end of respiratory activity is usually carried out based on a given pressure value; however, at a fixed pressure, due to noises, a delay is observed in determining the onset of inspiration and expiration, and with weak respiration the decision to switch the CPAP machine motor on for treating sleep apnea is made almost in the middle of the respiratory cycle, which leads to significant desynchronization of operation [5,6,7]. Therefore, in order to establish a decision-making criterion, we have developed an adaptive data processing algorithm based on modern statistical decision theory and taking into account the distribution law and the parameters of the useful signal and noise measured during automatic adjustment of the system [5,8]. In order to obtain the mathematical model of signal processing in anticipation of inspiratory / expiratory activity, experimental studies have been carried out of the breathing of various patients with the purpose of determining the law of noise distribution. The empirical data obtained were used to build histograms and to put forward the hypothesis about the normal noise distribution law, the likelihood of which was confirmed using chi-squared goodness-of-fit test. According to research conducted in [2,4,6], a mathematical model of the recognition process was established in which the likelihood ratio is obtained at each step of observation: 1 m m ln Λ( m) = ρ 0 ( ∑ zi − ) . (1) a i =1 2 2 where ρ 0 = a is signal / noise ratio, m is the count number, zi = yi − a 0 , a = as − a 0 , as is the σ2 input signal amplitude, σ 2 , a 0 are the variance and the average value of noise, yi is the measured value of the pressure in the breathing circuit [2,9]. The value ln Λ( m) is compared with two constant threshold values: A and B (A> B), which are found based on the predetermined conditional probabilities α* and β* of detection ahead of time (false alarm) and of delayed inspiration / expiration detection (signal omission) [1,2]. If the decision is taken that there is no signal, the analysis is repeated until the onset of inspiration / expiration is detected in accordance with the limitation interval. For the purposes of both the simulation modeling and the subsequent implementation of the developed model of inspiratory / expiratory activity onset detection, the probability of signal omission was found based on the analysis of respiratory rate and efficiency of sleep apnea treatment procedure α* = 0.01 , and the probability of false alarm, given the architecture and the function of CPAP machines, was set to β* = 10 − 3 . In this case, ln A = 4.605 , ln B = −6.89 [1,10]. 3. Algorithm of data processing in detecting the inspiration onset According to the obtained formula (1), the sleep apnea treatment complex comprising a pressure measurement unit was supplemented by additional elements making it possible to implement the adaptive method of detecting the onset of inspiration / expiration taking into account random external disturbances characteristic for each patient [4,5,11]. IV International Conference on "Information Technology and Nanotechnology" (ITNT-2018) 385 Data Science N V Ivakhno, S I Zykin and S V Antsibor Given the data obtained in experiments, we established the time of parameter adjustment, which amounts to 1-1.5 minutes, on the basis of the predetermined confidence level and the variance [2,3]. Automatic parameter adjustment allows implementation of the mathematical model of signal processing in detecting the onset of inspiration / expiration. The functioning of the algorithm can be represented as a block diagram (Fig. 1). Pconst P (t ) Pmax (t ) Initial parameter adjustment for the patient Pвх (a 0, σ, as ) Onset of inspiration P (t ) yi Storage element Calculating Threshold Continued element device observation Absence of inspiration ln A = 4,605 ln B = −6,89 Figure 1. A block diagram of the method of data processing when detecting the onset of inspiration. The initial parameters are as follows: the values lnA and lnB – constants for various categories of patients; σ, a 0 - the standard deviation and the average noise value (found during the automatic adjustment of parameters, with the patient breathing independently); as – the value of the useful signal, found during the automatic parameter adjustment as q1 ⋅ Pmax (t ) + Pconst , where q1 is a variable coefficient, the value of which, as a rule, may amount to 0.01÷0.2 depending on the maximum signal value (the ratio decreases with increasing amplitude), Pmax is the average maximum value of inspiratory / expiratory pressure found during the adjustment of parameters for each person, Pconst is the pressure level against which the measurements are taken, relative zero. The device for detecting the beginning of the patient’s inspiration / expiration operates as follows (Figure 2): yi - the measured value of the pressure in the breathing circuit is summed with the next count obtained (storage element), and the calculating element calculates the likelihood ratio ln Λ( m) at each stage of observation, taking into account a0 , σ , and as . The threshold device generates a conclusion about whether the beginning of the inspiration / expiration has been detected, or whether observation should be continued. Signal processing is carried out in the same way when detecting the end of inspiration / expiration. The results of experimental studies on the calculation of likelihood ratio value are presented in Fig. 2 and Fig. 3. 4. Diagnostic matrixes of the respiratory system condition for the correcting influence complexes After recognition of the beginning and the end of respiratory activity hardware has a controlling influence, at the same time should be diagnosis of the state of the human respiratory system, result processing in real time and adjusting loads. A comprehensive approach based on parametric analysis of the dependence of the pressure at various modes of functioning of the complexes has a correcting effect on the respiratory system, includes specifying a load in two modes – the throttle and relay that determines the change in the resistance of breathing circuit [3]. Under throttle type refers to the task of resistance in the breathing circuit in the form of restriction of the cross-sectional area of the breathing tube under the relay – IV International Conference on "Information Technology and Nanotechnology" (ITNT-2018) 386 Data Science N V Ivakhno, S I Zykin and S V Antsibor when the initial complete overlap of the respiratory tube at the beginning of the inhalation/exhalation – the full opening of the valve when it reaches a certain pressure (pressure switch). ln Λ( m) верхняя граница верхняя граница 5 ln Λ( m) 5 0 0 5 нижняя граница -5 нижняя граница - 10 -10 - 15 0 5 10 15 20 25 30 m -15 0 5 10 15 20 25 30 m Figure 2. The values of likelihood ratio at each Figure 3. The values of likelihood ratio at each step of observation with respect to the decision step of observation with respect to the decision limits (onset of inspiration registered at count limits (onset of inspiration registered at count 26). 31). The pressure values were measured in the breathing tube of a model according to the structural scheme presented in [2,3,4,11]. To conduct a parametric analysis of the dependence of the pressure measurement results were normalized relative to the maximum possible value of pressure measured during the initial studies of the respiration of each person, P (t ) P (t ) = meas , Pmax where P(t ) - normalized characteristic pressure; Pmeas (t ) - measured characteristic pressure in the respiratory tube according to the structural scheme presented in [3,4,5,11,12]; Pmax - maximum pressure of inhalation/exhalation fixed at the time of the initial investigation. To select the type of exposure variable is introduced which takes two values j = 0, j = 1 depending on the relay or the throttle operation. To build a matrix of conditions of the respiratory system enter the number of levels of load impacts N. Sequential changes in the load/pressure is indicated by i = 0,1...N . Every exposure causes (table 1): at throttle type – change of cross-sectional area relative to the 100 original in i %, the relay type (load change pressure switch) – change the pressure switch on N +1 0,7 Pmax i. N Table 1. An example of setting exposure levels when N = 4 i = 0,1…4 0 1 2 3 4 The establishment R0 = 0 R1 = 20 R2 = 40 R3 = 60 R4 = 80 of resistance (the area of overlap) Pressure switch P0 0,7 Pmax 0,7 Pmax 0,7 Pmax P4 = 0,7 Pmax P1 = P2 = P3 = 3 4 2 4 min load max load View graphs of the normalized pressure obtained at different load resistances, shown in Fig.4. As a result of analysis of numerous experimental data revealed that the relationship between the specified resistance and measured characteristics is not linear. As can be seen from Fig. 4, the phase of inhalation/exhalation can be divided into two sections and approximated by linear functions, the slope of which carries information about the state of the respiratory system of the patient. IV International Conference on "Information Technology and Nanotechnology" (ITNT-2018) 387 Data Science N V Ivakhno, S I Zykin and S V Antsibor P(t) 0,85 0,8 0,75 2 0,7 1 3 0,65 0,6 t Figure 4. Examples of the different characteristics of the pressure in the breathing circuit at the throttle type of impact (expiratory phase): 1 - easy breathing R0 = 0 ; 2 – breathing through a resistance R1 = 0,2 R ; 3 – breathing through the resistance - R3 = 0,6 R Thus, a generalized mathematical description when the throttle type of impact is represented by the combination of two linear functions: α i t + bi , at 0 < t ≤ t ri , Pi (t ) =  βi t + сi , at t нi < t ≤ Ti − t ri , where αi , βi - angles when increasing and decreasing the approximating function of the i-th load; t ri - the rise time of the pressure curve up to the maximum; bi , ci - coefficients; Ti - the duration of the inspiratory phase/expiratory (Fig.4), Pi (t ) - normalized pressure characteristic. A generalized mathematical description of the resulting characteristics of the pressure at relay type of impact (Fig. 5) is expressed by the following functional characteristics: αi ⋅ t + bi at t1 < t < t2 ,  Pi (t ) = α1i ⋅ t + b1i at t 2 < t < t3 ,  βpi ⋅ ln(t ) + b 2i at t 3 < t < t4 , where αi , α1i , βpi , bi , b1i , b 2i - the coefficients of the approximating functions of the i-th load; t1 − t 2 , t 2 − t3 , t3 − t 4 - intervals partitioning functions. P(t) 0.7 Pmax i N the characteristics of the different subjects t Figure 5. Examples of the different characteristics of the pressure in the breathing circuit at the relay type of impact (expiratory phase). Thus, the variable parameters characterizing the state of the human respiratory system when exposed to different levels of resistance and different pressure switch R0 ,..., RN , P0 ,..., PN are: the duration of the inspiratory phase/expiratory T1,..., TN , the inclination angle of the approximating IV International Conference on "Information Technology and Nanotechnology" (ITNT-2018) 388 Data Science N V Ivakhno, S I Zykin and S V Antsibor curve on the first section of the observation α1,.., αi .., α N , angle during the descending of the approximating function βi (with the load in the form of resistance), the coefficient of the approximating function in the third monitoring interval βp1,..., βp N (when the load in the form of a pressure switch), the rise time of the pressure curve to the maximum t r1,..., t rN , the characteristics of the pressure curve under free breathing α 0 , βp0 , t r 0 , T0 (load shift pressure), α 0 , β0 , tr 0 , T0 (load resistance) [6,7]. Then the generalized matrix characterizing the state of a person, his level of fitness when exposed to resistance and pressures, described so:  α0 β0 tr 0 T0   α0 βp0 tr 0 T0   . . . .   . . . .  M = , M1 =  .  αi βi t ri Ti   αi βpi t ri Ti      α N βN t rN TN  α N βp N t rN TN  The General criterion to establish the type of control action is formed by the conjunction of a number of parameters that make up the matrix of States of M and M1 and characterizes the variability of the condition of the human respiratory system with different types of impact, which is determined by the ratio:  2  1 s −1 N  M 1ik − M 1 *   i k   ∑ ∑ ck ⋅   at j = 1,  N k = 0 i =1  M 10k   2  K1 j =   2  s −1 N  M ik − M *   1   i k at j = 0. ∑ ∑c ⋅  N k = 0 i =1 k  M 0k     where с1, c2 , c3 , c4 - weights characterizing the importance of each indicator determined by expert; j - is the variable that determines the type of impact, k - is the parameter number ( k = 0,..., S − 1 , S – number of parameters, i - is the level of exposure i = 1,..., N , i* = i − 1 - previous exposure). Thus, the total set of informative features from different types of impacts (throttle and relay) is characterized by two matrices M and M1, which are necessary to identify the state of the respiratory system and formation of control actions [8,9]. These characteristics can be applied to the evaluation of corrective action. The General criterion to establish the type of control action, characterizes the variability of the condition of the human respiratory system with different types of exposure, is formed on the basis of indicators:  (T − T * ) 2 с N (t ri − t * ) 2 с N (βpi − βp * ) 2  с4 N i i ri i  ∑ + 3 ∑ + 2 ∑ + N 2 N 2 N βp 2  i =1 T i =1 t r0 i =1 0  0  2  с N (α i − α * ) + 1 i , at j = 1, ∑  N i =1 α2   0 K12j =   2 2 2  с N (Ti − T * ) с3 N (t ri − t ri * ) с 2 N (β i − β i * )  4 ∑ i + ∑ + ∑ +  N i =1 T2 N i =1 t2 N i =1 β2  0 r0 0   (α i − α * ) 2 + с1 N i , at j = 0,  N ∑ 2  i =1 α  0 IV International Conference on "Information Technology and Nanotechnology" (ITNT-2018) 389 Data Science N V Ivakhno, S I Zykin and S V Antsibor where с1, c2 , c3 , c4 - the weights characterize the importance of each indicator, j - is the variable that determinesthe type of impact, i - impact level ( i = 1,..., N ), i* = i − 1 - previous exposure. If we denote the number of the parameter k ( k = 0,..., S − 1 , S - is the number of parameters) General calculation specified ratio can be obtained based on the components of the matrices of the States of the respiratory system M and M1 for different numbers of parameters and different numbers of levels of effects [10,11,12,13]. Then, the calculation of this coefficient will describe the formulas [9,10,14,15]:  2  1 s −1 N  M 1ik − M 1 *   i k   ∑ ∑ ck ⋅   at j = 1,  N = =  M 10 k k 0 i 1   2  K1 j =   2  1 s −1 N  M ik − M *    i k  ∑ ∑ c ⋅  at j = 0.  N k = 0 i =1 k  M 0k    After the preliminary diagnostics of the condition of the respiratory system throttle type (load – resistance), set ratio К1 , the initial effect of throttle ( j = 0) and compared with the coefficient, determined experimentally for a group of patients whose characteristics change when holding the throttle pressure, which is expressed combined ratio К10 det (at peak effect of this factor - К11 det ). When К10 > К10 det the throttle is applied the method of the impact of adaptive selection of a load, when К10 < К10 det applied to the relay effect of shifting the pressure, or additionally is a factor К11 ( j = 1) and by comparing the proximity found in the process of diagnosis of coefficients to be determined К11det and К10 det , select the effect, which accounts for the maximum human reaction. Example of finding the coefficients К10 of equal weights of 0.25, are shown in table 2 at j = 0 , N =4 . Table 2. Data to find the coefficient of К10 Load i=0 i=1 i=2 i=3 i=4 characteristic R0=0 R1=0.2R R2=0.4R R3=0.6R R4=0.8R αi 0.139 0.186 0.186 0.187 0.188 βi -0.003 -0.003 -0.003 -0.003 -0.003 tr 2 0.5 0.6 0.61 0.62 0.62 Ti 1 1.2 1.3 1.5 1.6 The calculation results show the value of the parameter К10 = 0,187 , when the input values obtained the following values of the coefficient: К10 = 0,095 , К10 = 0,121 , К10 = 0,079 . So, if you receive two of the coefficient К10 = 0,295 , К11 = 0,329 the direction of impact will be selected at maximum К1 [9,10]. 4. Conclusions Experimental studies of the work of a patient with sleep apnea treatment equipment show that with the signal-to-noise ratio = 0.8 and using the developed mathematical model and the signal processing algorithm the beginning of expiration is detected at count 31 on average, that is after 0.062 seconds (at sampling frequency of 500 Hz), and that of inspiration – at count 23 (0.046 seconds). IV International Conference on "Information Technology and Nanotechnology" (ITNT-2018) 390 Data Science N V Ivakhno, S I Zykin and S V Antsibor Application of this method reduces the recognition time by 2.5-3 times, making it possible to carry out preliminary parameter adjustment for each patient and to select optimal detection threshold values to be used when operating sleep apnea treatment equipment. For a detailed description of the functionality of the respiratory system formation of diagnostic matrices at successive levels of loads. Developed methods for constructing matrices of state for various types of exposure apparatus, based on the allocation of the four main informative parameters in the analysis of the pressure characteristics is the angle of inclination of the pressure curve, the duration of the inspiratory phase/expiratory, the rise time of the pressure curve to the maximum angle during the descending pressure curve under load in the form of a resistance, the coefficient of the approximating function at the third site of observation under a load in the form of a pressure switch. 5. References [1] CPAP therapy machines (Access mode: http://sleepmedicine.popmed.ru/cpap/cpap_ comparative_analysis) (31.08.2017) [2] Ivakhno N V, Prohortsov A V, Senina E N and Fedorov S S 2014 Method of registration of chest movement in the diagnosis of sleep apnea Bulletin of New Medical Technologies 21(4) 133-136 [3] Ivakhno N V and Merkulov O V Utility model patent No. 115668. Respiratory muscles simulator Russian Federation. Priority date 20.09.2011 [4] Ivakhno N V and Tyagin A D Invention patent No. 2375034. Artificial pulmonary ventilation machine Russian Federation. Priority date 04.06.2008 [5] Antsiperov V E 2016 Automatic target recognition for low-count terahertz images Computer Optics 40(5) 746-751DOI: 10.18287/2412-6179-2016-40-5-746-751 [6] Ivakhno N V and Fedorov S S 2014 Principle of construction of mathematical model of process of signal processing in the detection of respiratory activity in systems of intellectual fitness effects Biotechnosphere 5(35) 19-22 [7] Ivakhno N V 2015 The structure and algorithm circuit self-diagnosis of the intellectual equipment of respiratory muscles Biotechnosphere 3(39) 40-44 [8] Gaidel A V, Khramov A G, Kapishnikov A V, Kolsanov A V and Pyshkina Yu S 2017 A method for digital renal scintigram analysis based on brightness and geometric features Computer Optics 41(1) 103-109 DOI: 10.18287/2412-6179-2017-41-1-103-109 [9] Ivakhno N V and Antsibor S V 2015 Parametric analysis of respiration characteristics under the relay action Proceedings of the Tula State University. Technical sciences 5(2) 78-84 [10] Ivakhno N V 2015 The method of diagnosis of the respiratory system under the choking action Proceedings of the Tula State University. Technical sciences 5(2) 92-97 [11] Smelkina N A, Kosarev RN, Nikonorov A V, Bairikov I M, Ryabov K N, Avdeev A V and Kazanskiy N L 2017 Reconstruction of anatomical structures using statistical shape modeling Computer Optics 41(6) 897-904 DOI: 10.18287/2412-6179-2017-41-6-897-904 [12] Gaidel A V 2016 Matched polynomial features for the analysis of grayscale biomedical images Computer Optics 40(2) 232-239 DOI: 10.18287/2412-6179-2016-40-2-232-239 [13] Ivakhno N V 2015 Formation of a common set of informative signs to identify the condition of the respiratory system Proceedings of the Tula State University. Technical sciences 5(2) 106- 111 [14] Ivakhno N and Fedorov S 2016 Adaptive stress control method used in remedial action complexes for human respiratory system Proceedings of the 12th Russian-German Conference on Biomedical Engineering 243-246 [15] Gaidel A V 2015 A method for adjusting directed texture features in biomedical image analysis problems Computer Optics 39(2) 287-293 DOI: 10.18287/0134-2452-2015-39-2-287-293 Asknowledgments The results of the research project are published with the financial support of Tula State University within the framework of the scientific project № 8718. IV International Conference on "Information Technology and Nanotechnology" (ITNT-2018) 391