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

16th
Jan 2015
diabeticgonewild
@diabeticgonewild
Jan 16 2015 05:37
This message was deleted
This message was deleted
diabeticgonewild
@diabeticgonewild
Jan 16 2015 05:43

Does anyone model IOB?

I am pretty sure you can either do it pretty well and simply either using a natural log function or using differential equations. Obviously you would have to use numerical methods (such as numerical integration) for solving the differential equation in most programming languages.

Therefore, a natural log function would be more realistic.

Scott Leibrand
@scottleibrand
Jan 16 2015 05:45
Our IOB model is two quadratic equations.
kenstack
@kenstack
Jan 16 2015 06:19
@diabeticgonewild take a look at my ihawk repo I have done iob formulas from Walsh et al - they match quite closely with medtronics as well
I used a 4th order curve fit to walsh's curves
which are pretty well established
Scott Leibrand
@scottleibrand
Jan 16 2015 06:22
@kenstack: want to update wip/iob-cob with those?
kenstack
@kenstack
Jan 16 2015 06:24
@guatavo and I are working on some glucose dynamics - iob from Walsh and cob from Think Like a Pancreas (Scheiner) - first version will ignore hepatic and renal portions - goal is to predict bg as a function of time for various gi carb intakes and bolus/temp basal profiles - going to layer on to ns and other alarm systems at some point but first version will be stand alone - predict the curve. Want to add user defined cob curve option as well - I think there is a lot of variability person to person beyond standard curves - but first things first :)
In my repo I have a compare on the mdt curves vs Walsh vs my curve fit
Very interested to discuss the hovorka model sounds like you know it well. I'm very interested to understand the hepatic and renal terms and their importance is short term bg calcs (say over a few hours)
Sure - can you point me to where ? Or I can just send you the equations in javascript - whatveer is easier
@scottleibrand re point :)
Typo @gustavo sorry buddy :)
kenstack
@kenstack
Jan 16 2015 06:30
I have the basic model running in Mathematica if anyone wants to play with it with a few examples - bolus at same time of ingestion, pre bolus, super bolus, etc - I'll stick it in the new repo once I get it setup hopefully Tomorrow
Js soon
Scott Leibrand
@scottleibrand
Jan 16 2015 06:36
There is an iobcalc function IIRC, called from iobTotal, from predictDIYPS. In client.js.
kenstack
@kenstack
Jan 16 2015 06:39
Ok cool I'll look tomorrow and will ask questions - handling a low right now ugh .... Kid did a killer workout this evening .... Adding exercise also on my agenda for the simulation
Jason Calabrese
@jasoncalabrese
Jan 16 2015 08:13
my son started wearing a pebble, I put misfit on, sounds like their android app will sync it to their cloud service, then I can use an api to pull it down
maybe not the most accurate, but he's already wearing the pebble
Sulka Haro
@sulkaharo
Jan 16 2015 08:40
Interesting new non-invasive glucose sensor: http://pubs.acs.org/doi/abs/10.1021/ac504300n
Chris Oattes
@cjo20
Jan 16 2015 08:52
thats not really a new sensor. They're saying the idea is 'promising'
diabeticgonewild
@diabeticgonewild
Jan 16 2015 15:57

@kenstack , thank you. I will look at your iHawk repo for the IOB formulas. That is awesome!

Also, if you are using Hovorka's models, which all of the current AP projects in use in clinical trials use, keep in mind that they are all designed for use with Humalog only (not Novolog). However, Hovorka et al described in a paper how to deal with Novolog so that might be used as a modification of the Hovorka models. I can only get Novolog with my insurance, and I can't really appeal it. Anyways, the article is free and it's available here: http://www.ncbi.nlm.nih.gov/pmc/articles/PMC3876328/

Also, a close colleague of Hovorka did his doctoral dissertation on the most updated Hovorka models (as far as I know) to date, which can be found entirely here: http://digitool.library.mcgill.ca/webclient/StreamGate?folder_id=0&dvs=1421423512391~496

The dissertation is highly useful, as it's easy to get lost. The math gets really advanced with the relatively new carbohydrate absorption models, and quite intimidating. Markov Chain Monte Carlo, random walks, stochastic stuff, and Bayesian stuff, may actually be the death of me. However, if you stare at the paper and the equations long enough it starts to make more and more sense.

I hope this helps.

