From ca977b1d33f243d445d35697efdf4edcd20e5d81 Mon Sep 17 00:00:00 2001 From: t_j_s Date: Fri, 9 Sep 2022 09:18:42 +0100 Subject: [PATCH 1/5] Introduction of DynISF into the prediction corves, lines 583, 587 and 617. --- .../assets/OpenAPSSMBDynamicISF/determine-basal.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js b/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js index f3ff906aac..74f442bbf1 100644 --- a/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js +++ b/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js @@ -579,9 +579,12 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ // for IOBpredBGs, predicted deviation impact drops linearly from current deviation down to zero // over 60 minutes (data points every 5m) var predDev = ci * ( 1 - Math.min(1,IOBpredBGs.length/(60/5)) ); - IOBpredBG = IOBpredBGs[IOBpredBGs.length-1] + predBGI + predDev; + //IOBpredBG = IOBpredBGs[IOBpredBGs.length-1] + predBGI + predDev; + IOBpredBG = IOBpredBGs[IOBpredBGs.length-1] + (round(( -iobTick.activity * (1800 / ( TDD * (Math.log((Math.max( IOBpredBGs[IOBpredBGs.length-1],39) / ins_val ) + 1 ) ) )) * 5 ),2)) + // calculate predBGs with long zero temp without deviations - var ZTpredBG = ZTpredBGs[ZTpredBGs.length-1] + predZTBGI; + //var ZTpredBG = ZTpredBGs[ZTpredBGs.length-1] + predZTBGI; + var ZTpredBG = ZTpredBGs[ZTpredBGs.length-1] + (round(( -iobTick.iobWithZeroTemp.activity * (1800 / ( TDD * (Math.log(( Math.max(ZTpredBGs[ZTpredBGs.length-1],39) / ins_val ) + 1 ) ) )) * 5 ), 2)); // for COBpredBGs, predicted carb impact drops linearly from current carb impact down to zero // eventually accounting for all carbs (if they can be absorbed over DIA) var predCI = Math.max(0, Math.max(0,ci) * ( 1 - COBpredBGs.length/Math.max(cid*2,1) ) ); @@ -610,7 +613,8 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ //console.error(UAMpredBGs.length,slopeFromDeviations, predUCI); UAMduration=round((UAMpredBGs.length+1)*5/60,1); } - UAMpredBG = UAMpredBGs[UAMpredBGs.length-1] + predBGI + Math.min(0, predDev) + predUCI; + //UAMpredBG = UAMpredBGs[UAMpredBGs.length-1] + predBGI + Math.min(0, predDev) + predUCI; + UAMpredBG = UAMpredBGs[UAMpredBGs.length-1] + (round(( -iobTick.activity * (1800 / ( TDD * (Math.log(( Math.max(UAMpredBGs[UAMpredBGs.length-1],39) / ins_val ) + 1 ) ) )) * 5 ),2)) + Math.min(0, predDev) + predUCI; //console.error(predBGI, predCI, predUCI); // truncate all BG predictions at 4 hours if ( IOBpredBGs.length < 48) { IOBpredBGs.push(IOBpredBG); } From e729b2a81aea473645d7855c291c6c96181f3c68 Mon Sep 17 00:00:00 2001 From: t_j_s Date: Fri, 9 Sep 2022 13:05:20 +0100 Subject: [PATCH 2/5] COrrected Variable --- .../main/assets/OpenAPSSMBDynamicISF/determine-basal.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js b/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js index 74f442bbf1..5066bd1cac 100644 --- a/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js +++ b/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js @@ -580,11 +580,13 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ // over 60 minutes (data points every 5m) var predDev = ci * ( 1 - Math.min(1,IOBpredBGs.length/(60/5)) ); //IOBpredBG = IOBpredBGs[IOBpredBGs.length-1] + predBGI + predDev; - IOBpredBG = IOBpredBGs[IOBpredBGs.length-1] + (round(( -iobTick.activity * (1800 / ( TDD * (Math.log((Math.max( IOBpredBGs[IOBpredBGs.length-1],39) / ins_val ) + 1 ) ) )) * 5 ),2)) + IOBpredBG = IOBpredBGs[IOBpredBGs.length-1] + (round(( -iobTick.activity * (1800 / ( TDD * (Math.log((Math.max( IOBpredBGs[IOBpredBGs.length-1],39) / insulinDivisor ) + 1 ) ) )) + * 5 ),2)) // calculate predBGs with long zero temp without deviations //var ZTpredBG = ZTpredBGs[ZTpredBGs.length-1] + predZTBGI; - var ZTpredBG = ZTpredBGs[ZTpredBGs.length-1] + (round(( -iobTick.iobWithZeroTemp.activity * (1800 / ( TDD * (Math.log(( Math.max(ZTpredBGs[ZTpredBGs.length-1],39) / ins_val ) + 1 ) ) )) * 5 ), 2)); + var ZTpredBG = ZTpredBGs[ZTpredBGs.length-1] + (round(( -iobTick.iobWithZeroTemp.activity * (1800 / ( TDD * (Math.log(( Math.max(ZTpredBGs[ZTpredBGs.length-1],39) / + insulinDivisor ) + 1 ) ) )) * 5 ), 2)); // for COBpredBGs, predicted carb impact drops linearly from current carb impact down to zero // eventually accounting for all carbs (if they can be absorbed over DIA) var predCI = Math.max(0, Math.max(0,ci) * ( 1 - COBpredBGs.length/Math.max(cid*2,1) ) ); @@ -614,7 +616,8 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ UAMduration=round((UAMpredBGs.length+1)*5/60,1); } //UAMpredBG = UAMpredBGs[UAMpredBGs.length-1] + predBGI + Math.min(0, predDev) + predUCI; - UAMpredBG = UAMpredBGs[UAMpredBGs.length-1] + (round(( -iobTick.activity * (1800 / ( TDD * (Math.log(( Math.max(UAMpredBGs[UAMpredBGs.length-1],39) / ins_val ) + 1 ) ) )) * 5 ),2)) + Math.min(0, predDev) + predUCI; + UAMpredBG = UAMpredBGs[UAMpredBGs.length-1] + (round(( -iobTick.activity * (1800 / ( TDD + * (Math.log(( Math.max(UAMpredBGs[UAMpredBGs.length-1],39) / insulinDivisor ) + 1 ) ) )) * 5 ),2)) + Math.min(0, predDev) + predUCI; //console.error(predBGI, predCI, predUCI); // truncate all BG predictions at 4 hours if ( IOBpredBGs.length < 48) { IOBpredBGs.push(IOBpredBG); } From 055a11dee0ea384c96013f7658d3576b71e407f1 Mon Sep 17 00:00:00 2001 From: t_j_s Date: Fri, 9 Sep 2022 13:26:25 +0100 Subject: [PATCH 3/5] COrrected Variable --- app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js b/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js index 5066bd1cac..ac7666ba87 100644 --- a/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js +++ b/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js @@ -208,7 +208,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ //********************************************************************************* console.error("---------------------------------------------------------"); - console.error( " Dynamic ISF version Beta 1.6.5 "); + console.error( " Dynamic ISF version Beta 2.0 "); console.error("---------------------------------------------------------"); var variable_sens = profile.variable_sens; From 786228189ff50a68ad1b92560253b329f8d1c4e7 Mon Sep 17 00:00:00 2001 From: Tim Street Date: Fri, 9 Sep 2022 17:41:59 +0100 Subject: [PATCH 4/5] Fixed missing semi-colon. --- app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js b/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js index ac7666ba87..1049113272 100644 --- a/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js +++ b/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js @@ -581,7 +581,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ var predDev = ci * ( 1 - Math.min(1,IOBpredBGs.length/(60/5)) ); //IOBpredBG = IOBpredBGs[IOBpredBGs.length-1] + predBGI + predDev; IOBpredBG = IOBpredBGs[IOBpredBGs.length-1] + (round(( -iobTick.activity * (1800 / ( TDD * (Math.log((Math.max( IOBpredBGs[IOBpredBGs.length-1],39) / insulinDivisor ) + 1 ) ) )) - * 5 ),2)) + * 5 ),2)); // calculate predBGs with long zero temp without deviations //var ZTpredBG = ZTpredBGs[ZTpredBGs.length-1] + predZTBGI; From 546ff7b1e04c86cbf16e21e076709866f3f5191e Mon Sep 17 00:00:00 2001 From: Tim Street Date: Tue, 13 Sep 2022 18:42:56 +0100 Subject: [PATCH 5/5] Missed +predDev from IOBPredBG. Re-added. --- app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js b/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js index 1049113272..fed911758e 100644 --- a/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js +++ b/app/src/main/assets/OpenAPSSMBDynamicISF/determine-basal.js @@ -581,7 +581,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_ var predDev = ci * ( 1 - Math.min(1,IOBpredBGs.length/(60/5)) ); //IOBpredBG = IOBpredBGs[IOBpredBGs.length-1] + predBGI + predDev; IOBpredBG = IOBpredBGs[IOBpredBGs.length-1] + (round(( -iobTick.activity * (1800 / ( TDD * (Math.log((Math.max( IOBpredBGs[IOBpredBGs.length-1],39) / insulinDivisor ) + 1 ) ) )) - * 5 ),2)); + * 5 ),2)) + predDev; // calculate predBGs with long zero temp without deviations //var ZTpredBG = ZTpredBGs[ZTpredBGs.length-1] + predZTBGI;