Merge pull request #2173 from tim2000s/dynisf_pred_curves

Dynisf pred curves
This commit is contained in:
Milos Kozak 2022-11-08 09:27:14 +01:00 committed by GitHub
commit 7747834a36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -208,7 +208,7 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
//********************************************************************************* //*********************************************************************************
console.error("---------------------------------------------------------"); console.error("---------------------------------------------------------");
console.error( " Dynamic ISF version Beta 1.6.5 "); console.error( " Dynamic ISF version Beta 2.0 ");
console.error("---------------------------------------------------------"); console.error("---------------------------------------------------------");
var variable_sens = profile.variable_sens; var variable_sens = profile.variable_sens;
@ -579,9 +579,14 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
// for IOBpredBGs, predicted deviation impact drops linearly from current deviation down to zero // for IOBpredBGs, predicted deviation impact drops linearly from current deviation down to zero
// over 60 minutes (data points every 5m) // over 60 minutes (data points every 5m)
var predDev = ci * ( 1 - Math.min(1,IOBpredBGs.length/(60/5)) ); 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) / insulinDivisor ) + 1 ) ) ))
* 5 ),2)) + predDev;
// calculate predBGs with long zero temp without deviations // 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) /
insulinDivisor ) + 1 ) ) )) * 5 ), 2));
// for COBpredBGs, predicted carb impact drops linearly from current carb impact down to zero // 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) // 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) ) ); var predCI = Math.max(0, Math.max(0,ci) * ( 1 - COBpredBGs.length/Math.max(cid*2,1) ) );
@ -610,7 +615,9 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
//console.error(UAMpredBGs.length,slopeFromDeviations, predUCI); //console.error(UAMpredBGs.length,slopeFromDeviations, predUCI);
UAMduration=round((UAMpredBGs.length+1)*5/60,1); 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) / insulinDivisor ) + 1 ) ) )) * 5 ),2)) + Math.min(0, predDev) + predUCI;
//console.error(predBGI, predCI, predUCI); //console.error(predBGI, predCI, predUCI);
// truncate all BG predictions at 4 hours // truncate all BG predictions at 4 hours
if ( IOBpredBGs.length < 48) { IOBpredBGs.push(IOBpredBG); } if ( IOBpredBGs.length < 48) { IOBpredBGs.push(IOBpredBG); }