Calculating Unintentional Leaks (Calling all maths geeks :)
Re: Calculating Unintentional Leaks (Calling all maths geeks :)
This is probably a really dumb idea, and this post will likely prove my moniker to be apropos in regards to this particular subject. Hell, while getting scuba certified, Boyles law seemed a bit convoluted, let alone solving this. Math is NOT my strong suit at all.
With those caveats firmly in place…
A fixed pressure is fairly straightforward to deal with, but BiLevel machines complicate things by virtue of the sinusoidal pressure waveform plotted against time. The amplitude and frequency of that waveform differs from patient to patient, and with ASV, from breath to breath. So…
IF: Various masks come with a flow vs. pressure chart from the manufacturer. It would seem that the laws of fluid dynamics would dictate the increase/decrease in flow at various pressures for any given size port. If that is correct:
THEN: If you were to plot the data from perhaps a few masks from each category/type, a fairly narrow band of pressure vs. flow response would likely reveal itself.
Using that data, the above calculated intentional leak plot (for a given mask type) could be applied against the pressure waveform, i.e., the time spent at each pressure point along the gradient (AUC?) could be used to calculate the intentional leak at that specific moment. There would be an exponential increase in calculations as you use more pressure points along each waveform – I don’t know if that heavy computational load would slow down the program too much.
Is this pertinent? Or am I like a 9-year old expressing simple & already known concepts to Phd level minds?
With those caveats firmly in place…
A fixed pressure is fairly straightforward to deal with, but BiLevel machines complicate things by virtue of the sinusoidal pressure waveform plotted against time. The amplitude and frequency of that waveform differs from patient to patient, and with ASV, from breath to breath. So…
IF: Various masks come with a flow vs. pressure chart from the manufacturer. It would seem that the laws of fluid dynamics would dictate the increase/decrease in flow at various pressures for any given size port. If that is correct:
THEN: If you were to plot the data from perhaps a few masks from each category/type, a fairly narrow band of pressure vs. flow response would likely reveal itself.
Using that data, the above calculated intentional leak plot (for a given mask type) could be applied against the pressure waveform, i.e., the time spent at each pressure point along the gradient (AUC?) could be used to calculate the intentional leak at that specific moment. There would be an exponential increase in calculations as you use more pressure points along each waveform – I don’t know if that heavy computational load would slow down the program too much.
Is this pertinent? Or am I like a 9-year old expressing simple & already known concepts to Phd level minds?
_________________
Machine: ResMed AirCurve 10 ASV Machine with Heated Humidifier |
Mask: AirFit™ P10 Nasal Pillow CPAP Mask with Headgear |
“Ignorance” is not pejorative; it is simply a lack of information. “Stupidity” is an inability to utilize available information.
Re: Calculating Unintentional Leaks (Calling all maths geeks :)
Okay, I finally have extracted some csv data for tinkering..
http://sourceforge.net/projects/sleepyh ... v/download
It's in the simple format
pressure, leak, frequency
Edit: this data is taken from most of my last 10 months on CPAP, mostly on APAP, with a swiftFX mask
According to Encore and the couple of other people who've reviewed my data I've had reasonably low leaks.. (not exemplary by any means)
http://sourceforge.net/projects/sleepyh ... v/download
It's in the simple format
pressure, leak, frequency
Edit: this data is taken from most of my last 10 months on CPAP, mostly on APAP, with a swiftFX mask
According to Encore and the couple of other people who've reviewed my data I've had reasonably low leaks.. (not exemplary by any means)
_________________
Machine: ResMed AirSense™ 10 AutoSet™ CPAP Machine with HumidAir™ Heated Humidifier |
Mask: Swift™ FX Nasal Pillow CPAP Mask with Headgear |
Humidifier: S9™ Series H5i™ Heated Humidifier with Climate Control |
Additional Comments: CMS50D+/F Oximeter, S9 VPAP Auto/Adapt, PRS1 Auto, Intellipap Auto, SleepyHead :) |
Author of the free, cross platform, open-source sleep tracking software SleepyHead.
Download http://sleepyhead.jedimark.net
Source Code http://gitlab.com/sleepyhead/sleepyhead-code
Download http://sleepyhead.jedimark.net
Source Code http://gitlab.com/sleepyhead/sleepyhead-code
Re: Calculating Unintentional Leaks (Calling all maths geeks :)
Some OOCalc graphs
Pressures the X axis, Leaks the Y axis..
A bubble plot of the data I posted above (scatter plot looked like crud in oocalc)

