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

27th
Nov 2015
Jim Matheson
@jmatheson
Nov 27 2015 00:03
@msrcgm I was stuck in a smilar place. To get the visualization working, the eaiest way is to set up Nightscout and have it pull and display the Dexcom BG data from one of the options found here: http://www.nightscout.info/wiki/welcome, if you have a G4 with share it would be this one http://www.nightscout.info/wiki/welcome/nightscout-with-ios-and-dexcom-share. Then you can upload pump data and other openaps data to Nightscout with the script that @scottleibrand mentioned.
I got stuck because I assumed since we had the BG data on the Pi that the upload script would upload BG as well, but it does not in the current iteration.
Ed Raskin
@msrcgm
Nov 27 2015 00:19
Thanks @jmatheson and @scottleibrand -- how do I run the script and what, if any, parameters do I need to change
diabeticgonewild
@diabeticgonewild
Nov 27 2015 01:51
So angry...I was one step away...that's right, one step away, from doing basic static tests before solving the whole entire problem on the first part of #VirtualPancreas, which creates distributions for the 22 parameters that represent ME, a unique patient, but could not get the function to work. After extensive Googling, it turns out that the program I was using, OpenBUGS, is incompatible for the 64 bit operating system for that particular function
So switching to PyMC which is better supported and can definitively handle this work too.
It was a single function out of several in OpenBUGS that would not work: car.normal(args)
car.normal is a special function, but PyMC can do it, too... http://glau.ca/?p=340
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:01
So, downloading Ubuntu/Linux now so I can install PyMC and the needed packages nicely. Fortunately PyMC is pretty much Python, so it is easy to pick up...
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:12

So I guess it's like way to be thankful on Thanksgiving, but programming that one last function that didn't even work blew it.

I guess I can be thankful that I concentrate better courtesy of a huge intravenous immunoglobulin dose, that was given to me yesterday, that comes from thousands of donors, although I still feel crappy from it cause it gives flu-like symptoms...

Chris Oattes
@cjo20
Nov 27 2015 02:22
or use a 32 bit version
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:24
Not going to work for how computational this is. On a 2013 3.0 GHz computer (probably an Intel Xenon desktop computer), it took on average 5 days to solve for each of the 12 individual patients.
Chris Oattes
@cjo20
Nov 27 2015 02:25
how many bits it is doesn't affect computation time like that
the only real difference 64 bits makes is the amount of memory you could potentially access
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:26
Yeah...
Chris Oattes
@cjo20
Nov 27 2015 02:26
and you potentially reduce memory usage going to 32 bit anyway, because you aren't storing 64 bit pointers everywhere
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:26
K
Chris Oattes
@cjo20
Nov 27 2015 02:26
how much RAM does it use while running?
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:26
Haven't tested that out.
A lot though
Chris Oattes
@cjo20
Nov 27 2015 02:27
what do you think is "a lot"
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:27
1,050,000 iterations per 72 data points....
4-6 GB RAM, if I were to guess
Chris Oattes
@cjo20
Nov 27 2015 02:27
iterating over something doesn't take a lot of memory
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:27
It's very math intensive
Chris Oattes
@cjo20
Nov 27 2015 02:28
yes, that's down to how many operations the processor does per second, not how many bits it is
what's important is how much memory is used during the iteration, not how many there are
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:28
I might whip out my old 32 bit netbook, for now...just to finish this up. I don't want to jump ship yet...
Chris Oattes
@cjo20
Nov 27 2015 02:28
or install a 32 bit version on whichever OS you're using
if it's Windows, you can just install the 32 bit version
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:29
Yeah, don't have a legal version of Windows. Can get Ubuntu 32-bit
Chris Oattes
@cjo20
Nov 27 2015 02:29
which OS are you using atm?
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:29
Just got down downloading 64 Bit Ubuntu
Windows 8.1 64 bit
Chris Oattes
@cjo20
Nov 27 2015 02:29
why can't you install 32 bit openBUGS on that?
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:30
Can upgrade to Windows 10, too, but scared to!
cause it doesn't have cross compatibility.
The OpenBUGS package is kind of crappy...
Chris Oattes
@cjo20
Nov 27 2015 02:31
have you tried it?
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:31
I am running the 32 bit version
It's listed in Program Files (x86)

