the present invention is motivated by the desire to produce a continuously updated estimate of the leak model parameter which is very stable when the actual leak parameter is stable , but which degrades progressively and gracefully to a less stable , less accurate but faster - responding estimate when the actual leak parameter is changing rapidly . the leak model parameter in question is typically an orifice constant ( equivalently a leak conductance ), but need not be . a continuously updated estimate of leak conductance ( in particular , continuously updated during each breath ) may be calculated by performing some kind of low - pass filtering operation , such as a 1st - order low pass filter or a moving average filter , typically with a fixed window length , on the non - vent flow ( equal to the sum of the respiratory flow and the instantaneous leak flow ) and on the square root of the mask pressure , producing a leak conductance estimate g 1 , as in berthon - jones . this method has the advantage over some other methods that it is independent of the determination of breath phase ( the position within the current breath ). thus sudden changes in leak can occur which cause respiratory flow estimates and hence breath phase estimates to be grossly in error , yet updating of the leak parameter estimates continues . a disadvantage of such breath - independent estimates is that the estimates are not stable within a breath unless particular fortuitous events occur ; for example , by coincidence , the duration of a window averaging filter includes exactly n breaths , where n is an integer . a particular case of this instability is illustrated by considering the situation when 1st order low - pass - filter estimates of mask flow and mask pressure are used . for simplicity , assume that a mask pressure is constant , and that true leak conductance is zero . then the leak flow estimate is just a 1st - order low - pass - filtered version of respiratory flow . this estimate rises whenever respiratory flow is above the leak flow estimate , and falls when respiratory flow is below the leak flow estimate . in particular , with reasonable filter time constants , the leak flow estimate rises during most of inspiration and falls during most of inspiration , rising slowly during the expiratory pause , and under normal circumstances crucially being below zero during the expiratory pause . since true respiratory flow is zero during the expiratory pause , estimated respiratory flow , being the difference between mask flow ( by assumption equal to respiratory flow ) and estimated leak flow , is positive during the expiratory pause , say equal to q eps . if a ventilator is designed to trigger into inspiration when the estimated respiratory flow exceeds some true respiratory flow threshold q insp — thresh , a ventilator which uses this kind of leak estimate , in order to trigger at the desired true respiratory flow , must set its trigger threshold to a higher value q insp — thresh + q eps . unfortunately q eps is a function of the respiratory flow shape , the respiratory rate , and the low - pass - filter time constant , very difficult if not impossible to determine in real time . hence triggering actually occurs at a variable threshold , and in the worst case auto - triggering ( triggering at a true respiratory flow of zero ) may occur . it should be noted that the effect of the non - constant estimate of leak parameter in producing a distorted respiratory flow exists throughout the breath and whether there is an identifiable expiratory pause or not , with potential adverse effects on cycling ( expiratory triggering ) as well an on ( inspiratory ) triggering , as well as other algorithms which operate on estimated respiratory flow . “ jamming ”, as described by berthon - jones , is the extent to which the leak has not yet been compensated for , and usually results from a rapid change in the leak . it is herein considered to be a fuzzy logical quantity . a leak conductance estimate g 1 is calculated as described above . note that the time constant of the filters uses preferably decreases as jamming increases , as described in berthon - jones . a second leak conductance estimate g 2 is calculated continuously , at the algorithmic sampling frequency or a lower frequency ( e . g . 10 hz ) which is still high compared with the respiratory frequency . in a manner described below , the algorithm identifies the position in the current breath , then attempts to find time associated with the same position in the preceding breath . if it fails to find such a position , it uses instead a time 10 seconds in the past . between that time in the past and the present , a window is established . low - pass filtered mask flow and low - pass filtered square root of mask pressure ( filtered by a non - breath - dependent method , such as a 1st - order lpf ), typically the low - pass filtered values used for the determination of g 1 , are then further low - pass filtered by being averaged over this window . the ratio of these window - averaged values is the leak conductance estimate g 2 which under conditions of stable leak is extremely stable . because g 2 responds rather slowly to changes in leak conductance , it is inappropriate to use when the leak is changing rapidly . thus to the extent that there is jamming , g 1 rather than g 2 is used . in the preferred implementation , if j is jamming ( a quantity in [ 0 , 1 ]), the conductance estimate g j is used , given by instantaneous leak is then straightforwardly calculated by q 1eak = g j √{ square root over ( p mask )}. the aim is to determine the same position in the previous breath as the patient , is at in the current breath . for this one needs a concept of breath phase which is not just one of a small set of categories , such as inspiration and expiration , but a conceptually real - valued ( in practice rational ) variable which increases progressively from the start of inspiration to the end of expiration , potentially with a small finite number of jumps . such a concept is provided in berthon - jones cheyne - stokes patent , wo98 / 012965 , which is incorporated herein by reference . breath phase is there defined to be 0 at the start of inspiration , 0 . 5 at the start of expiration , and approaches 1 at the end of expiration . given such a breath phase , one find the breath phase at the current moment , then searches backward in time to find the same breath phase in the previous breath . because breath phase as estimated by the system described by berthon - jones is not necessarily increasing with time during a breath ( neglecting the expiratory to inspiratory transition , at which it must decrease ) though typically it is increasing with time during a breath , it is necessary to have an algorithm which searches backward in time in such a way that a point in the same breath with the same breath phase as the current value is not identified as being in the previous breath . such a search algorithm is described below ; this algorithm may fail under exceptional circumstances , but is quite robust most of the time . because of jumps in phase , there may exist no point in the previous breath with a phase equal to the phase associated with the current moment , the latest time in the previous breath with a phase less than or equal to the phase at the current moment is used instead . on the other hand , a system which uses conventional flow thresholds for triggering and cycling need not use a fuzzy logical system for determining breath phase for the purpose of finding the same position in the previous breath as in the current breath . assuming that during inspiration , the maximum time between the present until the end of inspiration is known ( typically determined at the start of inspiration , but not necessarily ), the breath phase at each sampling interval is increased by such an amount that with equal increments of that amount , the phase would reach 0 . 5 at the end of inspiration . for example , in the simple case where a maximum inspiratory time of 1 . 6 seconds was determined at the start of inspiration , the phase would increase at a steady rate of 0 . 5 / 1 . 6 phase units / second . if cycling ( transition to expiration ) occurred earlier , for example because respiratory flow fell below a cycling threshold , the phase would at that point jump to 0 . 5 . similar considerations apply during expiration , with rate of increase of phase being the difference between 1 and the current phase divided by the time remaining until the maximum expiratory time . if since breath phase determined in this way is typically used only for the purpose of determining the same position in the previous breath as in the current breath , it is called “ book - keeping ” phase . regardless of the phase determination method used , whether that of berthon - jones , “ book - keeping ” phase as described above , or some other method , the search backward in time to find the latest time in the preceding breath with a phase less than or equal to the phase at the current moment is performed as follows ( though it will be appreciated that for “ book - keeping ” phase , simpler methods are available ). starting with the current phase , say φ 0 , the invention looks backwards in time for the most recent phase in the interval [ φ 0 − 0 . 75 , φ 0 − 0 . 25 ]. the aim is to seek a point in time at least 0 . 25 of a breath before the present . when such a phase is found , the invention calculates φ 1 = φ 0 − 0 . 25 and looks backward for a phase in the interval [ φ 1 − 0 . 75 , φ 1 − 0 . 25 ]. this is continued , 0 . 25 at a time , i . e . φ i + 1 = φ i − 0 . 25 . when a phase is found which is in [ φ 3 − 0 . 075 , φ 3 − 0 . 25 ] the iteration ceases , since this is just [ φ 0 − 0 . 5 , φ 0 ]. if phase varied continuously this would have found exactly φ 0 ; in reality it will most likely find φ 0 − ε ., where hopefully ε is small . by proceeding in this manner we have some confidence that the phase has gone backward rather than forward , since we have found phases in the 4 phase quadrants before the present . this algorithm will regard two phase transitions of 0 . 5 in succession as being movement backward , though the actual direction is of course actually indeterminate . if this algorithm fails to find a point between the present moment and a time before the present which meets this criterion , we take the start of the averaging window to be some reasonable maximum time before the present , such as 10 seconds . as an implementation detail , to reduce computational requirements , the leak , flow values may be averaged over the last 0 . 1 seconds and stored in a buffer accompanied by the associated breath phase , so that the search for the last breath is performed in a buffer of 100 points , and done every 0 . 1 seconds . the averaged leak estimate at the instantaneous leak calculation frequency , e . g . 100 hz , can then be calculated by linear interpolation between the most recent averaged leak conductance estimate and the averaged conductance leak estimate just before it . in a servoventilator or other system using some kind of measure of ventilation ( such as half the absolute value of respiratory flow , or a gross alveolar ventilation , or peak flow , or some weighted average of flows determined during inspiration or expiration ) to adjust ventilatory support , when jamming is observed , the system slams down or suspends changes in pressure support . this is because respiratory flow estimates are not reliable in the presence of jamming , and various measures of ventilation based on respiratory flow are likely to overestimate ventilation , leading for example in a servoventilator to unwarranted withdrawal in ventilatory support because ventilation appears to be above target ventilation . the extent of slowing down of adjustment of respiratory support is preferably some increasing function of the jamming . for example , if the calculated change in respiratory support from that at the previous time that it was calculated is some value δs , then the adjusted change in support would be kδs , where for example k is 1 for j ≦ 0 . 1 , 0 for j ≧ 0 . 3 , and taking linearly interpolated values for intermediate values of j .
a respiratory treatment apparatus and method in which a leak is determined by using an averaging window . the window starts at the present time and extends back in time to a point determined according to a current one of progressively detected phase measures of a first respiratory cycle and a corresponding phase measure attributable to a preceding second respiratory cycle . in another aspect , a jamming index indicates whether the leak is rapidly changing . to the extent that jamming is high , the leak estimate used progressively changes from that using sliding breath - window averaging to a more robust and faster responding low - pass filter method , and adjustment of ventilatory support based on measures employing estimated respiratory flow is slowed down or stopped .