Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion bin/oref0-autosens-loop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ main() {

autosens 2>&1
touch /tmp/autosens-completed
echo Completed oref0-autons-loop at $(date)
echo Completed oref0-autosens-loop at $(date)
}

usage "$@" <<EOT
Expand Down
7 changes: 6 additions & 1 deletion bin/oref0-autotune.sh
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,12 @@ do
fi
else
# Copy tuned profile produced by autotune to profile.json for use with next day of data
cp newprofile.$i.json profile.json
if cat newprofile.$i.json | jq . | grep -q start; then
cp newprofile.$i.json profile.json
else
jq -c newprofile.$i.json
die "newprofile.$i.json invalid"
fi
fi


Expand Down
5 changes: 4 additions & 1 deletion lib/autotune-prep/categorize.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,10 @@ function categorizeBGDatums(opts) {
var basalLength = basalGlucoseData.length;

if (opts.categorize_uam_as_basal) {
console.error("Categorizing all UAM data as basal.");
console.error("--categorize-uam-as-basal=true set: categorizing all UAM data as basal.");
basalGlucoseData = basalGlucoseData.concat(UAMGlucoseData);
} else if (CSFLength > 12) {
console.error("Found at least 1h of carb absorption: assuming all meals were announced, and categorizing UAM data as basal.");
basalGlucoseData = basalGlucoseData.concat(UAMGlucoseData);
} else {
if (2*basalLength < UAMLength) {
Expand Down
18 changes: 13 additions & 5 deletions lib/determine-basal/determine-basal.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,22 @@ var determine_basal = function determine_basal(glucose_status, currenttemp, iob_
ci = round((minDelta - bgi),1);
var uci = round((minDelta - bgi),1);
// ISF (mg/dL/U) / CR (g/U) = CSF (mg/dL/g)
if (profile.temptargetSet) {

// TODO: remove commented-out code for old behavior
//if (profile.temptargetSet) {
// if temptargetSet, use unadjusted profile.sens to allow activity mode sensitivityRatio to adjust CR
var csf = profile.sens / profile.carb_ratio;
} else {
//var csf = profile.sens / profile.carb_ratio;
//} else {
// otherwise, use autosens-adjusted sens to counteract autosens meal insulin dosing adjustments
// so that autotuned CR is still in effect even when basals and ISF are being adjusted by autosens
csf = sens / profile.carb_ratio;
}
//var csf = sens / profile.carb_ratio;
//}
// use autosens-adjusted sens to counteract autosens meal insulin dosing adjustments so that
// autotuned CR is still in effect even when basals and ISF are being adjusted by TT or autosens
// this avoids overdosing insulin for large meals when low temp targets are active
csf = sens / profile.carb_ratio;
console.error("profile.sens:",profile.sens,"sens:",sens,"CSF:",csf);

var maxCarbAbsorptionRate = 30; // g/h; maximum rate to assume carbs will absorb if no CI observed
// limit Carb Impact to maxCarbAbsorptionRate * csf in mg/dL per 5m
var maxCI = round(maxCarbAbsorptionRate*csf*5/60,1)
Expand Down