An email on the OpenBUGS mailing list in July 2012 claims that the BlackBox tools have been abandoned by their own developers, which is why there's no true 64-bit OpenBUGS.

http://geospaced.blogspot.com/2013/04/why-you-should-not-use-winbugs-or.html

Blackbox is a compiler for the component pascal language, which OpenBUGS uses
Chris Oattes
@cjo20
Nov 27 2015 02:33
That says there isn't a 64-bit binary for OpenBUGS, not that it can't run on 64 bit versions of windows
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:34
It does run, but it causes an error, on a function I need
due to 64 bit incompatibility
Chris Oattes
@cjo20
Nov 27 2015 02:34
where is the 64 bit incompatibility documented?
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:35

It's sparsely documented in various places

https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=BUGS;2709616e.1210

2 other places it is documented, and trying to find those
Here's another place it's kind of documented, and I got the same exact error: https://www.mail-archive.com/r-sig-geo@stat.math.ethz.ch/msg08110.html
Chris Oattes
@cjo20
Nov 27 2015 02:37
Why not do what they suggested in that thread and use R2OpenBUGS?
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:38
Cause I don't actually read! ;)
I seriously don't....
I use screenreaders for heavy reading...
It does require an additional program though...I will give it a try...
I have R on my computer...it's free and open source.
diabeticgonewild
@diabeticgonewild
Nov 27 2015 02:52
I'm going to work on it tomorrow, and hope I can get it working!
I'm done with hardcore work for tonight!
On another note, in Denmark, for their AP being developed in-house, they are programming the controller with Java. I will find the document later, but it's true!
I may program the controller for my AP on the iPhone, using Apple's Swift programming language, which can handle differential equations and may possibly be robust enough
So, possibly an offline AP on IPhone with a Bluetooth RileyLink...
diabeticgonewild
@diabeticgonewild
Nov 27 2015 03:00
The course on the Swift programming language is here, from Stanford CS193P by Stanford (https://itun.es/us/dhNs5)
Chris Oattes
@cjo20
Nov 27 2015 03:00
I'm not sure I'd choose to program an AP in a language I haven't used before
diabeticgonewild
@diabeticgonewild
Nov 27 2015 03:18
True.
Probably will do so on the second iteration...
I'm pretty much too tired to work on the R2OpenBUGS stuff tonight... :(
Chris Oattes
@cjo20
Nov 27 2015 03:22
stop like you said you would then :P Bedtime for me
diabeticgonewild
@diabeticgonewild
Nov 27 2015 03:23
Good night! AND THANK YOU! <3
Jason Calabrese
@jasoncalabrese
Nov 27 2015 04:21
Screen Shot 2015-11-26 at 9.20.03 PM.png
Dana Lewis
@danamlewis
Nov 27 2015 04:21
Neat
Jason Calabrese
@jasoncalabrese
Nov 27 2015 04:21
maybe I won't have to watch ssh all night now
Dana Lewis
@danamlewis
Nov 27 2015 04:21
Ps see email just sent, apparently A is a good ambassador :)
Jason Calabrese
@jasoncalabrese
Nov 27 2015 04:22
always want to see what the calculations are
yeah, Andrew had fun, went to each table showing it off
was a good way to keep it in range too
Dana Lewis
@danamlewis
Nov 27 2015 04:26
Heh
kenstack
@kenstack
Nov 27 2015 05:10
blob
@cjo20 this is a bit better re the "increase" in the last few minutes - see what you think - if I dropped the order you lose the fit in the middle...
Chris Oattes
@cjo20
Nov 27 2015 10:28
@kenstack looks much better. How did you come up with that?
@kenstack only thing I'd question is whether the derivative should be 0 when it reaches the end of the action of the insulin or not. I don't have a feel for how much of an impact that has
Now even more famous :)
Oskar Pearson
@oskarpearson
Nov 27 2015 12:53
Has anyone been in touch with him? I'd like to pass on my support for thinking about us DIYers
kenstack
@kenstack
Nov 27 2015 15:35
@cjo20 good question - I would think so but the data that we are fitting is an approximate function - Walsh's curves definitely are not - I fit those by hand interpolating his curves so I was likely s bit off on the points - but if you look at his graphs the derivative is not zero at the end.
Chris Oattes
@cjo20
Nov 27 2015 15:38
kenstack: that's why i was trying to work out how to automatically generate the function given a set of desired parameters (dia, peak time, time taken to start working). I think I know how to do it, but the maths gets messy
It's probably just me being picky :P
kenstack
@kenstack
Nov 27 2015 15:44
:) you'll likely end up with a really high order function who's slopes in between your points will be really jagged - maybe assume a form that's smooth and give up some accuracy on the fit (remember Walsh are approximations) so should be fine either way
Chris Oattes
@cjo20
Nov 27 2015 15:46
kenstack: it'd be limited in the order it could pick. I think quartic is the highets with just dia and peak, and x^5 with "how long to kick in" too
kenstack
@kenstack
Nov 27 2015 15:47
Cool let me know ! How did the activity curves from the temp basals compare to oref ?
Chris Oattes
@cjo20
Nov 27 2015 15:48
The method I was looking at using was saying f(x) = ax^4 + bx^3 + cx^2 + dx + e, then generating f'(x) = 4ax^3 + 3bx^2 + 2cx + d, then f''(x) = 12ax^2 + 6bx + 2c
Then from there you can say that you want f'(x) = 0 when x = 0 (which means d = 0), and f'(x) = 0 when x = dia (which lets you fill in some values), and something similar (f''(x) = 0 when x = peak))
and saying f(x) = 1 when x =0, f(x) = 0 when x = dia
All of those together gives you enough information to solve the simultaneous equations, but if you leave 'peak' and 'dia' as variables then the formulas look really messy
I've not looked at the oref curves for basal. I'm not currently running oref.
Matthias Granberry
@mgranberry
Nov 27 2015 15:54
@cjo20 for a lot of things the 64-bit versions are significantly faster because of wider SIMD instructions and a larger register set.
Chris Oattes
@cjo20
Nov 27 2015 15:54
mgranberry: it doesn't sound like that application is particularly well developed, and auto-vectorisation to SIMD isn't particularly good in most cases
Matthias Granberry
@mgranberry
Nov 27 2015 15:55
that also sounds true.
Chris Oattes
@cjo20
Nov 27 2015 15:56
jasoncalabrese: that looks cool
Peter Miller
@ochenmiller
Nov 27 2015 16:08
@jasoncalabrese , awesome!
Chris Oattes
@cjo20
Nov 27 2015 16:11
kenstack: http://imgur.com/DtCSdvs.jpg is how far I've got with the method I described
Chris Oattes
@cjo20
Nov 27 2015 16:19
kenstack: although that looks like it won't find a solution when the peak is at exactly half DIA (because the numerator in the formula for a simplifes to 3(nn - 2pn). If p = 0.5 n, 2p = n, so it becomes 3(nn-n*n) = 3(0) = 0.
actually, that just means you don't need the quartic for that curve
kenstack
@kenstack
Nov 27 2015 16:38
Cool -you'll have 5 things you can specify so if you spec value and slope at the ends you'll get one value in the middle (peak I think in your case) to specify - I think you are on the right track but I'd also suggest to look at your own iob curve from a correction - my sons looks more like Walsh's shape but again it's all personal preference - these are all approximations - I'll take a look tonight family still in town
Chris Oattes
@cjo20
Nov 27 2015 16:45
kenstack: I can generate really nice curves if you set the peak to be half DIA, but anything else breaks it horribly :P
diabeticgonewild
@diabeticgonewild
Nov 27 2015 16:46
@cjo20 That looks nice!
Chris Oattes
@cjo20
Nov 27 2015 16:52
kenstack: try -1.0392E-09x4 + 7.17047E-07x3 + -0.000126263*x2 + 1
where x4 should be pow(x,4)
etc.
oh, and you'll probably want to multiply the constants by 100
That's not got a parameter for how long it takes to start dropping yet
Chris Oattes
@cjo20
Nov 27 2015 17:03
kenstack: it'd be interesting to see a comparison between that curve and your curve
Mark Wilson
@mddub
Nov 27 2015 17:17
@danamlewis @bewest so we were talking about why i love my onetouch ultralink meter, which sends bgs to my pump, even though it’s kind of bulky
i inadvertently had a demonstration of why that automatic upload is so valuable
step 1, put dexcom receiver in laundry
next, experience cgm withdrawal, test bg way more than ever did before cgm
while waiting, realize that even though i can't use the pi i brought home to start my loop, i can use it to talk to my pump
set up openaps, get pump history, see BGReceived entries, write script to upload them as if they are sgvs, see them instantly graphed on my watch
kenstack
@kenstack
Nov 27 2015 17:19
blob
Mark Wilson
@mddub
Nov 27 2015 17:19
write another script to summarize recent sgvs in NS from the openaps device as a string, put that string in status bar of watch
tweak a few watchface config variables to adjust layout
put loop in cron, now i have an upload-less meter bg log on my wrist
kenstack
@kenstack
Nov 27 2015 17:20
@cjo20 do you have mathematica? Its one line - just specify the last condition as you like
Mark Wilson
@mddub
Nov 27 2015 17:20
the whole thing is a little ridiculous... but also a pretty awesome validation of how quickly one can improvise with openaps now
kenstack
@kenstack
Nov 27 2015 17:20
@mddub awesome
Chris Oattes
@cjo20
Nov 27 2015 17:22
@mddub that's cool
kenstack: I don't (I'm at work atm)
Mark Wilson
@mddub
Nov 27 2015 17:22
@kenstack @cjo20 watching your curve fitting convo with excitement and envy... going from cgm to blood testing is (i imagine) much harsher than losing pump and going back to MDI
kenstack
@kenstack
Nov 27 2015 17:23
@cjo20 I think this is what you are looking for I did it symbolically now just put in the time and value of your point you want to force
Mark Wilson
@mddub
Nov 27 2015 17:23
so many risks i felt more comfortable taking before
kenstack
@kenstack
Nov 27 2015 17:23
blob
@mddub yeah ... my son was diagnosed 11 years ago - my first "open source" software was an excel sheet that did iob for shots..... wow....... insane
Chris Oattes
@cjo20
Nov 27 2015 17:25
kenstack: heh, that's cheating :P
very cool though.
kenstack
@kenstack
Nov 27 2015 17:26
only way I can keep up with all you young guys :) except for pierre he is older then me ;)
Chris Oattes
@cjo20
Nov 27 2015 17:26
To get the curve I just generated, I think you put in {f[0]=1, f[dia]=0, f'[0]=0, f'[dia]=0, f''[peak]=0}
Mark Wilson
@mddub
Nov 27 2015 17:26
i think you can adapt to any level of information/tooling, though... it took me the last couple days to unlearn my dependency on cgm and relearn intuition for timing and interpreting meter tests
the first day was miserable, but there was a weird cognitive dissonance because i knew i never actually felt so helpless before cgm
kenstack
@kenstack
Nov 27 2015 17:33
@cjo20 correct
@mddub yeah its strange being so dependent now
Chris Oattes
@cjo20
Nov 27 2015 17:34
kenstack: I think a better option for the delay in starting might be to up the order to 5 and put in a requirement that f[15] = 0.99 (or f[15] > 0.99, if it supports that)
rather than doing piecewise curves
I'll have to have a play with mathematica when I get home
ah, you have to buy it :(
kenstack
@kenstack
Nov 27 2015 17:39
@cjo20 piecewise always causes issues with numerical models at some point because discontinuities are not real - we can push the order higher or just leave it - all these curves generate a bit too much activity in the first 30 min but it is quite small - well within any kind of error bound
here is your peak calc
blob
mathematica is free on the pi I think, but its kinda slow :)
I think maple is still around - thats open source
Scott Leibrand
@scottleibrand
Nov 27 2015 17:45
@mddub you have a replacement receiver en route yet?
Mark Wilson
@mddub
Nov 27 2015 17:46
@scottleibrand no, customer service is closed until monday
kenstack
@kenstack
Nov 27 2015 17:46
@mddub do you need a receiver? Can overnight one of the old ones if you like with the pre 505
Mark Wilson
@mddub
Nov 27 2015 17:47
@kenstack thanks, that is super kind, but i can last until tuesday
kenstack
@kenstack
Nov 27 2015 17:48
if you sure ok - let me know asap I think the fedex hub near my house stops taking walkins in a few hours - its not a big deal - can prob do saturday delivery
Chris Hannemann
@channemann
Nov 27 2015 17:50
the whole thing is a little ridiculous... but also a pretty awesome validation of how quickly one can improvise with openaps now
THIS! This is such an important point, @mddub.
@mddub I have many receivers now, and I'll be home Saturday evening, so just let me know if you want one of them and we can meet up
@oskarpearson re: Wired article, yes, @bewest and I were connected with Dr. Klonoff and have spoken with him about device security a few times now, hence being included in that article
Mark Wilson
@mddub
Nov 27 2015 17:54
@kenstack @channemann thanks guys, i really appreciate it. i think i'm fine for now
Chris Hannemann
@channemann
Nov 27 2015 17:56
@mddub Dexcom is paying us to make sure you stay dependent on them and don't get any funny ideas
Scott Leibrand
@scottleibrand
Nov 27 2015 17:57
:+1: ;-)
Mark Wilson
@mddub
Nov 27 2015 17:58
ha! you are doing a great job
Chris Oattes
@cjo20
Nov 27 2015 17:58
kenstack: thanks for that. That's a much simpler formula than I came up with :)
kenstack
@kenstack
Nov 27 2015 18:04
@channemann dont mention that :)
Chris Oattes
@cjo20
Nov 27 2015 18:04
kenstack: would you be able to try one more thing for me, then I'll stop bugging you; generate an order 5 polynomial with an extra condition that f[strt]=0.999
kenstack
@kenstack
Nov 27 2015 18:06
@cjo20 no problem will do
kenstack
@kenstack
Nov 27 2015 18:14
@cjo20 here you go
blob
that will be impossible to retype sorry :) ill pm you the text version
Chris Oattes
@cjo20
Nov 27 2015 18:20
haha, thanks
kenstack
@kenstack
Nov 27 2015 18:20
sent it but gitter seems to be pulling out the multiplications signs sorry
Ben West
@bewest
Nov 27 2015 18:56
interesting: http://gort.io/
Dana Lewis
@danamlewis
Nov 27 2015 18:59
Did ya'll see the email from Gitter that they've got some improvements coming? finally
John Males
@johnmales
Nov 27 2015 19:12
Jason Calabrese
@jasoncalabrese
Nov 27 2015 19:17
@mddub thats cool
did you see what I'm doing with devicestatus?
think it will work for pump status from connect
Mark Wilson
@mddub
Nov 27 2015 19:47
@jasoncalabrese yeah, i saw your PR, it looks great
it's nice that we can show openaps iob just by looking at devicestatus instead of recalculating in NS
once the fields are nailed down, could more easily swap/compare openaps algorithms too
Jason Calabrese
@jasoncalabrese
Nov 27 2015 19:52
not sure if we'll need to keep uploading the iob from openaps, once we have the iob calculator in dcalc and both NS and oref0 use it recalculating should be fine
think I'm uploading the openaps status too often, I want to try doing something like only uploading every 5m, but faster when there is an action
right now I upload blindly ever 2m
don't really like how the treatment upload to NS from openaps is working when offline either
it makes the whole loop wait
need to pull it out of the main loop and use a separate cron for it, thats what I'm doing with the status upload and push to github
Pete Schwamb
@ps2
Nov 27 2015 20:08
In your PR, you mention that there will be a pump field in that structure. What would go in that field?
And specifically, would it replace other treatments records?
Jason Calabrese
@jasoncalabrese
Nov 27 2015 20:27
it's for pump status, not treatments
so things like battery, clock, reservoir, iob, etc
then with @mddub's PR we'll add IOB_SOURCE
Pete Schwamb
@ps2
Nov 27 2015 20:28
So IOB as calculated by pump, and not via history records?
Jason Calabrese
@jasoncalabrese
Nov 27 2015 20:28
yeah
Pete Schwamb
@ps2
Nov 27 2015 20:28
Ok, that makes sense.
Jason Calabrese
@jasoncalabrese
Nov 27 2015 20:29
think IOB_SOURCE would be overrideable on the client
and that we would have all available in some tool tip
also think we'll want pump plugin, but not sure what the pill would display
but the tooltip would have a the pump status info
Scott Leibrand
@scottleibrand
Nov 27 2015 20:39
@jasoncalabrese ready to merge to openaps dev?
Ben West
@bewest
Nov 27 2015 21:11
err... please be careful merging to master on openaps
on all these actually, there's a release process I go through to make sure the published distributions are up to date with the release tags, and to create the git tag
if you do a merge to master, make sure it's ready to tag as a release :-)
Dana Lewis
@danamlewis
Nov 27 2015 21:12
^dev? (But agree)
Scott Leibrand
@scottleibrand
Nov 27 2015 21:16
K. Can you write up the merge-to-master process somewhere I'll be able to find it when I forget? Maybe add a file in the repo?
Ben West
@bewest
Nov 27 2015 21:16
yeah, wondering where to put that
maybe in contributing
Scott Leibrand
@scottleibrand
Nov 27 2015 21:17
That works.
Jason Calabrese
@jasoncalabrese
Nov 27 2015 21:23
yeah, think openaps/oref0#33 is good, but doesn't have an example other that the usage in the script
nightscout/cgm-remote-monitor#1375 still needs some work and would be good if someone else could test
there are some settings that need to be adjusted for it to work in NS: https://github.com/nightscout/cgm-remote-monitor/pull/1375/files#diff-04c6e90faac2675aa89e2176d2eec7d8
since this is pulling down a lot more device status info than before we'll need to see if thats a problem, I made it an option so it wouldn't effect the basic NS use case
Scott Leibrand
@scottleibrand
Nov 27 2015 21:30
K, 33 merged
Will test the NS stuff after we get home this weekend.
Jason Calabrese
@jasoncalabrese
Nov 27 2015 21:34
any thoughts on pulling upload out of the loop?
Ben West
@bewest
Nov 27 2015 21:35
I'd kind of prefer having monitor, predict, control be iterative projects that build on prior work
Scott Leibrand
@scottleibrand
Nov 27 2015 21:35
Yeah, I wonder if that is a problem for us too. I really never watch what's going on when it's offline.
Ben West
@bewest
Nov 27 2015 21:35
oh, different issue
Jason Calabrese
@jasoncalabrese
Nov 27 2015 21:36
would like to add it to the ns-uploader-setup.sh script, but without the NS change it will break uploader batery monitoring in NS
Scott Leibrand
@scottleibrand
Nov 27 2015 21:36
I have ours set with a cron that kills any process older than 10m
Ben West
@bewest
Nov 27 2015 21:36
you can have a --config script
Jason Calabrese
@jasoncalabrese
Nov 27 2015 21:37
yeah, I have that too
Ben West
@bewest
Nov 27 2015 21:37
you can query NS api for version and sniff it
Jason Calabrese
@jasoncalabrese
Nov 27 2015 21:37
yeah, that would be good
Ben West
@bewest
Nov 27 2015 21:38
ns-get type status.json :-D
ns-get help has lots of ways to call it