-
Notifications
You must be signed in to change notification settings - Fork 395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autotune insulinPeakTime and insulinEndTime #1018
Conversation
Fixed DIA to constant value for finding peak time.
Conflicts: bin/oref0-set-device-clocks.sh package.json
Discussion: what are reasonable peak time? I am not necessarily comfortable with the above proposed defaults, without testing this on a wider set of data to see the range of tuned values. |
I think I need to build a dev rig that uses this and test it out. The ranges feel very wide. They may not be unreasonable, but given the data from clamp testing is generally a mean from a population, assuming a normal distribution I think these seem quite wide. |
I've installed 0.7.0 dev(edison), but this code with autotune peaktime doesn't work. --tune-dia-and-peak=true - unknown option. but with --tune-insulin-curve=true
|
If your |
Same symptoms as @vanzaam . Node -v gives v0.10.29. (which is 10?? or not?, version numbering confuses me) |
The first number provides the major revision, so v0.10.29 is prior to
version 1 which is very old, so you need to update to version 8 to fix the
compatibility issue.
Already-up-to-date from the git pull command means your local copy matches
the copy in your GitHub branch, so you should be good to go.
…On Thu, May 31, 2018 at 5:49 AM Tore Bjørndalen ***@***.***> wrote:
Same symptoms as @vanzaam <https://github.com/vanzaam> . Node -v gives
v0.10.29. (which is 10?? or not?, version numbering confuses me)
One other thing is that when I a set the branch to tune-dia-and-peak and
did git pull I was already "Already up-to-date."?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1018 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/Ag8XaJjRq_b6SdKKCkDWH9pUcbnODBq1ks5t38qwgaJpZM4UH_K->
.
|
When working on the new curves last summer, I noticed even an 10 minute change to the peak made a fairly large change in the maths, so going down to 35 minutes from he default peak of 55 sounds like a huge default delta. +/-20% tuning would be 10 minutes either way? |
+/-20% is a good rule of thumb for things that affect the total expected impact of insulin delivery, and therefore can directly result in +/-20% insulin delivery. The insulin timing parameters don't change the total area under the curve, though, so we can safely vary them much more, to better reflect the data, without risking hypos or DKA. We still need to run this algorithm (and various other fitness functions, such as RMS, sum of deviations, etc.) against multiple people's NS instances to see how much variance in insulinPeakTime and insulinEndTime we get from real-world data, but I expect that a 35 minute peak would be quite rare. It will probably be pretty common to see peaks extended by 20m or more, though. |
@jpcunningh thanks. I installed v8. I ran with option --tune-insulin-curve=true not --tune-dia-and-peak=true as stated by @scottleibrand at the top.
Should I change DIA on the pump? |
(Reminder - this branch is off of 0.7.0-dev. 0.7.0 and all related feature branches should not be used on primary rigs and should be closely monitored as they are highly WIP). |
I wouldn't make any changes to your pump at this point. We need to run this over multiple weeks worth of data, on multiple people's NS data, and see if it always converges on sensible values for insulinPeakTime and insulinEndTime. I also fixed my issue summary to use |
I’m looking forward to testing this. My gut feel is that over a longer period of time it should Autotune in some good mean peak and end times, but on shorter time frame data, we may find that timings change with ISF/exercise. I haven’t read through the code fully yet, but is there a weighting factor applied, similarly to ISF and CR? |
Just did a test run on a 0.7.0 rig.
Question: I would expect it to set insulinEndTime to 2 hours in this case. |
How did you get an insulinEndTime of 3? The minimum should be 5h. It won't always move things in the direction of the "best" value: it just changes things one "step" in that direction if both the mean and RMSDeviations are better at the next step. In other words, if all four comparisons don't agree it's better to shorten (or lengthen) it, it will remain unchanged. |
I am using a standalone VM to run this, as I am open looping. Wanted to share to see if this helps testing at all, as I saw you mentioned var versus let earlier in the thread, I wasnt sure if this was related: ref0-autotune-core autotune.2018-08-19.json profile.json profile.pump.json > newprofile.2018-08-19.json TypeError: Cannot read property 'meanDeviation' of undefined |
@sethgagnon does autotune.2018-08-19.json look complete? |
@scottleibrand here are the files that may help: |
Thanks. I'll see if I can reproduce the problem locally with your NS URL and enable some debugging to see why you got that error. |
no prob. if its something just specific to me, dont worry about it. i know
you have better things to be looking at then an issue that is only relevant
to me.
…On Mon, Aug 20, 2018 at 4:47 PM Scott Leibrand ***@***.***> wrote:
Thanks. I'll see if I can reproduce the problem locally with your NS URL
and enable some debugging to see why you got that error.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1018 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAkfxlwOkaNHj8XDkR7-_xM240qTowQxks5uSyB0gaJpZM4UH_K->
.
--
Seth Gagnon
|
Try adding |
I was able to reproduce the problem, and fix it with d6bf57d |
Now that this is in the Dev branch, is there anywhere to document that for the DIA and Peak Time tuning, you need to set InsulinPeakTime in preferences.json to the correct value as it doesn’t pick this data up from the selected curve? |
Just checked the output on my dev rig and it’s elected a peak of 75 on a Fiasp curve and with insulinPeakTime set to 55 and the log shows no reasons for the decision. |
@tim2000s can you paste the incorrect output, and the relevant settings files needed to reproduce? |
preferences.json:
and the log file from the run:
There is no data in the file for the DIA or peak adjustments. |
Just pushed a potential fix to dev (thanks @PieterGit for pointing out the missing |
If we are open looping using AndroidAPS, how can we edit our peak time to have the oref algo use it? |
I’m not familiar with that detail of the AndroidAPS implementation, so you might want to ask in their Gitter. |
@sethgagnon: yes its called free peak oref, you set the peaktime in the settings.... |
@scottleibrand - just realised that the lack of info about insulin action times was user error. Rectified that and will report the outcome. Had assumed that action time calculation was set to automatically true as they were being output in the log, but they still need flagging. Does raise a concern that they default to DIA 7 hours and peak at 75 mins even when not being run though, rather than picking up defaults from the preferences.json file. |
Okay, the re-run has caused a change in DIA and peak, once I'd corrected the settings, but I'm still seeing it starting at 75mins on Fiasp. It looks as though PieterGit’s change is now stopping the expression from using the custom insulin peak time, but hasn’t helped it to pick up the correct curve from preferences. .
and output from the grep:
|
One thing I’ve run into with this is that my rig overheated (no airflow issues) while charging and calculating insulinPeakTime sonit stopped looping. |
I’ve spent a fair bit of time playing with this this afternoon. The logic for invoking the 55 minute peak time seems to be evaluating to false constantly, and I think this is because it is not evaluating the Not sure why not though, as I’ve tried multiple iterations of it this afternoon. |
Might want to double check your input files: |
This was the output: preferences.json: "curve": "ultra-rapid", I think this is a similar issue to the one where you switch from >1 ISF, in that Autotune reuses its last version of a profile, so even when you update preferences, it perpetuates incorrect data. |
Yep, looks like it. Do we have an issue open on that? Want to work with me on figuring out and fixing the root cause? |
I’ll get one raised and happy to. |
@tim2000s @scottleibrand Just reading these issues again. I think the issue you raised with the stale autotune profile at #1018 (comment) is managed with issue #1093 and resolved with @jpcunningh PR #1101 @tim2000s Can you confirm that this is correct? |
I believe so. I never double checked though. @jpcunningh should be able to confirm. |
@tim2000s, @PieterGit, and @scottleibrand, #1101 doesn't maintain the curve, but something very similar could be submitted that pulls the curve from the pumpprofile. I created PR #1174 to do that. Comments are welcome as I haven't spent a lot of time thinking through all of the scenarios. |
This PR optionally (if
oref0-autotune
is run with--tune-insulin-curve=true
) allows autotune to find the best values for the insulinPeakTime and insulinEndTime parameters used by therapid-acting
andultra-rapid
exponential insulin activity curves. It does so by repeatedly re-running the autotune calculations for each insulinEndTime, +/- 2h from the current setting in 1h steps, and for each insulinPeakTime, +/- 10m from the current setting in 5m steps, and calculating the sum of the squared deviations categorized as basals. It then determines whether the run with the lowest sum of squared deviations was longer or shorter than the current setting, and if so, whether the next 1h/5m step in that direction is better than the current setting. If so, it tunes the setting by one 1h/5m step in the direction that showed improvement, and then repeats the process the next day.Since pump settings do not correspond in any meaningful way to insulinPeakTime and insulinEndTime, and since very few users know how to tune those values manually, the safety bounds for autotuning insulinPeakTime are simply set as a range of acceptable values for each insulin activity curve type: 35-100m peak for ultra-rapid, and 50-120m for others. Both curves enforce a minimum insulinEndTime of 5h, with (currently) no maximum.
Terminology note: insulinEndTime is currently equated with DIA, but this may need to be changed to improve understanding. DIA, as used by Medtronic and others, refers to the duration over which 90% of insulin activity occurs. In the exponential insulin activity curve model, but the insulinEndTime parameter is the time after which insulin activity is modeled to reach zero. See LoopKit/Loop#388 (comment) for details on the exponential curves used in OpenAPS. As a result, the best-fit insulinEndTime is usually at least 2x as long as what users considered their DIA to be in normal pump use. Users should not be surprised if the insulinEndTime / DIA calculated by autotune is considerably longer than what they would use in their insulin pump. Such long times do not indicate a problem with the autotune process: they're simply a result of the fact that insulin activity exponentially decays and takes a really long time to get completely down to zero.