Just a scatterplot of the 40th percentile extracted by my algorithm

The obvious outliers shown above are in positions with weak frequency data.. These could be filtered out and interpolated from a curve fitting algorithm?
Or a simple function could be estimated and I'll drop the other silly idea.. I'm just mostly useless with that kind of maths.. :-/
Pressures the X axis, Leaks the Y axis..
A bubble plot of the data I posted above (scatter plot looked like crud in oocalc)

Just a scatterplot of the 40th percentile extracted by my algorithm

The obvious outliers shown above are in positions with weak frequency data.. These could be filtered out and interpolated from a curve fitting algorithm?
Or a simple function could be estimated and I'll drop the other silly idea.. I'm just mostly useless with that kind of maths.. :-/
_________________
Machine: ResMed AirSense™ 10 AutoSet™ CPAP Machine with HumidAir™ Heated Humidifier |
Mask: Swift™ FX Nasal Pillow CPAP Mask with Headgear |
Humidifier: S9™ Series H5i™ Heated Humidifier with Climate Control |
Additional Comments: CMS50D+/F Oximeter, S9 VPAP Auto/Adapt, PRS1 Auto, Intellipap Auto, SleepyHead :) |
Author of the free, cross platform, open-source sleep tracking software SleepyHead.
Download http://sleepyhead.jedimark.net
Source Code http://gitlab.com/sleepyhead/sleepyhead-code
Download http://sleepyhead.jedimark.net
Source Code http://gitlab.com/sleepyhead/sleepyhead-code
Re: Calculating Unintentional Leaks (Calling all maths geeks :)
DoriC reminded me of this table:
http://www.internetage.com/cpapinfo/leak-rates-1.html
Playing around in oocalc... Looking at my algorithms extracted percentile data, I have found a simple linear interpolation algorithm fits the data set.
(doh! I was expecting something a little less linear and way more complicated.)
For example:
pressure bounds between 4.5 and 14, leaks between 14 and 31, according to weighted percentile data..
I have checked this against some of the table Dori mentioned, and appears to be consistent.. (Please feel free to double check..)
So if ignore the low count-weighted data from my statistical algorithms output, and take the first and last of the widest point between good data, or alternatively sum the result of the above algorithm of each good consecutive pair (or a random groupings) of valid input, I should be able to find an average fit, and provide an unintentional leak solution much more accurate than Encore does..
There is also the option of resurrecting the generic mask profile idea, and averaging the points from there.. (I still find this idea yucky, as most people change masks fairly often early on in their CPAP journey..)
Forgive me if that's what some of you were referring to up above.. It takes a while for the ol' light bulb to turn on for me sometimes..
http://www.internetage.com/cpapinfo/leak-rates-1.html
Playing around in oocalc... Looking at my algorithms extracted percentile data, I have found a simple linear interpolation algorithm fits the data set.
(doh! I was expecting something a little less linear and way more complicated.)
For example:
pressure bounds between 4.5 and 14, leaks between 14 and 31, according to weighted percentile data..
Code: Select all
minP=4.5 // Minimum Pressure
maxP=14 // Maximum Pressure
minL=16 // Minimum Leak
maxL=31 // Maximum Leak
leak=(pressure-minP) * ((maxL-minL) / (maxP-minP)) + minL
So if ignore the low count-weighted data from my statistical algorithms output, and take the first and last of the widest point between good data, or alternatively sum the result of the above algorithm of each good consecutive pair (or a random groupings) of valid input, I should be able to find an average fit, and provide an unintentional leak solution much more accurate than Encore does..
There is also the option of resurrecting the generic mask profile idea, and averaging the points from there.. (I still find this idea yucky, as most people change masks fairly often early on in their CPAP journey..)
Forgive me if that's what some of you were referring to up above.. It takes a while for the ol' light bulb to turn on for me sometimes..
_________________
Machine: ResMed AirSense™ 10 AutoSet™ CPAP Machine with HumidAir™ Heated Humidifier |
Mask: Swift™ FX Nasal Pillow CPAP Mask with Headgear |
Humidifier: S9™ Series H5i™ Heated Humidifier with Climate Control |
Additional Comments: CMS50D+/F Oximeter, S9 VPAP Auto/Adapt, PRS1 Auto, Intellipap Auto, SleepyHead :) |
Author of the free, cross platform, open-source sleep tracking software SleepyHead.
Download http://sleepyhead.jedimark.net
Source Code http://gitlab.com/sleepyhead/sleepyhead-code
Download http://sleepyhead.jedimark.net
Source Code http://gitlab.com/sleepyhead/sleepyhead-code
Re: Calculating Unintentional Leaks (Calling all maths geeks :)
I updated my copy of the code to vanilla git (none of my algorithmic poking) last night. What stuck out at me was how much the cooked leak values jumped when I turned off Flex. Overall, it is actually a small jump (as I saw with the raw values), but the scale makes it look massive.
_________________
Mask: AirFit™ P10 For Her Nasal Pillow CPAP Mask with Headgear |
Additional Comments: Software: SleepyHead, loosely following HEAD |
Re: Calculating Unintentional Leaks (Calling all maths geeks :)
tetragon wrote:I updated my copy of the code to vanilla git (none of my algorithmic poking) last night. What stuck out at me was how much the cooked leak values jumped when I turned off Flex. Overall, it is actually a small jump (as I saw with the raw values), but the scale makes it look massive.
I haven't pushed the actual code yet..
Edit: There may have been a very early version.. I can't remember :-/
_________________
Machine: ResMed AirSense™ 10 AutoSet™ CPAP Machine with HumidAir™ Heated Humidifier |
Mask: Swift™ FX Nasal Pillow CPAP Mask with Headgear |
Humidifier: S9™ Series H5i™ Heated Humidifier with Climate Control |
Additional Comments: CMS50D+/F Oximeter, S9 VPAP Auto/Adapt, PRS1 Auto, Intellipap Auto, SleepyHead :) |
Author of the free, cross platform, open-source sleep tracking software SleepyHead.
Download http://sleepyhead.jedimark.net
Source Code http://gitlab.com/sleepyhead/sleepyhead-code
Download http://sleepyhead.jedimark.net
Source Code http://gitlab.com/sleepyhead/sleepyhead-code
Re: Calculating Unintentional Leaks (Calling all maths geeks :)
I got a set of baseline data points by finding the tenth quantile of the leak rate for each pressure with at least 100 total observations.
I fitted both a simple linear model and a quadratic model to the data.
The simple linear model was okay, but the y intercept (leak rate at 0 pressure) was well above zero.
The quadratic model looked a lot better and the y intercept was close to zero. Interesting thing was the quadratic term was negative (leak increases slightly less than linearly).
Linear model: leak = 6.578 + 1.6518 * pressure
Quadratic model: leak = 0.178 + 3.14764 * pressure - 0.08292 * pressure^2
Very similar results (slightly different numbers) when I used the 5th quantile instead of the 10th.
Would be nice to have a couple of additional data sets.
I fitted both a simple linear model and a quadratic model to the data.
The simple linear model was okay, but the y intercept (leak rate at 0 pressure) was well above zero.
The quadratic model looked a lot better and the y intercept was close to zero. Interesting thing was the quadratic term was negative (leak increases slightly less than linearly).
Linear model: leak = 6.578 + 1.6518 * pressure
Quadratic model: leak = 0.178 + 3.14764 * pressure - 0.08292 * pressure^2
Very similar results (slightly different numbers) when I used the 5th quantile instead of the 10th.
Would be nice to have a couple of additional data sets.
_________________
Mask: Swift™ FX Nasal Pillow CPAP Mask with Headgear |
Humidifier: S9™ Series H5i™ Heated Humidifier with Climate Control |
Additional Comments: Pressure is 11-14. Old CPAP was a Resmed S6 Lightweight. Also have Profile lite mask. ResScan is actually version 3.14. Now I use Sleepyhead. |
Re: Calculating Unintentional Leaks (Calling all maths geeks :)
It doesn't help that my mask seems a lot on the low side.. it should be reading nearly 30% higher to fit in with the official mask profile for a Swift FX.JointPain wrote:I got a set of baseline data points by finding the tenth quantile of the leak rate for each pressure with at least 100 total observations.
I fitted both a simple linear model and a quadratic model to the data.
The simple linear model was okay, but the y intercept (leak rate at 0 pressure) was well above zero.
The quadratic model looked a lot better and the y intercept was close to zero. Interesting thing was the quadratic term was negative (leak increases slightly less than linearly).
Linear model: leak = 6.578 + 1.6518 * pressure
Quadratic model: leak = 0.178 + 3.14764 * pressure - 0.08292 * pressure^2
Very similar results (slightly different numbers) when I used the 5th quantile instead of the 10th.
Would be nice to have a couple of additional data sets.
I'm not sure why.. (although I wonder if the System One Resistance Setting has a bearing on this?)
I'm quite willing to try anyone's suggestions on this one.. I find implementing the maths in code is easy, but I'm far too foggy at the moment to do justice to this with my current solution.
I'm kinda going around in circles on this one
Unintentional Leaks are one thing I'd rather not screw up, as controlling leaks is vital to successful CPAP therapy.
(and a big reason in why I believe the designers of compliance only machines need to be strung up, beaten, and forced to use their crappy machines )
If there is a consensus on best reasonable case, I will implement it..
The same code will be needed for F&P machines too, as they only record total leaks too.
_________________
Machine: ResMed AirSense™ 10 AutoSet™ CPAP Machine with HumidAir™ Heated Humidifier |
Mask: Swift™ FX Nasal Pillow CPAP Mask with Headgear |
Humidifier: S9™ Series H5i™ Heated Humidifier with Climate Control |
Additional Comments: CMS50D+/F Oximeter, S9 VPAP Auto/Adapt, PRS1 Auto, Intellipap Auto, SleepyHead :) |
Author of the free, cross platform, open-source sleep tracking software SleepyHead.
Download http://sleepyhead.jedimark.net
Source Code http://gitlab.com/sleepyhead/sleepyhead-code
Download http://sleepyhead.jedimark.net
Source Code http://gitlab.com/sleepyhead/sleepyhead-code
Re: Calculating Unintentional Leaks (Calling all maths geeks :)
I doubt that Resistance Setting has anything to do with it. Even back when I was using the M Series machine (no Resistance Setting on those machines) when I would look at my Encore reports (total leak back then) I often saw the overall leak line being below the expected vent rate for my mask at my pressures.jedimark wrote:It doesn't help that my mask seems a lot on the low side.. it should be reading nearly 30% higher to fit in with the official mask profile for a Swift FX.
I'm not sure why.. (although I wonder if the System One Resistance Setting has a bearing on this?)
_________________
Machine: AirCurve™ 10 VAuto BiLevel Machine with HumidAir™ Heated Humidifier |
Additional Comments: Mask Bleep Eclipse https://bleepsleep.com/the-eclipse/ |
I may have to RISE but I refuse to SHINE.