hmm. At 3 pins, that first display there might be runnable from a wixel if it kept (ts, bg) logs

http://airpi.es/index.php is nifty

the way they set it up "buy the parts, step 1, step 2"

@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

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. :-)

it looked like an integral of a triangle to me

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.

yeah

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.

if we had aggregated data and a sign-off, we could fit our own easily enough

annotated aggregated data...

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.

hmm, maybe if you could select a region and annotate it

laters

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!

Going to bed early tonight

@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...

@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

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

but it's gold

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

I'm not going to do that

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.

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.

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

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

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

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

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

that can be accounted for with #OpenAPS and in my case, #VirtualPancreas

@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.

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.

Like yay digital hoarding, found this article by Heinemann Insulin Infusion Set: The Achilles Heel of Continuous

Subcutaneous Insulin Infusion

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

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.

it's not overfitting if it's done properly

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

you need a simple robust model to fit your data to

including hydration

have you even read that paper. It throws away a bunch of "credible" clamp studies

the Germans got it right

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

i don't read papers to figure out how to build a system, only to understand the underlying biology

I don't play around with things. I just can't with all of my medical crap. Hence, papers.

Better (safer) to be approximately right than precisely wrong.

you have to have a really good intuitive understanding of how calibrated your estimates are.

good luck with severe gastroparesis...

The danger with trusting the literature too much is that you won't be skeptical enough of your estimates when you get random noise

Like dude, 3 words, stochastic differential equations, I have this set.

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?

Seriously, not only can stochastic differential equations, the errors can be estimated and propragated...but I mean wikipedia

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

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

Yeah, be careful of black swans (non-normally-distributed noise)

that's why I am doing things a certain way

I don't doubt that it can be made better than guessing

covered for by random walks

yeah I am not guessing

You should read Taleb

3 parameters--1 multiplicative, 2 additive covered by random walks

those are non normally distrubuted

Black Swan, Fooled by Randomness, Antifragile, etc.

obviously the noise is not going to be normally distributed

seriously?

in stochastic differential equations...

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.

then why are the using FDA approved simulation models and even Hovorka has at least 3 papers (if not more) published about simulations

@diabeticgonewild simple systems are so much easier to make safe.

You still need to build a really robust and reactive system, no matter how good your simulator is.

Exactly.

simulation models can be verified. that's why I am doing that first

I mean, come on guys, I am working on an OpenAPS

@scottleibrand I think an MPC with a dose-limiting safety system could be quite effective

nonlinear model predictive control

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.

why would you think I would assume that?

I trust you won't.

there is a bolus calculator, a occlusion detector, etc in typical AP controllers

But the way you talk about the math makes me doubt sometimes.

it

OK, I mean that's a little bit weird even for you scott

I don't think you understand it all conceptually

Undoubtedly not. You'll have to try to educate me Tuesday. :-)

oh

it's the value judgements

just dial back the value judgements

one paper is not going to describe the only way to do something

I said it was for using euglycemic clamp.

like the Germans did get it right...even Walsh cites them

consistently

fine, but it doesn't imply anything about outside work being better or worse

@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

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?

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

yeah, *stochastic* differential equations

no, I'm saying don't take the papers as gospel. They've all gotten it wrong

i'm not

seriously this is ridiculous

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.

This is probably the kind of discussion that would work a lot better in person.

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.

it's best not to argue at people over the internet

pretty self explanatory

@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*

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.

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.
Heh, you'll have to do a lot worse than telling me about normal bodily functions to make me uncomfortable. :-)

Oh well I tried...

;-)

@bewest Hey Ben, are you around today?

yeah

want to chat?

Yes, can I give you a quick call though?

yeah