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

Prep for eventual 0.6.0 dev to master release #650

Merged
merged 146 commits into from Oct 5, 2017
Merged

Prep for eventual 0.6.0 dev to master release #650

merged 146 commits into from Oct 5, 2017

Conversation

danamlewis
Copy link
Contributor

@danamlewis danamlewis commented Sep 11, 2017

DEPRECATED - Please move comments and activity over to #694 for the 0.6.0 dev testing notes

Note: this next release will be a big release (from 0.5.3 to 0.6.0 to match the significant changes).

WARNING: This code is highly experimental and has many changes compared to 0.5.3. Do not implement this branch for testing unless you review the diff and plan to watch it closely. Also, do not change behaviors until you test the defaults of this branch. There may be some things not yet documented here that need to be documented; please comment on this thread or in channel to help note what needs documenting. Make sure you follow this PR so you will get notifications about changes to this branch. It is still changing feature-wise, so you will want to update as new features and bug fixes are added in.

See the bottom-most comment for how to install and run 0.6.0.

CHANGED: Default behavior change for carb absorption

In 0.6.0, carb absorption now uses a /\ shaped bilinear carb absorption model (replacing the previous --- shaped constant model for predicting the future absorption of newly entered carbs that haven't shown any effect on BG yet. As a result, the COB predBG purple prediction line immediately after entering carbs shows an S-curve shaped rise that starts out flat (in line with current BG trends), and then rises sharply after about an hour before flattening out.

  • A typical meal absorption time of 3h is assumed when carbs are first entered, which is then extended over time, so that oref0 gradually relies more on actual observed carb absorption as carbs are absorbed. When the carbs are first entered, remainingCATime is set to 3 hours. When 50% of carbs have absorbed, the remainder (that aren't seen to be absorbing already) are predicted to take another 4.5h. And as COB approaches zero, remainingCATime will approach 6 hours.
  • As in 0.5.3, any actual observed carb absorption will be predicted to continue into the future. The predCI assumed carb absorption described above only kicks in for carbs would not be absorbed within the current carb absorption time if the current carb absorption rate decreases linearly over that time.

Exponential Curves

The code now supports three new configuration variables in preferences.json to allow exponential curves that better reflect the effects of insulin:

  • curve, with legal values of blank, "bilinear", "rapid-acting" and "ultra-rapid"
  1. if left blank or set to "bilinear", OpenAPS uses the old insulin activity model

  2. If set to "ultra-rapid", the new curve model analyzed from publicly available data for Fiasp from Novo Nordisk is used, set to reach activity peak at 55 minutes

  3. If set to "rapid-acting", the new curve model analyzed from publicly available data for Novorapid (Novolog) from Novo Nordisk is used. This curve should match well to Novorapid, Novolog, Humalog and Apidra and is set to peak at 75 minutes

  • insulinPeakTime, with legal values from 35 to 120. The value defines the minutes from bolus to peak. Note if you don't set it, the above mentioned peak defaults are used.
  • useCustomPeakTime, which must be set to "true" for the customized insulinPeakTime value to take effect

In order to use the rapid-acting or ultra-rapid curves, your pump must be set to 5 hour DIA, or longer. 6 hours is recommended as the starting point.

The details of the curve calculations and discussions can be found PR #568

Enhanced SMB (eSMB)

Note: for folks with tiny basals (in this case, say <0.5u/hr), exercise even more caution, as additional tweaks may need to be made to SMB-related portions of the code.

The default behaviour for SMB is that the max bolus that can be delivered is no greater than 30 mins of basal insulin. An additional preferences value, "maxSMBBasalMinutes", has been added to allow SMB to deliver a different amount of insulin as an SMB. This gives the ability to make SMB more aggressive if you choose. As with standard SMB, it is triggered by temp targets, carb entries and a pump bolus.

Increasing "maxSMBBasalMinutes" will allow the SMB functionality to deliver more insulin, earlier in the SMB process.

"maxSMBBasalMinutes" can be added into myopenaps/preferences.json. It is recommended that the value is set to start at 30, in line with the default, and if you choose to increase this value, do so in no more than 15 minute increments, keeping a close eye on the effects of the changes.

It is not recommended to set this value higher than 90 mins, as this may affect the ability for the algorithm to safely zero temp. It is also recommended that pushover is used when setting the value to be greater than default, so that alerts are generated for any predicted lows or highs.

Other SMB adjustments include: The preference of enabling SMB to always be on. (Leaving this as false (off) means the existing SMB toggles for carbs, temp targets, etc. will be what drives SMB behaviors.)

Autotune adjustments

Autotune now tunes carb ratio directly, eliminating the previously known upward bias on ISF and carb ratio. This also smooths out mealtime basals based on surrounding hours when there's no data for tuning a particular hour due to meals.

Behavior change recommended as a result: You should be logging rescue carbs (carbs eaten for lows or predicted lows) so that Autotune knows about them. (Rescue carbs can be entered into Nightscout directly (i.e. NS website care portal, IFTTT buttons, etc.) or via the pump as long as they are accompanied by a 0.1 bolus. Any carb entry on the pump without a bolus is ignored by OpenAPS).

Troubleshooting

  1. Make sure you've fully installed (see next section), including remembering to re-set your preferences.
  2. If you're getting "not enacted" in Nightscout but are looping fine, update your Nightscout to the latest dev.

How to install 0.6.0

No-git to reduce git-related errors (recommended install process)

0.6.0 also has support for no-git-based-flow, to reduce errors for most users. Moving forward, it'll default to no git. In order to install, you'll want to first move a copy of your old myopenaps directory, then run oref0-setup. So to install 0.6.0 with nogit, do the following:

  1. cd ~/src/oref0 && git checkout dev && git pull
  2. npm run global-install
  3. cd && mv myopenaps/ backupmyopenaps/
  4. cd && backupmyopenaps/oref0-runagain.sh
    (Note - if you call your copy something other than backupmyopenaps, you'll want to also match that name in step 4.)
  5. Update your preferences.
    As always, after an update/runagain, you'll also want to go in and edit your preferences as well. Check the code diff here to see what the optional preferences are for 0.6.0 - they are not in the main docs yet.

Testing list before release

  • different time zones
  • PI/TI stick rig
  • WW pumps

Release checklist

  • Doc changes
  • Release notes

scottleibrand and others added 30 commits July 15, 2017 13:13
Number one error for beginners that blocks looping is when people don't have the pump set to absolute u/hr (in % basal type instead), which prevents the rig from being able to set temp basals.
* echo status

* try preflight twice

* check radio 10x, and mmtune if all checks fail

* echo Preflight when starting it

* mmtune 30% of the time

* it's ok if refresh_profile or refresh_pumphistory_24h fail

* Revert "check radio 10x, and mmtune if all checks fail"

This reverts commit 6ea8637.

* remove extra any_pump_comms debugging

* removing duplicate 30s wait_for_silence before mmtune

* show just last line of any_pump_comms 1 output when Radio check fails

* check radio thrice

* echo "Done waiting for rigs with better signal."

* case-insensitive grep to match 'Comms with pump detected' too

* print when preflight fails

* retry radio check one more time

* exponential backoff on Radio check

* echo -n . when retrying Radio check

* print any_pump_comms output when it doesn't succeed

* ignore mmeowlink-any-pump-comms.py exit code and just check output

* reduce debugging
scottleibrand and others added 14 commits September 23, 2017 23:55
)

* don't set temp first if temp duration >20m

* echo -n

* only refresh pumphistory (twice) if it's more than 30m old

* don't print enact/smb-suggested.json

* if pump is suspended, return false

* wait for bolus to complete and refresh pumphistory after SMB

* only refresh after SMB/enact; wait_for_silence 10 if bolusing

* syntax

* gather has a bolusing check; no need for a full smb_verify_status

* check for recent bolused.json instead

* make SMB model failure explicit

* echo -n

* 10s is too short for a 0.8U SMB: try a third time after 20s more

* refresh_profile every 5m after a temp set, every 15m otherwise

* print correct profileage

* refresh_profile every 3m after temp/SMB
* Put pump_loop_completed in /tmp/

Changes the location of pump_loop_completed from $directory/monitor/ to /tmp/ so it disappears after reboot.

* Update oref0-pump-loop.sh
* print hour numbers in autosens output

* better differentiate hours from grams
* properly calculate minguardBG if COB==0 and UAM is off

* properly calculate minguardBG if COB==0 and UAM is off

* typo
Project remaining carb absorption time based on % carbs absorbed
* recalculate IOB and predBGs after refreshing everything

* don't print determine-basal output

* no need to refresh temp again or display suggested.json output

* print new IOB from refreshed smb-suggested.json

* no newline after Settings line
@scottleibrand
Copy link
Contributor

scottleibrand commented Sep 26, 2017

Historical note: In an early version (now outdated) of the dev branch, the duration of this predicted carb absorption was modified by setting temp targets ( predicted carb absorption time for not-yet-absorbing COB was 4h; (low) temp target and have carbs on board or entered, expedited the carb absorption time to be 3 hours.; n "activity mode" (higher) temp target changed the remainingCI time to be >4 hours (as well as temporarily disabling SMB, as it does in 0.5.3); )

This behavior of controlling carb absorption time via temp targets has since been replaced with more automatic heuristics described in the issue summary above.

* remove extra minPredBG in rT object

* remove extra minPredBG in rT object
* ignore last CR period if COB > 0 at midnight

* allow slightly positive avgDeltas to contribute to ISF to remove upward bias

* capture 12h more for UTC-dated treatments

* downgrade API_SECRET check to a warning, as readable sites work w/o it

* cap ISF and CR before adjusting, not just after

* debugging

* don't recategorize ISF as basal if BGI > 0 and ISF < 0

* use avgDeltas up to -2*BGI for ISF

* allow full autotune ISF adjustment now that safety caps fully apply

* apply 20% of ISF adjustment now

* remove CSF now that it's not used for anything

* comment out unused code

* only use CSF data if UAM data is insufficient

* ignore negative ISFs

* only use CSF data for ISF if ISFLength < 10
* randomize wait_for_silence before smb_verify_reservoir

* typo
* use lastCarbAge instead of fractionCOBAbsorbed to calculate remainingCATime

* set lastCarbTime based on the max treatmentTime

* remainingCATimeMax is now unused
* add an enableSMB_always option

* disable SMB on really big jumps for safety

* add SMB disabled to reason field if delta > 10% of bg
* look ahead an additional 15m to get insulin started faster

* ramp up remainingCATime 1.5x as fast as lastCarbAge
@danamlewis
Copy link
Contributor Author

danamlewis commented Oct 6, 2017

(Please move comments and activity over to #707 for the 0.6.0 dev testing notes)

@sjolundjohn
Copy link

I am running "oref0@0.6.0-dev1" on a WW rig that is using a TI stick, connected via USB to an Intel Development Board.

  1. WW works no problem
  2. TI Stick working with no issues.

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

Successfully merging this pull request may close these issues.

None yet

9 participants