Jason Calabrese
@jasoncalabrese
Jan 16 2015 16:28
good info @diabeticgonewild, didn't know they adjusted the models for Humalog vs Novolog, just thought it was tested with Humalog
kenstack
@kenstack
Jan 16 2015 16:32
@diabeticgonewild thanks for the reference !!! I've got my basic model running now and im looking forward to reading more - most of the papers I read re havorka use a standard shape for carbs and iob which I think in practical terms will be limiting. I'm hoping to let people for their own. I'm really interested in understanding the importance of the renal and hepatic terms on say a 3-5 hour timeframe - I suspect they are small but need to confirm - it's also covered by your generic basal assuming bg isn't too high or low. I'll post the math and the model soon it basically takes the iob and carb calcs, does the math for sensitivity and carb factor and gives you the plots
Will be awesome to layer on live cgm and grt
bolus history to auto complete the entries for this.
My personal experience re novolog is the Walsh iob curves are pretty accurate at least in my sons case - though I eventually want to interpolate between choices of duration right now you have to pick by the hour like the pump - I think my kid is between 3 and 4 not one or the other
Intersted in other peoples opinion on novolog and iob - we use novolog
Jason Calabrese
@jasoncalabrese
Jan 16 2015 16:40
we use novolog, there are so many unmeasured inputs that I wonder how much of a difference Humalog vs Novolog makes, probably varies person to person
diabeticgonewild
@diabeticgonewild
Jan 16 2015 16:40

@jasoncalabrese , @kenstack , you're welcome!

I realized that the dissertation link won't bring you to the dissertation. Instead search for "External Artificial Pancreas for Type 1 Diabetes: Modeling and Control" (in quotes) in Google.

@kenstack , the standard shape was used because there were no previous studies using radioactive (isotopes) tracers in food to model carbohydrate absoprtion. The APs in clinical trials right now do not have a formally developed (updated) model for CHO absportion, which is a good reason for #WeAreNotWaiting . Hovorka et al published this infomation with updated models in 2012-2013, but I suspect even more work is needed.

Correct, @jasoncalabrese .
diabeticgonewild
@diabeticgonewild
Jan 16 2015 16:51
The dissertation essentially contains a more detailed explanation of what's going on from the models (including CHO absorption) in the published paper from IEEE, Stochastic Virtual Population of Subjects With Type 1 Diabetes for the Assessment of Closed-Loop Glucose Controllers. I have been using this dissertation so I don't get as lost.
Ben West
@bewest
Jan 16 2015 20:17
can't wait to get this updated running choice of algorithm http://212.71.251.86:8083/
kenstack
@kenstack
Jan 16 2015 20:46
Yeah the cob curves are highly dependent on so many things - far more variability then iob. I'm really thinking many people will want to measure standard foods with kids and then use their own curve fit (or tweak a generic function) to get the best fit for that type of food if it's not absorbing quickly - it's thenslower ones that can get you into trouble with modeling - the fast carbs - whether it's an s or a straight line - end up getting absorbed so fast you don't necessarily care what the curve is
Pizza is a prime example - those meals that mix fat with carbs
Ben West
@bewest
Jan 16 2015 20:56
those are tricky
they are often deceptive.... they seem fine.... because you are at normal bg for hours after
and then you go low
and then you go high for like 8 miserable hours
kenstack
@kenstack
Jan 16 2015 20:59
Yeah - there is just no easy way to model that from first principles - I think you need to curve fit your body's typical reaction
Ben West
@bewest
Jan 16 2015 20:59
yeah
all that is fine, it's designing the visualizations and the data to trust and verify
when I was first diagnosed, I had watched too much star trek... assumed there would be some magic visualization/process they ran to figure this out
oh the horror of the real world smacking me in the fingers
nope, they just divide/subtract/multiply
turns out their goal is just to not kill you
just not quite same goal as freedom from \$x
so I was able to take all my pump data and export into single json file
need to tweak the tools to make that easier
and maybe straight to csv somehow
as java stuff comes up, we'll need way to export very simple text version and just diff to compare
should be identical if it's js, java, python, whatever
I tweaked mm-latest to write json files, thinking ihawk should run the script and simply serve those files from json/data directory
Ben West
@bewest
Jan 16 2015 21:04
might be nice to have a way to choose only one thing to do, or maybe only print json somehow
really want to get your maths stuff into a predictor online
diabeticgonewild
@diabeticgonewild
Jan 16 2015 22:26

I am pretty sure in order to get an actual stable control loop (except overnight), given the current limitations of insulin latency and glucose sensor delays, you have to limit carbohydrates. For starters, that likely means no "normal" pizza, ice cream, candy bars, etc.

However, I would likely minimize carbohydrates in general, like Dr. Bernstein style, whenever I do implement the closed-loop in my life.

