These are chat archives for nightscout/intend-to-bolus

9th
May 2015
Matthias Granberry
@mgranberry
May 09 2015 01:09
hmm. At 3 pins, that first display there might be runnable from a wixel if it kept (ts, bg) logs
Ben West
@bewest
May 09 2015 01:12
the way they set it up "buy the parts, step 1, step 2"
Ben West
@bewest
May 09 2015 01:18
@scottleibrand or @danamlewis curious where the magic numbers, and peak = 75 are coming from https://github.com/bewest/openaps-example/blob/master/iob.js#L24-L35
Scott Leibrand
@scottleibrand
May 09 2015 01:21
75 minutes to peak insulin activity was empirical for Dana's case.
The other magic numbers come from a linear increase in insulin activity up from 0 to a peak at 75, followed by a linear decrease from there to 0 at 3h DIA
There is some calculus that would let you derive those formulas, but I actually did it in excel with a curve fit. :-)
Matthias Granberry
@mgranberry
May 09 2015 01:23
it looked like an integral of a triangle to me
Scott Leibrand
@scottleibrand
May 09 2015 01:24
We can abstract that part of the code modularly to allow swapping it out with the IOB curves that Monica Ken and others have derived.
Ben West
@bewest
May 09 2015 01:24
yeah
Scott Leibrand
@scottleibrand
May 09 2015 01:24
Although there may be IP concerns with using a curve designed to exactly match a pump maker's
Better IMO to have it based on empirical observations.
Matthias Granberry
@mgranberry
May 09 2015 01:25
if we had aggregated data and a sign-off, we could fit our own easily enough
annotated aggregated data...
Scott Leibrand
@scottleibrand
May 09 2015 01:29
Yeah, that would be ideal.
And yes, it is the integral of a triangle.
We should be able to aggregate the data from all OpenAPS n=1 trials to calculate real IOB decay curves.
Just BG data isn't really useful for that, nor is incomplete manually entered data.
So my only data source right now is Dana's data.
Up up and away! Laters.
Ben West
@bewest
May 09 2015 01:32
hmm, maybe if you could select a region and annotate it
laters
diabeticgonewild
@diabeticgonewild
May 09 2015 02:00
yeah I know why I was such in a bad mood this afternoon...I had dealt with insurance issues and I didn't eat lunch and slept for only like 4 hours last night...
On top of that, I get mail late, so mail comes around at like 5:30 and I got mail from HR regarding my health insurance over an issue that me and my family had contacted both HR and the health insurance company over multiple times, and what do you know? HR and health insurance both screwed up.
Like it's regarding termination of benefits which shouldn't have happened, at the end of the month...and we were trying to prevent it from happening for a couple of years now for me.
Like I seriously apologized to my mom for getting so upset...happy mother's day!
diabeticgonewild
@diabeticgonewild
May 09 2015 02:06
Going to bed early tonight
diabeticgonewild
@diabeticgonewild
May 09 2015 02:39
@bewest you don't need that kind of setup with the mobile computer if you enable VNC on Linux and use a VNC viewer on your mobile phone
I thought of that this morning, but didn't mention that
but going to bed soon...
diabeticgonewild
@diabeticgonewild
May 09 2015 02:55
@danamlewis @scottleibrand there is one article that describes how to derive IOB properly from euglycemic clamp studies
I can email that to you if you want it
same to @bewest
diabeticgonewild
@diabeticgonewild
May 09 2015 02:57
not even mathematical modeling
all you have to do is print out a letter size (full page) print out of one of the euglycemic glucose clamp studies from the Germans in particular that are by Heinemann, Rave, Becker (look specifically for those authors)
and just interpolate the x and y axes and fit the dat
This message was deleted
This message was deleted
but it's gold
This message was deleted
much simpler than mathematical modeling
just print out a full size of one of those glucose infusion rate graphs from a euglycemic clamp study from Heinemann, Becker, Rave for like Lispro, Aspart, or Glulisine
get a pencil and ruler
write down the x and y values
follow the instructions
Ben West
@bewest
May 09 2015 03:00
I'm not going to do that
diabeticgonewild
@diabeticgonewild
May 09 2015 03:00
and then fit the data
well that's what I did the first time around
not that hard
same amount of work as getting the data for the Medtronic Animas and Tandem t:slim pumps
just less boring :P
but that's how you derive IOB properly
instructions are in that article
it's the only article that goes over it properly. In English at least
like it's the only English source...the rest of it is in German...from the paper... Waldhäusl [52] (German Only!)
suggested the onset of action be defined as the
point of time at which—after subtraction of the
basal rate—5% of the total AUC has been
reached and the end of action as the point of
time at which 95% has been reached.
This is what they cited In: Waldhäusel W, Gries FA, eds. Diabetes
in der Praxis. Berlin: Springer-Verlag, 1993:
150–172.
No English pub...that article is the best we got for properly deriving IOB from Euglycemic clamp studies
diabeticgonewild
@diabeticgonewild
May 09 2015 03:06
Actually I should do that for like the insulins...again...
Like Apidra, Novolog, Humalog...
but properly according to those instructions, this time
like that single paper is the only legit source on it in English for getting IOB based off of Euglycemic Clamp studies
Matthias Granberry
@mgranberry
May 09 2015 03:10
but for any individual person/site/whatever, it's still all so variable from day to day
I'm not sure that in practice it makes any sense to be so precise about an average of highly variable subjects
diabeticgonewild
@diabeticgonewild
May 09 2015 03:12
IDK about that...it has been modeled more than a few times, see this for example http://lup.lub.lu.se/luur/download?func=downloadFile&recordOId=4216014&fileOId=4216015
the clamp studies themselves I mean
the German ones with the biostators are reliable
like those three authors: Heinemann, Rave, Becker -- are where it's at
Matthias Granberry
@mgranberry
May 09 2015 03:14
but the DIA decreases with the age of an infusion site and so many other factors, including exercise. You can be as precise as you want, but it is impossible to control so many factors. The best you can do is design the system to be safe and robust to perturbations and estimate DIA as one of the random variables
diabeticgonewild
@diabeticgonewild
May 09 2015 03:15
that can be accounted for with #OpenAPS and in my case, #VirtualPancreas
Scott Leibrand
@scottleibrand
May 09 2015 03:19
@mgranberry is right: we don't need a precise method to estimate IOB curves for the whole population. We need an easy method to calculate a reasonably accurate curve with limited data for a single individual over a short timeframe.
Matthias Granberry
@mgranberry
May 09 2015 03:19
right, but the IOB function will be variable. I was high earlier, so I injected a couple units into my calf and went for a jog. An hour later I was in the normal range and didn't drop any more because that's what happens when you inject into muscle. There will be significant differences in how things behave from person to person.
diabeticgonewild
@diabeticgonewild
May 09 2015 03:19
Like yay digital hoarding, found this article by Heinemann Insulin Infusion Set: The Achilles Heel of Continuous
Subcutaneous Insulin Infusion
well what you do is you make a precise one and then fit it to your data later on
that's what my strategy would be
it's the rate not the shape of the curve that we are interested in
Scott Leibrand
@scottleibrand
May 09 2015 03:20
How do you know the live data should be that particular shape?
IOB curve shapes are variable in the real world.
So overfitting is dangerous.
diabeticgonewild
@diabeticgonewild
May 09 2015 03:21
it's not overfitting if it's done properly
Matthias Granberry
@mgranberry
May 09 2015 03:21
exactly. I don't see a lot of inter-subject data in these studies, and I can tell you that I have big differences from day to day, depending on all sorts of things
Scott Leibrand
@scottleibrand
May 09 2015 03:21
you need a simple robust model to fit your data to
Matthias Granberry
@mgranberry
May 09 2015 03:21
including hydration
diabeticgonewild
@diabeticgonewild
May 09 2015 03:22
have you even read that paper. It throws away a bunch of "credible" clamp studies
This message was deleted
the Germans got it right
Matthias Granberry
@mgranberry
May 09 2015 03:23
I know that clamp studies are flawed, but there is danger in assuming that there is some perfect model to fit things to. It's better to have a simple well-behaved function to work with for optimization problems, which is what control reduces to
Scott Leibrand
@scottleibrand
May 09 2015 03:23
i don't read papers to figure out how to build a system, only to understand the underlying biology
diabeticgonewild
@diabeticgonewild
May 09 2015 03:24
I don't play around with things. I just can't with all of my medical crap. Hence, papers.
Scott Leibrand
@scottleibrand
May 09 2015 03:24
Better (safer) to be approximately right than precisely wrong.
you have to have a really good intuitive understanding of how calibrated your estimates are.
diabeticgonewild
@diabeticgonewild
May 09 2015 03:25
good luck with severe gastroparesis...
Scott Leibrand
@scottleibrand
May 09 2015 03:25
The danger with trusting the literature too much is that you won't be skeptical enough of your estimates when you get random noise
diabeticgonewild
@diabeticgonewild
May 09 2015 03:26
Like dude, 3 words, stochastic differential equations, I have this set.
Scott Leibrand
@scottleibrand
May 09 2015 03:27
Or you might have overconfidence. You can be more confident once you make predictions about the future and see how often they're correct.
you did that earlier, right?
what did the error bars look like at 30, 60, 90 minutes?
diabeticgonewild
@diabeticgonewild
May 09 2015 03:28
Seriously, not only can stochastic differential equations, the errors can be estimated and propragated...but I mean wikipedia
Matthias Granberry
@mgranberry
May 09 2015 03:28
but the food absorption will still be unpredictable. You can nail down insulin absorption as closely as you want (which I maintain is still highly variable), but gastroparesis will severely limit how much insulin prediction will help because you need to have an essentially reactive system to prevent severe hypos in that case
diabeticgonewild
@diabeticgonewild
May 09 2015 03:28
A stochastic differential equation (SDE) is a differential equation in which one or more of the terms is a stochastic process, resulting in a solution which is itself a stochastic process. SDEs are used to model diverse phenomena such as fluctuating stock prices or physical systems subject to thermal fluctuations. Typically, SDEs incorporate random white noise which can be thought of as the derivative of Brownian motion (or the Wiener process); however, it should be mentioned that other types of random fluctuations are possible, such as jump processes.
  • nonlinear model predictive controller = life is good
