Skip to content
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

Carbs Absorption Calculation (for discussion) #3359

Open
Philoul opened this issue Jun 1, 2024 · 7 comments
Open

Carbs Absorption Calculation (for discussion) #3359

Philoul opened this issue Jun 1, 2024 · 7 comments

Comments

@Philoul
Copy link
Contributor

Philoul commented Jun 1, 2024

I noticed updates in dev branch concerning Carb absorption calculation that leads (according to me) to wrong COB values or wrong decay of carbs when we use algo with variable Sensitivity (could be DynISF plugin or latest PR with AutoISF aligned with interfaces with APS plugins...

Previously, profile values were used to calculate COB, but now within IobCobOref1Worker, the sens value taken to calculate everything is Variable ISF if aps?.supportsDynamicIsf() is true

But currently the equivalent concerning aps?.supportsDynamicIc() is always false (currently not implemented nowhere neither within DynISF variant of APS algorithm, nor in AutoISF algorithm....
=> So on request (see line 207 in code below) profile.getIc(bgTime) will allways return profile IC value, when sens will allways get variable value calculated by DynISF algo (or AutoISF algo) (so this value can be much higher or lower than ISF value defined within profile for the same timeslot...

Considering that all variable APS algo reduce ISF value at high BG (to be more aggressive) and increase ISF value at low BG (to be less aggressive), that will lead to a Variable CSF value (ISF/IC) but for me in the wrong direction...
=> CSF will be lower at high BG (so carbs absorption will be accelerated, so will lead to lower COB results compared to a Fix CSF value due to profile only). I confirm on my side each time I was high with DynISF , COB decay is faster and UAM is detected (I stoped to use DynISF for this reason because ISF was always half the amount of my profile that works well)
=> CSF at low BG will be higher, so that will reduce carb absorption speed, so remaining COB will be higher compared to a fix CSF value due to profile only)... (I saw some screenshots in Discord with huge amount of remaing COB far from latest meal, associated with ahuge value of dynamic ISF and a low BG value)

Note that the Carbs absorption speed will be increased or reduced even when min_5m_carbimpart is used as security feature

image

image

This could lead for me to an over estimation of COB at low BG (so potential too strong calculated correction of remaining COB), and an under estimation of Carbs at high BG (so lower associated insulin, or increase unanounced meal detection when COB is down to 0)
=> I think we should probably consider CSF as a main parameter defined by user within profile (could be through IC and ISF values defined within profile), and not vary CSF according to bg value (or any other dynamic features of APS algo) to get same COB decrease speed whatever the level of BG vlaue

@vanelsberg
Copy link
Contributor

vanelsberg commented Jun 1, 2024

I think we should probably consider CSF as a main parameter defined by user within profile [...] to get same COB decrease speed whatever the level of BG value.

Good observation @Philoul! Yes, this fully matches my experiences with Dynamic ISF which I stopped using (I gave up after trying at least 3 times) because it absolutely does not work for me, i.m.h.o. mostly because of this.

For as far as I can see, there is no reason why CSF should vary on sensibility (rather than a fixed value derived from profile)

@lostboy86
Copy link

Same for me, for longest decay of COB. plus a strange auto-increase of a COB value sometimes

@parapenT1sta
Copy link
Contributor

For me becomes even stranger when using E-Carbs

@gerison77
Copy link

I therefore switched back to weighted average sensitivity because decay of carbs is calculated differently. I just now give it a testrun with dynisf since I quitted it immediately after the first try in oref.

@Philoul
Copy link
Contributor Author

Philoul commented Jul 8, 2024

I continue a bit more my formula analysis on this topic (see screenshot below),
image

So according to formula (don't hesitate to correct me if you think I made a mistake), variable ISF will have an impact on Carb absorption only if BG value change (rise of BG value) and when DEV is below min_5m_carbimpact: Carb Absorption speed will be higher when ISF is lower.

Carb absorption speed is not modified when BG value is constant between 2 BG readings and DEV is above min_5m_carbimpact (so with high insulin activity after the meal if BG value doesn't increase...)

Finally min_5m_carbimpact threshold is also impacted by variable ISF (a lower ISF value will generate more min_5m_carbimpact)

@Philoul
Copy link
Contributor Author

Philoul commented Jul 8, 2024

That said, if average variable ISF value is close to profile ISF, this will probably not have a huge impact on carb absorption speed, but if variable ISF is much higher, (or much lower) than profile ISF, then impact on Carb absorption can be important:

  • if average variable ISF is much lower than profile ISF: then you will have more min_5m_carbimpact, and after a meal (increase of BG value and high insulin activity), then COB reduction will be very important (it's exactly my situation with DynISF, meal Carbs can be down to zero in less than 1h or 1h30 after a meal, my DynISF is about Profile ISF/2 on target and can be Profile ISF / 3 at high BG). This can lead to an under estimation of remaining COB so can reduce insulin correction due to COB at high BG.
  • if average variable ISF is much higher than profile ISF, you will have less min_5m_carbimpact, and an important reduction of COB speed, even with min_5m_carbimpact (this can be critical if BG don't rise after the meal, because COB will be overestimated...)

@gerison77
Copy link

I am really glad, that you took up this issue. I made myself an excell sheet in which I can set CSF and calculate any combination of ISF and IC in order to get the same carbs decay in AAPS over my wohle circadian basal rate. It was much effort and the results not satisfying.

Is I wrote above I switched now to DynISF with weighted average sensitivty and I am impressed how good this works. I announce carbs though.

I hope the calculation of COB decay can be solved; since I would like to use UAMs as well, wich is not possible with the current sensitvity detection method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants