Calculate Insulin Effects accurately by taking into account ISF according to the schedule#588
Open
motinis wants to merge 9 commits intoLoopKit:devfrom
Open
Calculate Insulin Effects accurately by taking into account ISF according to the schedule#588motinis wants to merge 9 commits intoLoopKit:devfrom
motinis wants to merge 9 commits intoLoopKit:devfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Loop has historically used the ISF at the start of a dose to determine the ISF for the lifetime of the dose, ignoring changes to ISF (whether according to the regular schedule or via overrides).
This contribution changes this to using ISF over the lifetime of the dose. It does this by splitting the calculation in 2 parts:
Dosage determination is handled by considering the glucose effect change that would happen if giving 1U, and then scaling this to match Loop's existing criteria.
Note that the interpolation during dose determination is done for consistency, even though unitGlucoseEffect should be aligned on the same dates. The interpolation logic was originally implemented in #562 before being generalized in motinis@3040b7b and simplified for 1 value - it is designed to support interpolation as part of a loop where we want to continue to search for the next relevant data point(s) from where we left off at the previous iteration (so as to have O(n) behavior in the length of the data and not O(n^2)).