Dana Lewis
@danamlewis
Jan 16 2015 22:30
Yikes, ya'll, no! What we've learned with #DIYPS is it's not about the type of food, it's about the total # of carbs. that's why many people have lows, then rebound highs - because their insulin is stacked disproprtionate to the carb activity in the body!
Ben West
@bewest
Jan 16 2015 22:30
right
I'm describing the visceral effects of easily getting it wrong
Dana Lewis
@danamlewis
Jan 16 2015 22:31
I have stable closed loop activity, and excellent outcomes, with VERY few spikes >150 now and time in range often <120 for 24 hours and time in range >90%. And this includes SUPER high carb meals like 120g of pizza.
Ben West
@bewest
Jan 16 2015 22:31
insulin gets stacked in the wrong way, faster than the carbs
right, so pizza is better with sustaiined and managed extra insulin for long fat tail of activity
Dana Lewis
@danamlewis
Jan 16 2015 22:32
@bewest yes. Just scares me to see statements about needing to limit carbs, just because there's not enough mainstream systems that use carb absorption rates. Heck, none of the market ones use carb absorption rates.
but it's not even about the fat tail. it's pure carbs.
Ben West
@bewest
Jan 16 2015 22:32
yes, notice I said activity without specifying which
Dana Lewis
@danamlewis
Jan 16 2015 22:32
ah, I read "tail" regarding fat content, not "fat" as describing the tail :)
Ben West
@bewest
Jan 16 2015 22:34
@danamlewis I briefly sketched out areas for each social network, and ways we use them
Dana Lewis
@danamlewis
Jan 16 2015 22:34
I feel like I've had a lot of conversations lately about low-GI or low-carb as the way to manage diabetes. That's certainly an approach that some people take. But the average person is not going to do that. And I think we should continue to strive for a system that can support people with diabetes regardless of whichever meal strategy they think is right for them…versus saying "low carb" or "low GI" is the way to go. (In a lot of cases, that makes it even harder for people to get good nutrition in general, and if you add in celiac or any other complicating food factors, it's hard.) Just because the systems on the market aren't out there yet, doesn't mean we shouldn't keep building and pushing and advocating for doing the right thing. #wearenotwaiting and all that.
@bewest awesome
Ben West
@bewest
Jan 16 2015 22:35
would be great to drop in any stuff you've got on contributing
from gathering information from people
Dana Lewis
@danamlewis
Jan 16 2015 22:35
ya
Ben West
@bewest
Jan 16 2015 22:36
I will soon file something for decocare
so might be good to coordinate how much to include "user projects"
any word from mark/amy/medtronic?
Dana Lewis
@danamlewis
Jan 16 2015 22:38
Nope. Proposal submitted 11/30. Legally they have 90 days to respond…. :/ was going to wait til end of January and ping and see if that prompts anything
Ben West
@bewest
Jan 16 2015 22:39
hmmm
Dana Lewis
@danamlewis
Jan 16 2015 22:39
Did you ever formally submit?
Ben West
@bewest
Jan 16 2015 22:39
no, this other paperwork has kept me up at night :-)
fda asks you to assemble gap analysis... personally.... great.
hoping once I get through it I can copy/paste bits in to other useful things like proposals for research/grants
just got admin status, so I can generate charts from APIs now
Dana Lewis
@danamlewis
Jan 16 2015 22:41
K. Will keep you posted as I hear anything.
;) Good problems!
Ben West
@bewest
Jan 16 2015 22:42
well, I should have co-ordinated a bit more and submitted something
would have been good to press them at same time as fda
kenstack
@kenstack
Jan 16 2015 23:06
I setup a repo for glucodyn - will push somethjng tonight - no gui yet @gustavo is going to help with that. I think the carb discussion is a good one - everyone is completely different and reacts to carbs differnently - hence the need to program your own curves :) that's not in there yet but it's straightforward - im working on the medium and low gi math and hopefully will get that in there tonight - you have to change the parameters in the code for the events right now but Gustavo and I will get a nice gui soon. Then we can start pulling from decocare and the android stuff
Ryan loves to eat white rice - 60g of white rice (fast) looks a lot like the high gi curve I use - waffles are a bit slower but similar - hard to control for the spike with no Pepe bolus - even with a pre bolus he will head up 80 Pts or more most days if he eats nothing else on an empty stomach - i think for these large loads the super bolus is really cool but the sim shows you gotta be careful can go low first - I've seen that in him
kenstack
@kenstack
Jan 16 2015 23:15
Pre bolus not Pepe :)