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

29th
Oct 2015
Tim Howard
@tghoward
Oct 29 2015 00:00
here's the top end of glucose.json
[
  {
    "packet_size": 0,
    "name": "DataEnd",
    "date": "2015-10-28T19:56:00",
    "date_type": "none",
    "_tell": 1,
    "op": "0x01"
  },
  {
    "name": "GlucoseSensorData",
    "date_type": "prevTimestamp",
    "_tell": 2,
    "sgv": 166,
    "date": "2015-10-28T19:51:00",
    "packet_size": 0,
    "op": 83
  },
Scott Leibrand
@scottleibrand
Oct 29 2015 00:01
we expect something more like this:
  {
    "_id": "563154ee37c3bd3fc78d877d",
    "sgv": 145,
    "date": 1446073507000,
    "dateString": "2015-10-28T23:05:07.000Z",
    "trend": 3,
    "direction": "FortyFiveUp",
    "device": "share2",
    "type": "sgv",
    "glucose": 145
  }
Tim Howard
@tghoward
Oct 29 2015 00:01
drat!
Scott Leibrand
@scottleibrand
Oct 29 2015 00:01
should be easy enough to convert it
Tim Howard
@tghoward
Oct 29 2015 00:01
so I'm using openaps straight up to get the MM cgm data
should I work up some post-processing?
Ben West
@bewest
Oct 29 2015 00:03
yeah, if you could put a little script together, that'd be great
Tim Howard
@tghoward
Oct 29 2015 00:03
:smile: :worried:
Ben West
@bewest
Oct 29 2015 00:03
json -e "this.glucose = this.sgv" is half of it
Tim Howard
@tghoward
Oct 29 2015 00:04
Ok, I can try to figure this out. Which fields are needed in each packet?
Ben West
@bewest
Oct 29 2015 00:04
not sure, I'd focus on identifying the glucose one
I'd use the timezone tools in openapscontrib to convert to zoned timestamps
Scott Leibrand
@scottleibrand
Oct 29 2015 00:04
he already has sgv
Ben West
@bewest
Oct 29 2015 00:04
then I'd rename/copy sgv -> glucose
but oref0 expects glucose
Scott Leibrand
@scottleibrand
Oct 29 2015 00:05
he just needs date and/or dateString
no it doesn't
other way around
Ben West
@bewest
Oct 29 2015 00:05
oh, maybe it's other way around
haha
yeah
Tim Howard
@tghoward
Oct 29 2015 00:06
datestring and glucose?
Ben West
@bewest
Oct 29 2015 00:06
so first thing I would do is run the timezone tool
main thing is the date field
yeah date, dateString, and timestamp
Tim Howard
@tghoward
Oct 29 2015 00:06
even if I'm in the right timezone?
Ben West
@bewest
Oct 29 2015 00:06
that data has no zone info
it's just like your microwave/car clock
running the timezone tool on it will add your local timezone to the data
Tim Howard
@tghoward
Oct 29 2015 00:07
ok - this is the tool in oref0
Ben West
@bewest
Oct 29 2015 00:08
once it's zoned, you can then run json -e "this.dateString = this.date; this.date = (new Date(Date.parse(this.dateString)).getTime( ))"
there
the timezone tool is in...
hmm
Tim Howard
@tghoward
Oct 29 2015 00:13
this?
sudo dpkg-reconfigure tzdata
Ben West
@bewest
Oct 29 2015 00:13
no
it's a python
do sudo easy_install -ZU openaps-contrib
Tim Howard
@tghoward
Oct 29 2015 00:13
good, because I had done that ...
done
output:
pi@betacb ~/bcb-s $ sudo easy_install -ZU openaps-contrib
Searching for openaps-contrib
Reading https://pypi.python.org/simple/openaps-contrib/
Best match: openaps-contrib 0.0.5
Downloading https://pypi.python.org/packages/2.7/o/openaps-contrib/openaps_contrib-0.0.5-py2.7.egg#md5=14d23ad1ec847b606641889e2af5a499
Processing openaps_contrib-0.0.5-py2.7.egg
creating /usr/local/lib/python2.7/dist-packages/openaps_contrib-0.0.5-py2.7.egg
Extracting openaps_contrib-0.0.5-py2.7.egg to /usr/local/lib/python2.7/dist-packages
Adding openaps-contrib 0.0.5 to easy-install.pth file

Installed /usr/local/lib/python2.7/dist-packages/openaps_contrib-0.0.5-py2.7.egg
Processing dependencies for openaps-contrib
Finished processing dependencies for openaps-contrib
Ben West
@bewest
Oct 29 2015 00:15
nice
I just updated it
like seconds ago :-)
ok
Tim Howard
@tghoward
Oct 29 2015 00:15
:smile:
Ben West
@bewest
Oct 29 2015 00:15
now you can do something like
openaps vendor add openapscontrib.timezones
openaps device add tz timezones
openaps use tz rezone --date date ./monitor/glucose.json
or you can pipe form iter_glucose_hours like this:
openaps use pump iter_glucose_hours 2 | openaps use tz rezone --date date -
Tim Howard
@tghoward
Oct 29 2015 00:20
woohoo!
[
  {
    "name": "DataEnd", 
    "date_type": "none", 
    "_tell": 1, 
    "packet_size": 0, 
    "date": "2015-10-28T20:21:00-04:00", 
    "op": "0x01"
  }, 
  {
    "name": "GlucoseSensorData", 
    "date_type": "prevTimestamp", 
    "_tell": 2, 
    "packet_size": 0, 
    "date": "2015-10-28T20:16:00-04:00", 
    "sgv": 152, 
    "op": 76
  },
Ben West
@bewest
Oct 29 2015 00:20
nice, you're zoned :-)
can save that in a report..
Tim Howard
@tghoward
Oct 29 2015 00:20
so, I need to massage output, or will new output be timezoned?
Ben West
@bewest
Oct 29 2015 00:21
well, save glucose as a report
and then save this as another report
Tim Howard
@tghoward
Oct 29 2015 00:21
got it -- massage output in a report
Ben West
@bewest
Oct 29 2015 00:21
yeah
for now, we're in early prototyping, so lots of reports to show what's happening between steps
makes it easy to step in and debug/change things on a whim
Tim Howard
@tghoward
Oct 29 2015 00:22
ok, thanks. And we assume I still need to change sgv to glucose
Ben West
@bewest
Oct 29 2015 00:22
apparently you don't need to do that
Tim Howard
@tghoward
Oct 29 2015 00:23
ok
Ben West
@bewest
Oct 29 2015 00:23
you can pipe all that for testing into
something liek this
openaps use pump iter_glucose_hours 2 | openaps use tz rezone --date date - | json -e "this.dateString = this.date; this.date = (new Date(Date.parse(this.dateString)).getTime( ))"
Tim Howard
@tghoward
Oct 29 2015 00:27
hmm don't seem to have json installed
bash: json: command not found
Ben West
@bewest
Oct 29 2015 00:28
sudo npm install -g json for that one
hmm, I jsut did one similar
Tim Howard
@tghoward
Oct 29 2015 00:30
install worked ... and 'use' command worked - I'll convert to a report
on second look
 {
    "body": "9d",
    "name": "CalBGForGH",
    "date_type": "minSpecific",
    "_tell": 33,
    "packet_size": 5,
    "raw": "93-99-1c-0f-9d",
    "amount": 157,
    "date": 1446074700000,
    "op": "0x0e",
    "dateString": "2015-10-28T19:25:00-04:00"
  }
note date is integer
Ben West
@bewest
Oct 29 2015 00:32
yup
this is for posting to NS?
Tim Howard
@tghoward
Oct 29 2015 00:32
yes, eventually,
now just need it for basal recommendations
Ben West
@bewest
Oct 29 2015 00:34
would also add another one | json -e "this.device = "openaps://medtronic/$model" or something
in that case
it also needs glucose
| json -e "this.glucose = this.sgv"
Tim Howard
@tghoward
Oct 29 2015 00:35
excellent, right
I'm following the structure! woohoo!
Ben West
@bewest
Oct 29 2015 00:35
hmmm
this already exists
mm-format-ns-glucose
do you have that tool?
oh, no need what you just did
that doesn't do the stuff you just did
Tim Howard
@tghoward
Oct 29 2015 00:38
output from mm-format-ns-glucose
 {
    "name": "GlucoseSensorData",
    "date_type": "prevTimestamp",
    "_tell": 16,
    "sgv": 162,
    "date": 1446075900000,
    "packet_size": 0,
    "op": 81,
    "dateString": "2015-10-28T19:45:00-0400",
    "type": "sgv",
    "device": "openaps://medtronic/pump/cgm"
  },
so, yes, missing glucose
but otherwise ok?
Ben West
@bewest
Oct 29 2015 00:40
ah, yeah
I'll make a patch to that tool
hmmm
Tim Howard
@tghoward
Oct 29 2015 00:47
proud of my alias
openaps alias add fixglucose "! mm-format-ns-glucose monitor/glucose.json | json -e 'this.glucose = this.sgv' > monitor/glucose.json"
Ben West
@bewest
Oct 29 2015 00:47
nice
yup, that's how you do it
hmm
that might not work
might just output to stdout
well, we'll see
you can add that alias as a process type of device and use it as report
Tim Howard
@tghoward
Oct 29 2015 00:49
:smile: yep!!! didn't work
Ben West
@bewest
Oct 29 2015 00:49
yeah
empties your file, eh?
hehe
just take out the redirect at the end I think
then you can add it as another device for reports...
Tim Howard
@tghoward
Oct 29 2015 00:49
add the alias as a device?
Ben West
@bewest
Oct 29 2015 00:50
openaps device add fixglucose process openaps fixglucose
sure ;-)
if it prints to stdout
when you add it as report, it will save it to the file
well, same deal, has to be a different file
Tim Howard
@tghoward
Oct 29 2015 00:52
huh. no it didn't print out to my screen
Ben West
@bewest
Oct 29 2015 00:52
the alias needs to be without the redirect
Tim Howard
@tghoward
Oct 29 2015 00:53
yes, took the redirect out -- note had to change the json call to single quotes -- that ok?
Ben West
@bewest
Oct 29 2015 00:53
yeah, that's fine
openaps use fixglucose monitor/glucose.json
that should run same way as alias basically
Tim Howard
@tghoward
Oct 29 2015 00:56
the alias
pi@betacb ~/bcb-s $ openaps alias add fixglucose "! mm-format-ns-glucose monitor/glucose.json | json -e 'this.glucose = this.sgv'"
added fixglucose ! mm-format-ns-glucose monitor/glucose.json | json -e 'this.glucose = this.sgv'
Ben West
@bewest
Oct 29 2015 00:59
looks ok
Tim Howard
@tghoward
Oct 29 2015 01:00
still not giving me anything onscreen ... can I pipe to stdout?
Ben West
@bewest
Oct 29 2015 01:01
the alias itself works, right?
oh
you need to run your glucose report again to get it
Tim Howard
@tghoward
Oct 29 2015 01:03
still nothing
pi@betacb ~/bcb-s $ openaps report invoke monitor/glucose.json
pump723://JSON/iter_glucose/monitor/glucose.json
reporting monitor/glucose.json
pi@betacb ~/bcb-s $ openaps fixglucose
pi@betacb ~/bcb-s $
Scott Leibrand
@scottleibrand
Oct 29 2015 01:04
Are you examining the file, or just expecting it on stdout?
Tim Howard
@tghoward
Oct 29 2015 01:04
at this point, just expecting on stdout
but here's the top
pi@betacb ~/bcb-s $ head -30 monitor/glucose.json 
[
  {
    "packet_size": 0, 
    "name": "DataEnd", 
    "date": "2015-10-28T21:01:00", 
    "date_type": "none", 
    "_tell": 1, 
    "op": "0x01"
  }, 
  {
    "name": "GlucoseSensorData", 
    "date_type": "prevTimestamp", 
    "_tell": 2, 
    "sgv": 148, 
    "date": "2015-10-28T20:56:00", 
    "packet_size": 0, 
    "op": 74
  },
Scott Leibrand
@scottleibrand
Oct 29 2015 01:05
cat monitor/glucose.json
nm, not sure.
Should be a report now though, not an alias, I'd think.
Tim Howard
@tghoward
Oct 29 2015 01:08
ok, thanks @scottleibrand and @bewest I am a heck of a lot closer than earlier and I know the path I need to go down. Appreciate it.
Ben West
@bewest
Oct 29 2015 01:10
if you can get that oref0 branch, I just mentioned you in a commit/branch
you can "add" device's similar to alias
with the patch you can call mm-format-ns-glucose --oref0 glucose.json
Tim Howard
@tghoward
Oct 29 2015 01:11
ok - I'll find it and merge it in!
Ben West
@bewest
Oct 29 2015 01:12
you can add that as a device: openaps device add fixglucose process mm-format-ns-glucose --oref0
then use it openaps use fixglucose shell monitor/glucose.json
Tim Howard
@tghoward
Oct 29 2015 01:25
fetched and merged. Will work on this tomorrow -- bedtime for me now. Thanks again!
Scott Leibrand
@scottleibrand
Oct 29 2015 02:43
@bewest so what's your latest-treatments device looks like? latest-treatments.ini is missing from the repo
trying to set up ns treatments uploading
Scott Leibrand
@scottleibrand
Oct 29 2015 03:42
pi@rpi3 ~/openaps-dev $ openaps vendor add openapscontrib.timezones
No module named openapscontrib.timezones
openapscontrib.timezones doesn't seem to be an importable python module
is there a way to install openapscontrib from the package, or do you have to git clone and setup.py it?
Jason Calabrese
@jasoncalabrese
Oct 29 2015 03:58
Nice
Thought I installed it from a clone, but that was a while ago, was thinking I'd have everything running from a clone of a fork
Ben West
@bewest
Oct 29 2015 06:28
$ cat latest-treatments.ini 
[device "latest-treatments"]
fields = 
cmd = nightscout
args = latest-openaps-treatment bewest.labs.diabetes.watch

bewest@hither:~/Documents/foo$
it's not in public repo because site name should be secret
@scottleibrand sudo easy_install openaps-contrib
Oskar Pearson
@oskarpearson
Oct 29 2015 07:05
Nice scripts, Scott
Ben West
@bewest
Oct 29 2015 19:02
hmmmmm
another git corruptino
they happen basically every day
gitpython-developers/GitPython#265
Ben West
@bewest
Oct 29 2015 19:24
nice
that actually perfectly explains what we've been seeing
I just looked through the code and I was doing exactly what he explained would cause the problem
openaps/openaps@b03492c
one line fix, requires essay to explain
Scott Leibrand
@scottleibrand
Oct 29 2015 19:58
That sounds promising.
Other thing I was thinking is to make my reset-git script just do a re-clone from github instead of an init
so you only lose data back to the last successful git push
with your one-branch-per-Pi idea of course
Ben West
@bewest
Oct 29 2015 20:00
yeah, you should pull from github
I only use master to cherrypick/checkout -f the openaps.ini and other select files now
scottleibrand @scottleibrand nods
Ben West
@bewest
Oct 29 2015 20:01
you can init a new one, that's fine
it's just a git repo
you can actually just init git repo and pull
and if pulling fails you can just touch openaps.ini
Scott Leibrand
@scottleibrand
Oct 29 2015 20:02
yeah, that would work too
just don't want to lose history
or have merge conflicts.
Ben West
@bewest
Oct 29 2015 20:02
if you pull from github you can always join/stitch them together
there's two ways
I use pull/merge
and then when there's conflicts, I force "all theirs"
or "all mine
"all mine"
whichever is more appropriate
Scott Leibrand
@scottleibrand
Oct 29 2015 20:03
We need to script that
i was never able to in a multi-Pi-per-branch setup
Ben West
@bewest
Oct 29 2015 20:03
"all theirs": git checkout -f origin/my-history -- .
git commit the result, it'll be clean
Scott Leibrand
@scottleibrand
Oct 29 2015 20:03
but it might work with one per branch.
Ben West
@bewest
Oct 29 2015 20:04
"all mine" git checkout -f HEAD -- .
Scott Leibrand
@scottleibrand
Oct 29 2015 20:04
Will need your help codifying that into oref0-reset-git.sh
Ben West
@bewest
Oct 29 2015 20:04
yeah
then, from their, I restored one of my corrupted ones
and was able to rebase -i it --onto my recovery branch
and merge that in also
diabeticgonewild
@diabeticgonewild
Oct 29 2015 20:16

This is kind of a crazy question, but it's not hard to answer:

I know that Medtronic pumps can only set basal rates at 30 minute interval lengths. Can you theoretically set up a cron job to set a temp basal (given a temp basal is running and still active) and override the current basal relatively easily?

The reason why I am asking this question, is cause I need to set basal rates every 15 minutes or so for my project, #VirtualPancreas, which actually I have come a long way with...
Scott Leibrand
@scottleibrand
Oct 29 2015 20:18
You can reset the basal every minute if you want. You just have to make sure that whatever basal you set is safe to run for the full 30m if you lose connectivity (as you often will).
So that means you'll usually want to sacrifice some speed of response (an additional 15m to deliver the intended additional insulin) in exchange for safety.
You can still recalculate every 5m as new data comes in, and issue new temps whenever you need to, but those rates will be lower than they might be if you could run them for just 15m or less.
diabeticgonewild
@diabeticgonewild
Oct 29 2015 20:21

Thank you! That's what I thought. I just wanted to confirm. I just wanted a heads up, in case I need to make any plans.

The specific reason why I asked was because I have to have my insulin dosing "optimized" when running the "experiment" that creates "a virtual copy of myself as a diabetes patient", to solve for the "unique parameters". The unique parameters allow me to make a copy of myself...

I will likely use #OpenAPS (with lots of practice and optimization) for the 18 hour data collection experiment.
diabeticgonewild
@diabeticgonewild
Oct 29 2015 20:26
The main paper that I am using for this portion of #VirtualPancreas, is not even remotely as scary as it seems. Stochastic Virtual Population of Subjects With
Type 1 Diabetes for the Assessment of Closed-Loop
Glucose Controllers. Even in the past 24 hours, it has become a lot less scary.
diabeticgonewild
@diabeticgonewild
Oct 29 2015 20:32
I think besides an artificial pancreas, for those of us involved in "designing our own devices", being able to "simulate somebody with diabetes" will be very rewarding, aside from safety and verification
But @scottleibrand I am not too worried about loss of data, even with #VirtualPancreas. It can be run offline, via a Minnowboard Max (like a Raspberry Pi, in the sense that it is a "System on a Chip", but MATLAB can run on it) but it is larger and not realistic for carrying around during the day, unless you have a big purse. I will eventually get to a point where I will want to be able to "switch back and forth" right away, by streamlining a "syncing" process....
diabeticgonewild
@diabeticgonewild
Oct 29 2015 20:37
For the implementation that is not offline, it will likely use a Verizon mobile USB stick, as Verizon is solid (except NOT outside the US, as it is a proprietary CDMA--not GSM network). If I do any international travel, I will likely have a mobile USB stick that can use T-Mobile....
But this isn't rocket science....but I do need to get back to work....
Dana Lewis
@danamlewis
Oct 29 2015 22:09
@bewest Great article you just posted to cgm in the cloud. Can you tweet, too, so I can rt you?
TY :)
Ben West
@bewest
Oct 29 2015 22:14
:-)
Ben West
@bewest
Oct 29 2015 23:36
this one show nice expected 90 minutes to action with temp basal
blob
blob