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

10th
Jun 2015
diabeticgonewild
@diabeticgonewild
Jun 10 2015 00:06
FML been in bed all afternoon and evening cause I was so tired from the ordeal at the hospital yesterday. It sucks not having normal amounts of energy.
Scott Leibrand
@scottleibrand
Jun 10 2015 03:11
got @amazaheri all set up with OpenAPS, with homework to start making edits to the private repo. :-)
Dana Lewis
@danamlewis
Jun 10 2015 03:12
Woot! :)
Ben West
@bewest
Jun 10 2015 03:14
nice
make sure to add us as collaborators :-)
Scott Leibrand
@scottleibrand
Jun 10 2015 04:31
Same private repo you're already on. Hopefully we'll be seeing some pull requests soon. :-)
Ali Mazaheri
@amazaheri
Jun 10 2015 16:04
Feel like back in early 90's doing Novell, got punished by Scott for not using TAB very often though! :) I need a live tile for this Linux thingy lol
Paul Andrel
@stavlor
Jun 10 2015 16:09
lol
diabeticgonewild
@diabeticgonewild
Jun 10 2015 16:13
Yeah it's definitely crazy.
justinr1234
@justinr1234
Jun 10 2015 16:25
So I assume no one has tried to see if the USB COM port on the Tandem t:slim supports sending commands to the pump?
I also would assume the FDA made them disable that functionality
Eric
@ecc1
Jun 10 2015 16:39
I don't see why that follows -- USB requires physical access, so it's no more vulnerable than the pump itself.
But I often make the mistake of assuming gov't agencies will act rationally :-)
Toby Canning
@TC2013
Jun 10 2015 16:42
:)
Paul Andrel
@stavlor
Jun 10 2015 16:51
As if the US gov't or its agency's ever act rationally
justinr1234
@justinr1234
Jun 10 2015 16:56
I'm saying, similar to the way medtronic patched up the ability to have commands sent to it in later models .. I would assume that was motivated by the FDA telling them it was a security risk ... and therefore since Tandem is a new pump they were likely required to turn off the functionality in shipping pumps ... But I wanted to know if anyone had done any work confirming before I head down that path
Eric
@ecc1
Jun 10 2015 17:02
Right, but the Medtronic pump could be controlled by RF from across the room. Not familiar with Tandem, but I assumed you were talking about a USB port on the pump itself?
justinr1234
@justinr1234
Jun 10 2015 17:08
Yes .. it also has a bluetooth module inside of it .. but not sure if it is hard disabled from inside the firmware
Dana Lewis
@danamlewis
Jun 10 2015 17:18
No one has reported making any progress on tandem with usb that we've seen.
justinr1234
@justinr1234
Jun 10 2015 17:18
Thanks Dana
Nathan Racklyeft
@loudnate
Jun 10 2015 17:20
Hey all, wanted to share what I've been working on: https://github.com/loudnate/rpi-naterade
It's a relatively simple project based on @kenstack and @bustavo's GlucoDyn graph, modified to accept historical data gathered directly from openaps calls.
At the core is some code that turns MM pump history (including suspends, bolus wizards, journal markers) into a set of events of three types: bolus, carb, and "relative temp basal" (diff from current basal schedule). This has unit tests, and might be helpful in other folks projects.
You can see an example of my output (from 30 min ago) here: http://loudnate.github.io/rpi-naterade/
Jason Calabrese
@jasoncalabrese
Jun 10 2015 17:46
looks great @loudnate
I'm planning making the NS predications a plugin, so you could swap out AR2 for iob/cob, create something new, and maybe use multiples
Nathan Racklyeft
@loudnate
Jun 10 2015 17:49
Those will pull directly from NS data, then right?
I found some interesting quirks in my own pump data (in the Carelink CSV as well; not a decoding issue). Bolus Wizard history is sometimes logged twice, for example.
Nathan Racklyeft
@loudnate
Jun 10 2015 17:55
That and temp basal parsing wasn't simple. Adjustments across basal schedule boundaries, cancellations, suspend/resume events... Sharing those implementations (and their test cases) was a priority for me. If anyone has an idea for a good place to place that code in a shareable fashion, I'd be happy to lead that effort.
More eyeballs will make us all safer ;-)
Toby Canning
@TC2013
Jun 10 2015 17:59
@loudnate In the example graph you posted, what is the CAR and minutes delay (looks like none)?
Nathan Racklyeft
@loudnate
Jun 10 2015 18:07
Each CAR curve is starting at the time listed in the Input History section: 79 minutes and 174 minutes before I generated the graph
The curve is described here by @kenstack: https://github.com/kenstack/glucodyn/blob/master/basicmathv1.PDF
the carb effect prediction, as well as the insulin effect prediction, are both centered at the BG @ t0, which is a known value pulled from the CGM data.
Toby Canning
@TC2013
Jun 10 2015 18:55
@loudnate Thanks!
Ben West
@bewest
Jun 10 2015 19:06
welcome @amazaheri :-)
@loudnate that's awesome, I have some outstanding PRs from you and @fokko also, should get those in
Matthias Granberry
@mgranberry
Jun 10 2015 19:14
@justinr1234 it can, protected by a hard-coded key and the device serial number
@justinr1234 just need to get some kind of a hand-hold into the firmware to get the key they use
Nathan Racklyeft
@loudnate
Jun 10 2015 19:17
Thanks @bewest. Curious as to your vision of how the "predict" plugins will take shape for openaps. I'd be happy to port and conform parts of this.
Ben West
@bewest
Jun 10 2015 19:18
cool
yeah, should write more docs there somehow
important thing here are defining all those functions
Matthias Granberry
@mgranberry
Jun 10 2015 19:19
@justinr1234 and the BT module has been disabled in the firmware, but the commands are formatted to fit in BLE packets so they clearly intended for wireless access.
Ben West
@bewest
Jun 10 2015 19:19
to make things easy-ish, I provided a Use class in openaps for all to use
basically you can think of Use as very simple, well behaved console program
lot of boiler plate, but basically it makes it easy to run your plugin/app with some input and produce some output
the module as a whole implements a "vendor" in openaps
vendors are that potentially have one to many uses
openaps just knows how to find vendors and run configured uses
so any vendor you add like this can be configured exactly same way as all the other reports and stuff
justinr1234
@justinr1234
Jun 10 2015 19:22
@mgranberry Are you speaking of commands for reading data off the pump through their Virutal COM port?
Ben West
@bewest
Jun 10 2015 19:22
so vendor module needs get_uses to return all possible uses for this device... easy way to do that is subclass from Use and return list of them
set_config and display_device are used while configuring openaps to use this vendor
so assuming you have a python module foobar installed, and it has these functions and a docstring, you can add it to openaps as a possible vendor like this: openaps vendor add foobar
Matthias Granberry
@mgranberry
Jun 10 2015 19:24
@justinr1234 https://github.com/mgranberry/chrome-uploader/blob/tandem/lib/drivers/tandemTslimDriver.js has most of the VCP interaction information. It's not too hard to discover some more interesting things through fuzzing.
Ben West
@bewest
Jun 10 2015 19:24
after this, you can tell openaps to make the uses available by naming/creating a device that is that kind of vendor:
openaps device add myname foobar
Matthias Granberry
@mgranberry
Jun 10 2015 19:25
unfortunately Tandem put some protections in on the "riskier" commands, and I don't have good information on how to execute them
Ben West
@bewest
Jun 10 2015 19:25
the medtronic vendor uses that opportunity to collect/store serial number via set_config
now all the uses are available under the use menu
openaps use myname -h should list the uses you exported
from get_uses
my recent thinking is to allow aliases
so openaps get would become alias for openaps report invoke glucose.json history.json ...
Matthias Granberry
@mgranberry
Jun 10 2015 19:26
@justinr1234 if all you want is a data dump, all of the interesting stuff is there. I have some code somewhere that decodes pressure sensor data for fun, too, but it isn't too useful.
Ben West
@bewest
Jun 10 2015 19:26
and openaps would run the configured uses to generate all those reports
reports are just uses of devices with their configuration saved in the config
their output gets saved to file
so you can invoke bunch of desired reports all in one step, these steps would make up the openaps
the Use class, basically users subclass and define main at least https://github.com/openaps/openaps-agp/blob/master/openapscontrib/agp/__init__.py#L44-L56
the main function is what gets run as the main body of the program
there are bunch of ways to influence how config gets saved, as well as ways to customize output format for text, json, etc...
configure_app is given some context and the parser used for this app, and can add options using the parser object
parser is an instance of argparse
justinr1234
@justinr1234
Jun 10 2015 19:40
@mgranberry so what you're saying is that the "riskier" commands seem to be present, but figuring out how to actually execute them is unknown at this point ?
Matthias Granberry
@mgranberry
Jun 10 2015 19:41
@justinr1234 yes
Ben West
@bewest
Jun 10 2015 19:48
@loudnate, similar to gitweb et all it'd be cool to have server plugins
idea is all the static files/reports are the "active RAM" of openaps
need networking, ways to send data to pushover/notifications/twilio/nightscout, etc...
and having server to show dashboards seems natural
could push to github pages every 5 minutes ;-)
Matthias Granberry
@mgranberry
Jun 10 2015 19:54
@justinr1234 in their last quarterly report Tandem mentioned a reduced-size display-free t:sport pump in development that communicates to a phone over BLE to perform all control functions. Wireless control is coming, but there isn't really a public timeline.
hopefully the medtronic connect clears the regulatory pathway and comforts other manufacturers about the potential regulatory risks. I personally think that the benefits good real-time data access far outweigh any security risks, but doctors and the FDA are a funny bunch.
Nathan Racklyeft
@loudnate
Jun 10 2015 20:01
@bewest I was thinking about something a little more encapsulated for the prediction logic. The code today is a flask server only because it was easy to prototype. Network access is helpful and HTML is a simple way to bootstrap a UI, but not a necessary component.
Ben West
@bewest
Jun 10 2015 20:01
ah, all that was incidental
hehe
for prediction, I imagine something similar to agp
prediciton is a "calculator" of sorts
it takes some inputs, maybe has some tunable config, and comes up with an output
Nathan Racklyeft
@loudnate
Jun 10 2015 20:02
yep, but with multiple inputs
Ben West
@bewest
Jun 10 2015 20:03
yeah, it needs glucose, pump, what else? iob/temp-summaries?
Nathan Racklyeft
@loudnate
Jun 10 2015 20:03
An even smaller scale to simply smooth over bumps in mm history
Ben West
@bewest
Jun 10 2015 20:03
should there be a report which stitches these into a single prediction-input-summary report?
so that the prediction app is easier and takes one input?
Nathan Racklyeft
@loudnate
Jun 10 2015 20:03
Yeah, look at the GlucoDyn class in the repo I sent.
Ben West
@bewest
Jun 10 2015 20:04
report/use are interchangeable words there
Nathan Racklyeft
@loudnate
Jun 10 2015 20:04
Raw history, full basal schedule, zero time, and end time
Those four inputs create a series of (sanitized) events
Ben West
@bewest
Jun 10 2015 20:06
yeah, basically need all the schedules
Nathan Racklyeft
@loudnate
Jun 10 2015 20:06
Prediction can be determined from those events, so there's a natural encapsulation point there
Ben West
@bewest
Jun 10 2015 20:06
bg schedule, carb ratios, insulin sensitivities
Nathan Racklyeft
@loudnate
Jun 10 2015 20:07
Those are inputs to prediction but irrelevant to history gathering
Ben West
@bewest
Jun 10 2015 20:07
I see, so you'd also demand start/end explicit at that time as well
I see
the "get" side
something you could bundle with other "gets" if you wanted to do one big get step up front
Nathan Racklyeft
@loudnate
Jun 10 2015 20:07
The sim_length is only to manage missing boundaries for suspend/resume records
Ben West
@bewest
Jun 10 2015 20:08
yeah, it helps when interleaving the schedules later
Nathan Racklyeft
@loudnate
Jun 10 2015 20:08
Otherwise the content of the history input array is enough to dictate time period
Right, good point
Ben West
@bewest
Jun 10 2015 20:08
there are some edge cases jana at tidepool would love to chat about, hahaha
yeah, the issues you mentioned are all issues tidepool had problems with
Nathan Racklyeft
@loudnate
Jun 10 2015 20:08
I found a few! But I don't trust myself to find them all.
Send me your data @channel.
Ben West
@bewest
Jun 10 2015 20:09
this sounds good though
they haven't started working with medtronic pump data yet
they've been going solely off csv
Nathan Racklyeft
@loudnate
Jun 10 2015 20:09
Are they building open-source?
Ben West
@bewest
Jun 10 2015 20:09
at least pump memory data's order is always right
yeah, the source is all in the open, the planning/design process is hard to tap into
Nathan Racklyeft
@loudnate
Jun 10 2015 20:10
I actually found a few discrepancies there
See pump.py
Ben West
@bewest
Jun 10 2015 20:10
if you can imagine what they might do on their end
Nathan Racklyeft
@loudnate
Jun 10 2015 20:10
I didn't dig further though. Maybe I can patch decocare there.
Ben West
@bewest
Jun 10 2015 20:10
first, in the applet they compile binary "snapshots" which represent pump stuff
in csv land, when they export from their db
the records are lossy basically
there are several scenarios where the ordering can come back backwards
and because of the way pump ops are recorded (rather than theory of therapy, it's theory of operation) csv is tricky to get right when you need to interleave or depend on ordering to get things right
but with pump memory, the order is rigid
the oracle export/sorting basically, it's not gauranteed which order the records will come back in
so some of them will rotate positions
they also "insert" current settings et al with fake datetime as if they were historical events, set to the time of the auditing
decocare, I think attempts to preserve the ordering found in pump memory
would be nice to migrate smarts to sort through it and extract/interleave information to get sanitized reports somewhere
thinking openaps plugin would be good
there's a contrib package already out, maybe I should stub out empty vendor and let people add uses there, would simplify/reduce boilerplate to just subclassing Use
Ben West
@bewest
Jun 10 2015 20:16
Nathan Racklyeft
@loudnate
Jun 10 2015 20:17
Making that a vendor would mean multiple report files as input?
Ben West
@bewest
Jun 10 2015 20:17
a plugin is basically a vendor
vendor is the thing that provides implementation, knowledge for how to do stuff
but vendor gets expressed through a "devicee"
so plugin is basically vendor
user configures vendor to become a device
devices can be used
user teaches openaps about devices by configuring vendors
once openaps knows about devices, users can use/report them
so vendor basically has get_uses to tell openaps about potential uses
device is instance of vendor
vendor is implemented as module type
for multiple inputs
just use parser.add_argument(...)
in configure_app (self, app, parser)
Nathan Racklyeft
@loudnate
Jun 10 2015 20:20
Got it. So that would be pretty trivial to add to that class, but the user has a bit of a cognitive task of fetching the inputs
ah, only for use
openaps use is for experimenting with the uses and their inputs
openaps report is for configuring and running the uses with the config
Nathan Racklyeft
@loudnate
Jun 10 2015 20:21
But only a single use command per report
yes
but, openaps report invoke takes list of reports
so you can run bunch in one step, in order
Nathan Racklyeft
@loudnate
Jun 10 2015 20:22
That's good, ok.
Ben West
@bewest
Jun 10 2015 20:22
so you can have one prep prediction-summary-inputs.json early on as an output
that second bit with get_params is what openaps will use to save the config
Nathan Racklyeft
@loudnate
Jun 10 2015 20:23
There are dependencies between reports though, for example pump clock
Which is used to find latest glucose reading (and it's timestamp)
That subsequent glucose timestamp is an input to the history query, which might span multiple pages
Ben West
@bewest
Jun 10 2015 20:24
I imagine there will be several runs of openaps report invoke needed
we'll have to be careful determining which uses should take what parameters and emit what outputs
like we might add steps to create interstitial inputs/outputs if need be
in some cases I turned some of the tunable options/arguments into "program" type of input instead
so that the "program" could be captured as a report in earlier step and then fed to the thing as input rather than as option/config
Nathan Racklyeft
@loudnate
Jun 10 2015 20:26
What's an example?
Ben West
@bewest
Jun 10 2015 20:26
basal/bolus
way we've been doing that on cli is to have switches you can turn or parameters on commandline
instead I turned it into json object and require it as input, optionally through stdin
so now predictor thingy can prep that as the output
so clock.json gets saved early on
did similar with changing the clock
have been doing it as command argument/switch
changed it to take json input
happens to match json output
I do this for the things where the option/value needs to change depending on output of other uses
Nathan Racklyeft
@loudnate
Jun 10 2015 20:32
Got it, so I could certainly break pump.py into multiple commands accepting stdin
Ben West
@bewest
Jun 10 2015 20:32
for static values like max/min limits (num pages, num records max, basal limit) I use the usual --foo type of switches... the get_params function is used to record into openaps.ini for uses of the named report
yeah, probably more fine grained commands
Nathan Racklyeft
@loudnate
Jun 10 2015 20:33
And register each command as a plugin?
Ben West
@bewest
Jun 10 2015 20:33
I would bundle them in same vendor, so one plugin
but you'll have a new Use type of subclass for each "program" you want openaps to run
Nathan Racklyeft
@loudnate
Jun 10 2015 20:34
Got it.
Ben West
@bewest
Jun 10 2015 20:34
and get_uses will return list of them
if it's onerous, there's some tricks you can employ, in medtronic's vendor, I created somethin called SameNameCommand, which allowed me to whittle down definition to 3 lines when the name of the use matched the name of some existing public method
Ben West
@bewest
Jun 10 2015 20:56
your new commands will show up in menu under openaps use <users-name-for-your-device-implented-by-your-vendor> -h gives list of your "uses"
Gustavo
@bustavo
Jun 10 2015 22:12
@loudnate :D