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
Ketoacidosis protection #107
Conversation
This is a very Changes should be done in the core oref algorithm (and if they are, they should be submitted to the OpenAPS repo first) not the abstraction layer. |
Have there been adverse events recorded that would make a change necessary? |
I haven't checked the code but the mere idea of this is very concerning. I
have periods with very low basal and that often gets reduced to zero
particularly during exercise. Any insulin added at this time would
definitely send me low or require me to eat unnecessarily. AAPS keeps me in
good shape with the current model and I object to the approach of this
change.
…On Wed, 9 Dec 2020, 22:44 swissalpine, ***@***.***> wrote:
This PR enables a ketoacedosis protection. There are two different
strategies for this:
1. A small basal rate when IOB is in negative range as if no basal
insulin has been delivered for one hour (zero temp is possible and the
small temporary basal rate is activated very rarely).
2. Every Zero Temp is replaced with a small TBR.
Both concepts have been tested by two different people over the last
two years We have not noticed any negative effects with regard to hypo
avoidance.
------------------------------
You can view, comment on, or merge this pull request online at:
#107
Commit Summary
- Merge pull request #1 from nightscout/dev
- Ketoacidosis Protection: Adjust TBR
- Ketoacidosis Protection: Settings
- Ketoacidosis Protection: Add keys and strings
- Code clean up
File Changes
- *M*
app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.java
<https://github.com/nightscout/AndroidAPS/pull/107/files#diff-98e2f804653a703c4fc06e2e40afd6ed79ffd4e8cd3eee137478c140f2b5869b>
(21)
- *M* app/src/main/res/values/strings.xml
<https://github.com/nightscout/AndroidAPS/pull/107/files#diff-5e01f7d37a66e4ca03deefc205d8e7008661cdd0284a05aaba1858e6b7bf9103>
(10)
- *M* app/src/main/res/xml/pref_openapssmb.xml
<https://github.com/nightscout/AndroidAPS/pull/107/files#diff-0e77eb2e8cb24f2b55bae4288a596475bf0769528609ccd640a88a373bcb0a27>
(34)
Patch Links:
- https://github.com/nightscout/AndroidAPS/pull/107.patch
- https://github.com/nightscout/AndroidAPS/pull/107.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#107>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAS7B3RSAIZYZIM2DO5U7UTST7VVBANCNFSM4UUDFZVA>
.
|
@ArthurusDent Thanks for your question. And yes, I wrote this for a person (a well known diabetic professional) who couldn't loop any other way because she has been shown to start a ketoacidotic episode after an hour of Zero Temp. She uses the 20% minimum strategy. @guydavies I myself had big problems with exercise, which also led to hours of Zero Temp, which led to massive drops in performance for me after about 2,5 hours. I use the variable strategy, so Zero Temp is possible, but only up to a certain limit of negative IOB. And: With a f. e. 30% temporary basal rate which kicks in at f. e. -0,7 U IOB I never seen any influence of my bg - but the good feeling not to have ketoacidosis problems. And: It is disabled by default. @Tornado-Tim Maybe you are right with your criticism and we must find another way to integrate this. BTW this is the first time that the concept behind was not convincing. Whenever I've explained it so far, it's been more of a "I want that too!", hence the PR. Interesting. Probably this is a problem of my english? |
@swissalpine, I tend to see this issue of long zero basal when my basal is already pretty small <0.2u/h. Thus, my insulin rarely goes negative due to active insulin still from earlier in the day and from previous meals. And if it does go negative, it’s by small amounts, which tend to be “handled” by the activity. I would definitely not be activating a feature such as the one you proposed because *for me* it would likely be dangerous.
… On 10 Dec 2020, at 16:24, swissalpine ***@***.***> wrote:
@ArthurusDent <https://github.com/ArthurusDent> Thanks for your question. And yes, I wrote this for a person (a well known diabetic professional) who couldn't loop any other way because she has been shown to start a ketoacidotic episode after an hour of Zero Temp. She uses the 20% minimum strategy.
@guydavies <https://github.com/guydavies> I myself had big problems with exercise, which also led to hours of Zero Temp, which led to massive drops in performance for me after about 2,5 hours. I use the variable strategy, so Zero Temp is possible, but only up to a certain limit of negative IOB. And: With a f. e. 30% temporary basal rate which kicks in at f. e. -0,7 U IOB I never seen any influence of my bg - but the good feeling not to have ketoacidosis problems. And: It is disabled by default.
@Tornado-Tim <https://github.com/Tornado-Tim> Maybe you are right with your criticism and we must find another way to integrate this.
However, these strategies do not interfere with the algorithm, but change the result at a time when the algorithm has already done its work. And that, as written, only as an option, only for those who want it.
And wouldn't it be a pity if AndroidAPS only discusses layouts and adds pretty graphics (I am exaggerating). Why not send a good idea the other way, give something back from AndroidAPS.
BTW this is the first time that the concept behind was not convincing. Whenever I've explained it so far, it's been more of a "I want that too!", hence the PR. Interesting. Probably this is a problem of my english?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#107 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAS7B3VED5GTLR4ZOUGKHUDSUDR3PANCNFSM4UUDFZVA>.
|
@swissalpine It does influence the algo in that the algo calculates with being able to withhold insulin, which is then overruled by AAPS. This might practically be negligible, but appending modifications that what OpenAPS has calculated isn't as simple as it seems. It's simple code-wise, but the overall complexity grows as OpenAPS now potentially works against what AAPS does and uses wrong assumptions. |
@swissalpine Ok, now I'm wondering to how many other people this applies to. I think it's important to know how much of an edge case this is. How did she determine that she was ketoacidotic? Is this just clinically detectable or does she get actual symptoms? |
I agree that this is probably not the safest approach for most people. Usually, when someone is zero temped for an hour or two, it's after a meal when they have lots of residual insulin activity, their BG is dropping, and the algorithm is attempting to counteract that as aggressively as it can to avoid hypoglycemia. Any restriction on the duration of zero temping or the minimum temp basal rate would require a considerable number of other changes in maximum safe insulin dosing given the inability to zero-temp as aggressively to counteract any overshoot. I don't think most AndroidAPS users would benefit from such changes, as it'd result in more and longer highs. I also agree that avoiding both ketoacidosis and hypoglycemia is something that can only reliably be done by alerting the user that carbs are required. If you wanted to expand the carbsReq feature to alert on scenarios where insulin activity (not IOB) is too negative and BG is still flat/dropping, that might be useful to a broader population. |
Thank you for the controversial discussion of the approach. I very much appreciate your approach to this idea! The problem with our loop algorithm is that it can only handle activity to a limited extent (and by activity I don't just mean sports). It works fantastically in bed as long as you don't move too much while doing it ..., and requires user intervention when activity goes beyond what is covered in the basal rate and factors. We help ourselves here with TT, with carbs or/and BR changes, some stop the loop. But there are also the things that the Loop can actually do without intervention: With the variable strategy zero temps are also possible over a longer period of time (with a bolus of 6 IU theoretically in my case over 8-9 hours zero temps), the concern that after a meal the 20% kick in and prevent the insulin saving is unfounded, at least with the variable strategy this cannot happen. And that this small basal amount has a massive effect with such a low IOB (as written with me of -0.7 U and lower), I have not noticed, because the IOB continues to fall and the BG should actually rise, which it just does not because of the activity. There is a little bit of insulin, which our body simply needs, nothing more ... In pre-loop times I reduced my basal rate, but never set it to zero during three hours. By the way, it is interesting that in the last weeks not even this protection was activated: because I was with cold symptoms exclusively at home and worked at the desk, hardly any movement, no sports.Normally, I have the phases in which the TBR kicks in about once a week. Based on my more than two years of self-experimentation (n=1), I simply cannot understand the concerns expressed and remain convinced that this means additional security (!) (for those who want it). There was no hypo associated with it. I am also surprised by the risk discussion. In my eyes, the interventions that Automation allows in AAPS are much more aggressively conceivable (e.g. profil increase by 30% with a delta of +1) and possibly more dangerous in combination with SMB. Automation interferes with the algorithm far more massively than the possibility discussed here. Perhaps the reservations are also directed primarily against the other strategy: The 20% always as keto protection are not my favored solution (although I also tried it on myself), but encounter a very special and certainly absolutely rare special case. But even this strategy did not cause any hypo problems, even if the 20% is called all the time, since every Zero Temp is replaced here ... Thanks for reading. |
You might be able to accomplish what you want by making the decision based on insulin activity instead of IOB. When you have a post-meal long zero temp, IOB can go very negative even as BGI from insulin activity is still positive or weakly negative. In your scenario of 3h of moderate activity without much insulin beforehand, BGI from insulin activity would go much more negative. You could also have the action resulting from going below the BGI threshold be a low temp target instead of a full override of the dosing decision. That way, if you’re at risk of a hypo despite the very negative BGI, it can keep zero temping, but resume insulin delivery sooner when it’s safe to do so. |
Apart from all the said above, the code would also need some cleanup:
|
@AdrianLxM Thanks for your review which is reasonable. I have corrected it and hope I have not made a mistake. @scottleibrand This "hack" is based on the total IOB (bolus and basal). Therefore, I do not quite understand why a "positive or weakly negative" BGI should be possible with a clearly negative total IOB. Or have I possibly translated the objection incorrectly? To show that zero temping is possible, here is a typical day when, as usual, the protection does not start: And here's a family hiking day from vacation (in August 2020) with some BG outliers; the arrow marks the 20% hypo-protection: Perhaps this will show the safety and impact of this approach (by the way, this was the last day I know of that protection was active). |
Insulin activity and BGI peak at about an hour after insulin is given or withheld, but IOB reflects that immediately. So IOB always goes negative before insulin activity goes negative and BGI goes positive, and vice versa. If someone’s BG is still being driven down by insulin activity, you wouldn’t want to prevent the loop from zero temping to counteract that. However, if their insulin activity is negative and BGI is positive (their BG should be rising sharply), you’re more likely to be in an insufficient-insulin situation (even if BG hasn’t started rising as fast as expected yet). In that situation it’s probably safe to allow some additional insulin to be given any time BG stops falling, which is easiest to implement with a low temp target. |
@scottleibrand Thanks for the explanations!
A temporary target is not safe enough for me, since it is not possible to predict how much insulin will really be delivered. Because in this case, 20-30% insulin may simply be necessary to avoid ketoacidosis. I assume this value, based on a guess (but no complete certainty) of my diabetologist Dr. Kröger. There are probably no studies on the question, with how much insulin a ketoacidosis can be safely avoided. |
Yes, combining both BGI and IOB seems like a good approach. If BG is < 60 mg/dL and flat/dropping, it's not safe to give even 20-30% insulin until BG starts to rise: mitigating any risk of hypoglycemia is more urgent than preventing euglycemic DKA. A temp target approach ensures that insulin is only given when hypoglycemia risk is mitigated, but there are other ways to do so as well. |
@swissalpine could you PR against oref repo, then update this PR if oref get updated with the changes? |
Dear All, |
@ulrikethurm when doing an identical hike with a minimum level of insulin, what happens to your BG? I would expect it to drop considerably, rather than stay in range. In that case, you would've had to eat carbs to bring blood sugar back up. Have you tried eating (and entering) the carbs first, rather than giving the insulin first and risking a low? Would it be useful to receive a carbs required notification when you've been receiving too little insulin, so you can eat and enter the carbs and get insulin dosing started? |
Dear Scott,
thank you very much for answering. Sure I could enter carbs, but the
hypoglyceamia is not my major concern. When watching CGM and getting the
pre alarm from xDrip+ I feel totally safe avoiding hypos. I am more
concerned about getting ketoacidosis, due to my extrem insulin
sensitivity I once got a ketoacidosis by just putting of the pump for
going into a sauna for only 60 minutes. O.k., due to the heat the
insulin resorption is faster, but it was just these 60 minutes without
insulin, which got me into ketocis, symptomatic and detected with blood
ketone measuring. So I personally feel so much safer, knowing that I
still have a minimum of insulin on board, without watching all the time
into my body waiting for a ketoacidosis to happen. I am not concerned
about the higher risk of a hypoglyceamia, because the CGM tells me
exactly, when to take what amount of carbs to avoid it, but with the
ketoacidosis there is no pre alarm, so without this protection I would
just go back to manually reduce the basal rate to my exercise profil and
stop the Loop. This ketoacidosos protection gives me my peace of mind
while looping. So for me this is the perfect tool to live with my DIY
Loop perfectly safe and trusting it in all situations. I could not do
this without it. I agree totally to your concerns, that this is not a
tool for everybody, but due to my extrem insulin sensitivity this is
heaven for me. Please give my deepest regards to Dana, we met in
Barcelona on the Hacking Health event. This ketoacidosis protection let
me finish a couple of half marathons and even a foll marathon without
hypos and without ketones, this is, was I was dreaming of. You made not
only the perfect christmas gift ever, I will always be thankful for all
the work (and there I mean all the developers who support us with so
many work the do). I can not thank you enough for that emprovement of my
quality of life. THANK you ALL, merry christmas and hopefully a better
2021, take care of yourself and stay healthy, THANK YOU, Ulrike
Am 19.12.2020 um 07:32 schrieb Scott Leibrand:
@ulrikethurm <https://github.com/ulrikethurm> when doing an identical
hike with a minimum level of insulin, what happens to your BG? I would
expect it to drop considerably, rather than stay in range. In that
case, you would've had to eat carbs to bring blood sugar back up. Have
you tried eating (and entering) the carbs first, rather than giving
the insulin first and risking a low? Would it be useful to receive a
carbs required notification when you've been receiving too little
insulin, so you can eat and enter the carbs and get insulin dosing
started?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#107 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADAEFJTRTLLXJ3RI4HGPWQLSVRCJHANCNFSM4UUDFZVA>.
--
Ulrike Thurm Diabetesberaterin DDG/ Systemischer Personal Coach ECA
Autorin: Diabetes- und Sportfibel/ CGM- und Insulinpumpenfibel Telefon:
+ 49 171 201 44 49 E-Mail: thurm@idaa.de
|
Thanks, that is helpful context. It sounds like someone should open a PR against oref0 that adds a few off-by-default (probably initially hidden) preferences that allows people to set a minimum IOB and insulin activity threshold, and a corresponding minimum % basal rate, if they want to take over more personal responsibility for avoiding lows in exchange for less worry about avoiding ketosis. We should also include reasonable maximum allowable values for all three thresholds. Once that is code reviewed and merged into oref0 for testing, someone can do the same on AndroidAPS. |
@ulrikethurm If you don't mind me asking... When you start experiencing ketoacidosis symptoms what sort of level of blood ketones are you seeing? |
Dear Brian,
I`ll get blood ketone levels above 1,0, last time 1,5 and symptomes like
cramps, vomiting and breathing problems - so quite clearly a
katoacidosis. I injekted insulin with a syringe (10 units per hour) till
the ketones went down below 0,6. Due to these reasons I do not go to a
sauna any more etc., meaning I do not disconnect my pump for longer than
30 minutes, all the best, Ulrike
Am 23.12.2020 um 22:04 schrieb Brian Quinion:
I am more concerned about getting ketoacidosis, due to my extrem
insulin sensitivity I once got a ketoacidosis by just putting
of the pump for going into a sauna for only 60 minutes. O.k., due
to the heat the insulin resorption is faster, but it was just
these 60 minutes without insulin, which got me into ketocis,
symptomatic and detected with blood ketone measuring.
@ulrikethurm <https://github.com/ulrikethurm> If you don't mind me
asking...
When you start experiencing ketoacidosis symptoms what sort of level
of blood ketones are you seeing?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#107 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADAEFJVPIWI4OPVCZX62CGLSWJLPPANCNFSM4UUDFZVA>.
--
Ulrike Thurm Diabetesberaterin DDG/ Systemischer Personal Coach ECA
Autorin: Diabetes- und Sportfibel/ CGM- und Insulinpumpenfibel Telefon:
+ 49 171 201 44 49 E-Mail: thurm@idaa.de
|
@Tornado-Tim @scottleibrand One more note on Ulrike's comments and Scott's response: |
The vast majority of people on any sort of APS (probably >99%) experience occasional hypoglycemia but never euglycemic DKA. The hard 20% minimum is more dangerous for them, so I don't want to include it if we can accomplish the same goal by ensuring minimum insulin delivery only when insulin activity and IOB are already low/negative. I can help with porting to oref0 if someone wants to hit me up on Slack and actively work on it with me. |
@scottleibrand I'm very busy the next two weeks but I will have a lool at openAPS repo and meet you on slack if I have an idea what to do ... Thanks for your support! |
I think the consensus is, that this topic needs further discussion. |
This PR enables a ketoacedosis protection. There are two different strategies for this:
Both concepts have been tested by two different people over the last two years We have not noticed any negative effects with regard to hypo avoidance.