+
yeah man, that's what the controller is for...I mean, I have severe gastroparesis...sometimes I empty normally, sometimes I regurgitate food hours old and you can smell it like something is rotting...I hope you get the idea
Scott Leibrand
@scottleibrand
May 09 2015 03:30
Yeah, be careful of black swans (non-normally-distributed noise)
diabeticgonewild
@diabeticgonewild
May 09 2015 03:30
that's why I am doing things a certain way
Matthias Granberry
@mgranberry
May 09 2015 03:30
I don't doubt that it can be made better than guessing
diabeticgonewild
@diabeticgonewild
May 09 2015 03:30
covered for by random walks
yeah I am not guessing
Scott Leibrand
@scottleibrand
May 09 2015 03:31
You should read Taleb
diabeticgonewild
@diabeticgonewild
May 09 2015 03:31
3 parameters--1 multiplicative, 2 additive covered by random walks
those are non normally distrubuted
Scott Leibrand
@scottleibrand
May 09 2015 03:31
Black Swan, Fooled by Randomness, Antifragile, etc.
diabeticgonewild
@diabeticgonewild
May 09 2015 03:32
obviously the noise is not going to be normally distributed
seriously?
in stochastic differential equations...
Scott Leibrand
@scottleibrand
May 09 2015 03:33
a lot of people have lost a lot of money with precisely calibrated models of the world that turned out to be based on incorrect assumptions. You don't want to do that with your health.
Your approach is good, I think. (I don't understand the math.)
what I'm worried about is your overconfidence that the math represents reality and can be trusted as such.
diabeticgonewild
@diabeticgonewild
May 09 2015 03:34
then why are the using FDA approved simulation models and even Hovorka has at least 3 papers (if not more) published about simulations
Matthias Granberry
@mgranberry
May 09 2015 03:34
@diabeticgonewild simple systems are so much easier to make safe.
Scott Leibrand
@scottleibrand
May 09 2015 03:34
You still need to build a really robust and reactive system, no matter how good your simulator is.
Exactly.
diabeticgonewild
@diabeticgonewild
May 09 2015 03:35
simulation models can be verified. that's why I am doing that first
I mean, come on guys, I am working on an OpenAPS
Matthias Granberry
@mgranberry
May 09 2015 03:35
@scottleibrand I think an MPC with a dose-limiting safety system could be quite effective
diabeticgonewild
@diabeticgonewild
May 09 2015 03:35
nonlinear model predictive control
Scott Leibrand
@scottleibrand
May 09 2015 03:35
So, by all means build your virtual pancreas simulator. And verify it. But never trust it enough to bypass safety systems.
I don't know control theory enough to know MPCs and how they map to what we're doing.
diabeticgonewild
@diabeticgonewild
May 09 2015 03:36
why would you think I would assume that?
Scott Leibrand
@scottleibrand
May 09 2015 03:37
I trust you won't.
diabeticgonewild
@diabeticgonewild
May 09 2015 03:37
there is a bolus calculator, a occlusion detector, etc in typical AP controllers
Scott Leibrand
@scottleibrand
May 09 2015 03:37
But the way you talk about the math makes me doubt sometimes.
Ben West
@bewest
May 09 2015 03:37
it
diabeticgonewild
@diabeticgonewild
May 09 2015 03:37
OK, I mean that's a little bit weird even for you scott
I don't think you understand it all conceptually
Scott Leibrand
@scottleibrand
May 09 2015 03:38
Undoubtedly not. You'll have to try to educate me Tuesday. :-)
diabeticgonewild
@diabeticgonewild
May 09 2015 03:38
oh
Ben West
@bewest
May 09 2015 03:38
it's the value judgements
just dial back the value judgements
one paper is not going to describe the only way to do something
diabeticgonewild
@diabeticgonewild
May 09 2015 03:39
I said it was for using euglycemic clamp.
like the Germans did get it right...even Walsh cites them
consistently
Ben West
@bewest
May 09 2015 03:39
fine, but it doesn't imply anything about outside work being better or worse
Matthias Granberry
@mgranberry
May 09 2015 03:39
@diabeticgonewild but did they control for residual insulin production that has recently been shown to occur in T1s?
Science is never perfect, so don't get bogged down in the details
diabeticgonewild
@diabeticgonewild
May 09 2015 03:41
seriously guys...we are modeling something that has been in a pump since 2002...and you are looking to me to find some paper about residual insulin production for more accuracy and representation?
Matthias Granberry
@mgranberry
May 09 2015 03:41
a robust controller should be able to handle some incorrect model parameters, because there will be errors from all sides coming in. Don't design it to be too reliant on things actually working. Nothing actually works in the real world
diabeticgonewild
@diabeticgonewild
May 09 2015 03:41
yeah, stochastic differential equations
Matthias Granberry
@mgranberry
May 09 2015 03:41
no, I'm saying don't take the papers as gospel. They've all gotten it wrong
diabeticgonewild
@diabeticgonewild
May 09 2015 03:41
i'm not
seriously this is ridiculous
Matthias Granberry
@mgranberry
May 09 2015 03:43
sigh. Thanks for giving me the kick to do a decent AGP calculator. I think I need about 5-10% more basal going into the evening.
Scott Leibrand
@scottleibrand
May 09 2015 03:43
This is probably the kind of discussion that would work a lot better in person.
diabeticgonewild
@diabeticgonewild
May 09 2015 03:43
In an SDE, the prediction error is split into two noise terms. This separation ensures that the errors are uncorrelated and provides the possibility to pinpoint model deficiencies.
Ben West
@bewest
May 09 2015 03:43
it's best not to argue at people over the internet
pretty self explanatory
diabeticgonewild
@diabeticgonewild
May 09 2015 03:55
@bewest FYI I wasn't arguing...at least I didn't think so. I just felt like this conversation was super awkward. Like I have ~30 articles on euglycemic clamps and that paper had the most solid information for the work I did before by hand
Scott Leibrand
@scottleibrand
May 09 2015 04:23
Ah. The way you said it made at least some of us think you were implying that was the only valid way to calculate IOB.
diabeticgonewild
@diabeticgonewild
May 09 2015 04:24
no look I will admit it straight up because it will make all of the dudes uncomfortable and yes I am a b**** tonight....I'm not gonna lie. I'm PMSing and I am not usually this way. TMI but there you go guys.
Scott Leibrand
@scottleibrand
May 09 2015 04:27
Heh, you'll have to do a lot worse than telling me about normal bodily functions to make me uncomfortable. :-)
diabeticgonewild
@diabeticgonewild
May 09 2015 04:28
Oh well I tried...
Scott Leibrand
@scottleibrand
May 09 2015 04:28
;-)
Toby Canning
@TC2013
May 09 2015 19:16
@bewest Hey Ben, are you around today?
Ben West
@bewest
May 09 2015 19:26
yeah
want to chat?
Toby Canning
@TC2013
May 09 2015 19:28
Yes, can I give you a quick call though?
Ben West
@bewest
May 09 2015 19:28
yeah