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

Autotune insulinPeakTime and insulinEndTime #1018

Merged
merged 25 commits into from
Aug 15, 2018
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3a4a81c
Initial commit of tuning dia and peak capability.
May 15, 2018
6fd9549
Added setting customPeakTime to true to allow peak time manipulation.
May 17, 2018
6817bc7
Fixed Math function being called.
May 17, 2018
a55277d
Only allowed DIA to range to 9.
May 19, 2018
c1f0653
skip glucose records w/o valid glucose
scottleibrand May 21, 2018
f64da70
Merge branch 'autotune' into tune-dia-and-peak
scottleibrand May 21, 2018
620cb0c
consider DIAs +/- 2h, and peaks +/- 10m, each run
scottleibrand May 21, 2018
35e9b14
use correct peaks; store output
scottleibrand May 21, 2018
a53ec46
tune DIA and insulinPeakTime
scottleibrand May 21, 2018
8e720b1
comment out debugging
scottleibrand May 21, 2018
35a1edd
only tune DIA and peak if requested
scottleibrand May 21, 2018
0771b92
allow 35-100m peak for fiasp, 50-120m for others
scottleibrand May 22, 2018
0987469
syntax
scottleibrand May 22, 2018
7e73528
replace let with var for compatibility
scottleibrand Jun 3, 2018
8b37073
round deviations before comparison
scottleibrand Jun 3, 2018
14a189c
require 1% improvement to change DIA/peak
scottleibrand Jun 4, 2018
cf35f41
fix variable reference
scottleibrand Jun 4, 2018
0ec8bfa
print insulinEndTime instead of DIA
scottleibrand Jun 4, 2018
2788d58
enforce a maximum insulinEndTime of 12h
scottleibrand Jun 4, 2018
9fa266b
don't reference glucoseDatum unless it exists
scottleibrand Jun 4, 2018
d33d62d
set the right variable
scottleibrand Jun 4, 2018
b3ad718
Compare both RMSD and MAE (#1028)
scottleibrand Jun 8, 2018
3d1f424
print when leaving ISF unchanged
scottleibrand Jun 8, 2018
f15ac24
only uam-exclude when IOB > 2x basal
scottleibrand Jun 8, 2018
8e920cc
add UAM to ISF if needed and keep lowest 50%, like with basal
scottleibrand Jun 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
print when leaving ISF unchanged
  • Loading branch information
scottleibrand committed Jun 8, 2018
commit 3d1f424ae6abd78023f31930a2d68e2db3d49daf
8 changes: 4 additions & 4 deletions lib/autotune/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ function tuneAllTheThings (inputs) {
var BGIs = [];
var avgDeltas = [];
var ratios = [];
var count = 0;
for (var i=0; i < ISFGlucose.length; ++i) {
deviation = parseFloat(ISFGlucose[i].deviation);
deviations.push(deviation);
Expand All @@ -439,7 +438,6 @@ function tuneAllTheThings (inputs) {
var ratio = 1 + deviation / BGI;
//console.error("Deviation:",deviation,"BGI:",BGI,"avgDelta:",avgDelta,"ratio:",ratio);
ratios.push(ratio);
count++;
}
avgDeltas.sort(function(a, b){return a-b});
BGIs.sort(function(a, b){return a-b});
Expand All @@ -448,14 +446,16 @@ function tuneAllTheThings (inputs) {
var p50deviation = percentile(deviations, 0.50);
var p50BGI = percentile(BGIs, 0.50);
var p50ratios = Math.round( percentile(ratios, 0.50) * 1000)/1000;
if (count < 10) {
var fullNewISF = ISF;
if (ISFGlucose.length < 10) {
// leave ISF unchanged if fewer than 5 ISF data points
var fullNewISF = ISF;
console.error ("Only found",ISFGlucose.length,"ISF data points, leaving ISF unchanged at",ISF);
} else {
// calculate what adjustments to ISF would have been necessary to bring median deviation to zero
fullNewISF = ISF * p50ratios;
}
fullNewISF = Math.round( fullNewISF * 1000 ) / 1000;
//console.error("p50ratios:",p50ratios,"fullNewISF:",fullNewISF,ratios[Math.floor(ratios.length/2)]);
// adjust the target ISF to be a weighted average of fullNewISF and pumpISF
var adjustmentFraction;

Expand Down