Going back to the summer of last year, we rolled out an initial version of DynamicISF, based on user data gathered by Chris Wilson, and submitted to the Dev branch of AndroidAPS, where it has been working, alongside a version in FreeAPSX. Most of the details of that were discussed in this post.
Since the initial implementation, the model and deployment have been refined, to what we have today. This post provides an update on that.
Firstly, the DynamicISF calculation has evolved. It is now based around a natural logarithmic function that takes into account total daily dose of insulin, the peak time of the insulin and current glucose level. The equation is shown below:
variableSensitivity = 1800 / (tdd * (ln((glucoseStatus.glucose / insulinDivisor) + 1)))
As you can see, we’ve ended up in a place where it superficially appears similar to the “1800” rule.
TDD is total daily dose, modified by an adjustment factor if required. TDD is calculated using an average of the 7-day average TDD, the previous day’s TDD and an extrapolation of the weighted average of the last eight hours, weighted to the last four. This mix is used to try and capture whether more insulin is being used more recently and therefore indicates that a user may be less insulin sensitive.
There is an adjustment factor incorporated in preferences that allows a user to tweak the calculation by adjusting the TDD value up or down.
InsulinDivisor is a value based on the type of insulin used that varies with the peak time of the insulin in use.
This is the basic calculation of DynamicISF.
In addition, traditional Autosens value is replaced with a value that contains the rolling 24h TDD / 7 day average TDD.
Implementation – predictions
The above calculation is used to define sensitivity in multiple locations. Firstly, it defines the sensitivity where profile value was previously used. This is the starting sensitivity for predictions, and is also used in the CSF calculation.
In the latest version of the code (not yet in the AndroidAPS Dev repository), every prediction point that oref1 creates uses this equation to calculate the sensitivity for each point in the IOB, ZT and UAM curves. This means that the predictions for ZT and IOB result in lower values more quickly, and the UAM value results in a higher value more quickly.
The COB curve has been left to use the initial calculation, and therefore uses a static value throughout its prediction curve.
Implementation – dosing
The value of ISF used for calculating the insulin required for dosing uses the same calculation structure as defined previously, however, dependent on the current state of the glucose levels and recent history, it may use current glucose or the minimum predicted glucose, or a combination of both.
If glucose levels are climbing, only current glucose level is used.
If glucose levels are falling, the lower of minimum predicted value or current bg is used.
When levels are flat, an average value of current BG and lowest of current or minimum value is used.
This, in theory, allows a safer value when flat or falling.
Implementation – Low Glucose Suspend
In addition, the DynamicISF plugin also has a user definable “low glucose suspend” level.
In the standard code, the minimum threshold value is set at 65mg/dl, with a calculated update to the number on every loop cycle, and if the value is higher, that is used by the system.
In DynamicISF, the user can define the minimum threshold value upmto 100mg/dl, allowing an earlier low glucose suspend, should it be required.
DynamicISF remains an experimental approach to managing variability of ISF values with blood glucose level, a phenomenon that has been observed by many within the Diabetes community and some within the commercial APS community.
It remains to be seen whether this is the correct approach in the long run, and there are various conversations going on constantly about tweaks and modifications that may need to be made.
If you’re interested in this approach, feel free to check out the Dev branch of AndroidAPS and the predicted curves test branch at https://github.com/tim2000s/AndroidAPS-2/tree/dynisf_pred_curves