Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
1d0d4aa
use openaps --nogit option
scottleibrand Jul 15, 2017
148a422
Merge branch 'master' into nogit
scottleibrand Jul 15, 2017
6d808f2
--nogit for myopenaps-cgm-loop too
scottleibrand Jul 15, 2017
f5317c9
remove git-specific stuff
scottleibrand Jul 15, 2017
4da025d
enable SMB/UAM (if enabled in preferences) for a full 6 hours after a…
scottleibrand Jul 22, 2017
418cc97
refresh pumphistory when pump is suspended and we can't enact
scottleibrand Jul 22, 2017
b097c7f
Merge branch 'dev' into gather-when-suspended
scottleibrand Jul 29, 2017
9d96590
Merge branch 'dev' into nogit
scottleibrand Jul 29, 2017
8d204bd
Merge branch 'gather-when-suspended' into nogit
scottleibrand Jul 29, 2017
d338151
check whether decocare-0.0.31 has been installed
scottleibrand Jul 29, 2017
bcef7ad
Merge branch 'update-decocare' into nogit
scottleibrand Jul 29, 2017
ee7271e
automatically install openaps 0.2.1 with --nogit support
scottleibrand Jul 29, 2017
e744e4e
check radio twice, and mmtune if both checks fail
scottleibrand Jul 30, 2017
7590fbf
use any_pump_comms function
scottleibrand Jul 30, 2017
2504e55
debugging
scottleibrand Jul 30, 2017
77ea0df
Calling out the number one beginner error
danamlewis Aug 8, 2017
68ee1ce
oref0-pump-loop reliability and debugging improvements (#575)
scottleibrand Aug 11, 2017
e9478ec
if currentDeviation is null or maxDeviation is 0, set mealCOB to 0 fo…
scottleibrand Aug 11, 2017
454bc1f
Merge branch 'dev' into nogit
scottleibrand Aug 12, 2017
5c54df4
version bump
scottleibrand Aug 12, 2017
61839af
Merge branch 'dev' into bad-deviation
scottleibrand Aug 12, 2017
90612ac
Merge branch 'dev' into number-one-beginner-error-people-refuse-to-ch…
scottleibrand Aug 12, 2017
d603bfb
Merge branch 'bad-deviation' into 0.6.0-dev
scottleibrand Aug 12, 2017
279750d
Merge branch 'number-one-beginner-error-people-refuse-to-check-on-the…
scottleibrand Aug 12, 2017
58a987e
speed up COB calculation
scottleibrand Aug 12, 2017
ffa7ede
Merge remote-tracking branch 'origin/cob-speedup' into 0.6.0-dev
scottleibrand Aug 12, 2017
296d560
remove ' that is confusing vim; indentation
scottleibrand Aug 12, 2017
c8fbd37
chmod +x bin/oref0_nightscout_check.py
scottleibrand Aug 12, 2017
71809c5
refresh meal.json after merge_pumphistory
scottleibrand Aug 12, 2017
7bb2033
newline
scottleibrand Aug 12, 2017
6f0d305
Merge branch 'separate-meal-calcs' into 0.6.0-dev
scottleibrand Aug 12, 2017
3c989c9
don't SMB unless bg > threshold (#602)
scottleibrand Aug 13, 2017
9683781
Exponential curves (#568)
sulkaharo Aug 13, 2017
0859697
Speed up COB calculation by only converting pumphistory to treatments…
scottleibrand Aug 13, 2017
88862cc
remove double declaration of biobContrib (#605)
AdrianLxM Aug 13, 2017
2319c2e
first attempt at allowing unsuspend without SMB (#596)
scottleibrand Aug 14, 2017
c4030a6
Clean up old unused stuff, fix whitespace, etc. (#595)
scottleibrand Aug 14, 2017
623da17
Decocare 0.1.0 (#597)
scottleibrand Aug 14, 2017
65faebf
fix percent grep
scottleibrand Aug 14, 2017
3e8eccd
check for percent mode after failure to make it more obvious
scottleibrand Aug 14, 2017
07f2c88
fix whitespace
scottleibrand Aug 14, 2017
62b527b
stop using DIA for anything but actual IOB/activity calcs (#599)
scottleibrand Aug 14, 2017
82d0b25
don't allow target_bg below 80
scottleibrand Aug 14, 2017
18b066d
only updatePreferences with displayedDefaults
scottleibrand Aug 14, 2017
e2ee0a6
move dia = 3 code so not to interfere with bolus snooze
scottleibrand Aug 14, 2017
46bffa2
Merge branch 'dev' into 0.6.0-dev
scottleibrand Aug 14, 2017
f4a9624
use profile.sens instead of autosens-adjusted sens (#618)
scottleibrand Aug 19, 2017
9a604ce
only print minDelta < expectedDelta when it's true
scottleibrand Aug 21, 2017
7a99a00
Merge branch 'dev' into 0.6.0-dev
scottleibrand Aug 23, 2017
dd6e1a6
don't overreact to negative deviations from a big negative delta (#615)
scottleibrand Aug 23, 2017
159b4da
make carbsReqThreshold configurable (#607)
scottleibrand Aug 23, 2017
6cb71c1
force minimum DIA of 3h (#606)
scottleibrand Aug 23, 2017
e355b0c
Timezone fix to 0.6.0-dev (#624)
scottleibrand Aug 23, 2017
42f4ffd
Merge branch '0.6.0-dev' of github.com:openaps/oref0 into 0.6.0-dev
scottleibrand Aug 23, 2017
6155121
Merge remote-tracking branch 'origin/dev' into 0.6.0-dev
scottleibrand Aug 23, 2017
112b143
ignore bolusing status if pump is suspended
scottleibrand Aug 24, 2017
955bfbe
clarify bolus snooze reason (for #626)
scottleibrand Aug 25, 2017
15f6a43
microBolus 1/2 the insulinReq if IOB doesn't yet cover COB (#621)
scottleibrand Aug 27, 2017
594a085
model remainingCarbs as a /\ shaped bilinear curve (#620)
scottleibrand Aug 27, 2017
99e7944
for purposes of categorizing boluses as SMBs to add to basalIOB, use …
scottleibrand Aug 28, 2017
1e331ec
add max_daily_basal to fix tests
scottleibrand Sep 2, 2017
384b514
always mmtune on falure if mmtune.json is more than 15m old
scottleibrand Sep 3, 2017
041b223
don't necessarily mmtune if pump_loop_completed within 15m
scottleibrand Sep 3, 2017
d536fbf
Merge branch 'always-mmtune-when-old' into 0.6.0-dev
scottleibrand Sep 3, 2017
04d7382
Always mmtune if pump_loop_completed > 15m old (#635)
scottleibrand Sep 4, 2017
3c970f1
stop letting high temp run (#633)
scottleibrand Sep 4, 2017
b60f341
remove -g as it breaks autotune's time filters
scottleibrand Sep 4, 2017
bb15929
Merge branch 'fix-autotune' into 0.6.0-dev
scottleibrand Sep 4, 2017
067ccac
Revert "remove -g as it breaks autotune's time filters"
scottleibrand Sep 4, 2017
621ba48
Merge branch 'dev' into 0.6.0-dev
scottleibrand Sep 5, 2017
d3d3e52
Allow nonzero low temps for SMB (#634)
scottleibrand Sep 5, 2017
abdb96a
Merge branch 'dev' into 0.6.0-dev
scottleibrand Sep 5, 2017
8962fce
don't allow maxSMBBasalMinutes > 30 unless IOB (and COB) are > 0 (#639)
scottleibrand Sep 7, 2017
52f4b30
COB-aware autosens (#629)
scottleibrand Sep 7, 2017
6c2456f
carbs: should only include carbs actually used in calculating COB (#640)
scottleibrand Sep 7, 2017
9c89a54
weight COBpredBG vs. UAMpredBG based on how many carbs remain as COB …
scottleibrand Sep 7, 2017
8cfd6a7
Additional remainingCI debugging (#645)
scottleibrand Sep 7, 2017
4519a13
remove autosens avgDelta-bgi < 6 check (#643)
scottleibrand Sep 7, 2017
9a659a7
Merge branch 'dev' into 0.6.0-dev
scottleibrand Sep 8, 2017
05658ed
Merge branch 'dev' into 0.6.0-dev
scottleibrand Sep 9, 2017
9e78f10
Autotune: calculate CR directly, and use CR*CSF to help calculate ISF…
scottleibrand Sep 10, 2017
d498552
Make remainingCI time responsive to temp targets (#646)
scottleibrand Sep 10, 2017
656fc6f
Merge branch 'dev' into 0.6.0-dev
scottleibrand Sep 10, 2017
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
24 changes: 19 additions & 5 deletions bin/oref0-autotune-prep.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var generate = require('oref0/lib/autotune-prep');
function usage ( ) {
console.error('usage: ', process.argv.slice(0, 2), '<pumphistory.json> <profile.json> <glucose.json> [carbhistory.json] [autotune/glucose.json]');
console.error('usage: ', process.argv.slice(0, 2), '<pumphistory.json> <profile.json> <glucose.json> [pumpprofile.json] [carbhistory.json] [autotune/glucose.json]');
}

if (!module.parent) {
Expand All @@ -33,8 +33,9 @@ if (!module.parent) {
}
var profile_input = process.argv.slice(3, 4).pop();
var glucose_input = process.argv.slice(4, 5).pop();
var carb_input = process.argv.slice(5, 6).pop()
var prepped_glucose_input = process.argv.slice(6, 7).pop()
var pumpprofile_input = process.argv.slice(5, 6).pop()
var carb_input = process.argv.slice(6, 7).pop()
var prepped_glucose_input = process.argv.slice(7, 8).pop()

if ( !pumphistory_input || !profile_input || !glucose_input ) {
usage( );
Expand All @@ -51,10 +52,23 @@ if (!module.parent) {
return console.error("Could not parse input data: ", e);
}

var pumpprofile_data = { };
if (typeof pumpprofile_input != 'undefined') {
try {
pumpprofile_data = JSON.parse(fs.readFileSync(pumpprofile_input, 'utf8'));
} catch (e) {
console.error("Warning: could not parse "+pumpprofile_input);
}
}

// disallow impossibly low carbRatios due to bad decoding
if ( typeof(profile_data.carb_ratio) == 'undefined' || profile_data.carb_ratio < 2 ) {
console.log('{ "carbs": 0, "mealCOB": 0, "reason": "carb_ratio ' + profile_data.carb_ratio + ' out of bounds" }');
return console.error("Error: carb_ratio " + profile_data.carb_ratio + " out of bounds");
if ( typeof(pumpprofile_data.carb_ratio) == 'undefined' || pumpprofile_data.carb_ratio < 2 ) {
console.log('{ "carbs": 0, "mealCOB": 0, "reason": "carb_ratios ' + profile_data.carb_ratio + ' and ' + pumpprofile_data.carb_ratio + ' out of bounds" }');
return console.error("Error: carb_ratios " + profile_data.carb_ratio + ' and ' + pumpprofile_data.carb_ratio + " out of bounds");
} else {
profile_data.carb_ratio = pumpprofile_data.carb_ratio;
}
}

try {
Expand Down
6 changes: 3 additions & 3 deletions bin/oref0-autotune-recommends-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ csf_new=$(cat $directory/autotune/profile.json | jq '.csf')
carb_ratio_new=$(cat $directory/autotune/profile.json | jq '.carb_ratio')

# Print Header Info
printf "%-${parameter_width}s| %-${data_width}s| %-${data_width}s\n" "Parameter" "Current" "Autotune" >> $report_file
printf "%-${parameter_width}s| %-${data_width}s| %-${data_width}s\n" "Parameter" "Pump" "Autotune" >> $report_file
printf "%s\n" "-------------------------------------" >> $report_file

# Print ISF, CSF and Carb Ratio Recommendations
Expand All @@ -74,10 +74,10 @@ if [ $csf_current != null ]; then
else
printf "%-${parameter_width}s| %-${data_width}s| %-${data_width}.3f\n" "CSF [mg/dL/g]" "n/a" $csf_new >> $report_file
fi
printf "%-${parameter_width}s| %-${data_width}.3f| %-${data_width}.3f\n" "Carb Ratio [g]" $carb_ratio_current $carb_ratio_new >> $report_file
printf "%-${parameter_width}s| %-${data_width}.3f| %-${data_width}.3f\n" "Carb Ratio[g/U]" $carb_ratio_current $carb_ratio_new >> $report_file

# Print Basal Profile Recommendations
printf "%-${parameter_width}s| %-${data_width}s|\n" "Basal Profile [unit/hour]" "-" >> $report_file
printf "%-${parameter_width}s| %-${data_width}s|\n" "Basals [U/hr]" "-" >> $report_file

# Build time_list array of H:M in 30 minute increments to mirror pump basal schedule
time_list=()
Expand Down
131 changes: 63 additions & 68 deletions bin/oref0-autotune.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# This script sets up an easy test environment for autotune, allowing the user to vary parameters
# like start/end date and number of runs.
# like start/end date.
#
# Required Inputs:
# DIR, (--dir=<OpenAPS Directory>)
Expand All @@ -10,8 +10,6 @@
# Optional Inputs:
# END_DATE, (--end-date=<YYYY-MM-DD>)
# if no end date supplied, assume we want a months worth or until day before current day
# NUMBER_OF_RUNS (--runs=<integer, number of runs desired>)
# if no number of runs designated, then default to 5
# EXPORT_EXCEL (--xlsx=<filenameofexcel>)
# export to excel. Disabled by default
# TERMINAL_LOGGING (--log <true/false(true)>
Expand Down Expand Up @@ -39,7 +37,8 @@ DIR=""
NIGHTSCOUT_HOST=""
START_DATE=""
END_DATE=""
NUMBER_OF_RUNS=1 # Default to a single run if not otherwise specified
START_DAYS_AGO=1 # Default to yesterday if not otherwise specified
END_DAYS_AGO=1 # Default to yesterday if not otherwise specified
EXPORT_EXCEL="" # Default is to not export to Microsoft Excel
TERMINAL_LOGGING=true
RECOMMENDS_REPORT=true
Expand Down Expand Up @@ -96,8 +95,12 @@ case $i in
END_DATE=`date --date="$END_DATE" +%Y-%m-%d`
shift # past argument=value
;;
-r=*|--runs=*)
NUMBER_OF_RUNS="${i#*=}"
-t=*|--start-days-ago=*)
START_DAYS_AGO="${i#*=}"
shift # past argument=value
;;
-d=*|--end-days-ago=*)
END_DAYS_AGO="${i#*=}"
shift # past argument=value
;;
-x=*|--xlsx=*)
Expand All @@ -116,28 +119,31 @@ case $i in
esac
done

# remove any trailing / from NIGHTSCOUT_HOST
NIGHTSCOUT_HOST=$(echo $NIGHTSCOUT_HOST | sed 's/\/$//g')

if [[ -z "$DIR" || -z "$NIGHTSCOUT_HOST" ]]; then
echo "Usage: oref0-autotune <--dir=myopenaps_directory> <--ns-host=https://mynightscout.azurewebsites.net> [--start-date=YYYY-MM-DD] [--end-date=YYYY-MM-DD] [--runs=number_of_runs] [--xlsx=autotune.xlsx] [--log=(true)|false]"
echo "Usage: oref0-autotune <--dir=myopenaps_directory> <--ns-host=https://mynightscout.azurewebsites.net> [--start-days-ago=number_of_days] [--end-days-ago=number_of_days] [--start-date=YYYY-MM-DD] [--end-date=YYYY-MM-DD] [--xlsx=autotune.xlsx] [--log=(true)|false]"
exit 1
fi
if [[ -z "$START_DATE" ]]; then
# Default start date of yesterday
START_DATE=`date --date="1 day ago" +%Y-%m-%d`
START_DATE=`date --date="$START_DAYS_AGO days ago" +%Y-%m-%d`
fi
if [[ -z "$END_DATE" ]]; then
# Default end-date as this morning at midnight in order to not get partial day samples for now
# (ISF/CSF adjustments are still single values across each day)
END_DATE=`date --date="1 day ago" +%Y-%m-%d`
END_DATE=`date --date="$END_DAYS_AGO days ago" +%Y-%m-%d`
fi

if [[ -z "$UNKNOWN_OPTION" ]] ; then # everything is ok
echo "Running oref0-autotune --dir=$DIR --ns-host=$NIGHTSCOUT_HOST --start-date=$START_DATE --runs=$NUMBER_OF_RUNS --end-date=$END_DATE"
echo "Running oref0-autotune --dir=$DIR --ns-host=$NIGHTSCOUT_HOST --start-date=$START_DATE --end-date=$END_DATE"
else
echo "Unknown options. Exiting"
exit 1
fi

# Get profile for testing copied to home directory. "openaps" is my loop directory name.
# Get profile for testing copied to home directory.
cd $directory && mkdir -p autotune
cp settings/pumpprofile.json autotune/profile.pump.json || die "Cannot copy settings/pumpprofile.json"
# This allows manual users to be able to run autotune by simply creating a settings/pumpprofile.json file.
Expand All @@ -157,15 +163,6 @@ if [[ $TERMINAL_LOGGING = "true" ]]; then
exec &> >(tee -a autotune.$(date +%Y-%m-%d-%H%M%S).log)
fi

# Pull Nightscout Data
echo "Grabbing NIGHTSCOUT treatments.json for date range..."

# Get Nightscout carb and insulin Treatments
query="find%5Bcreated_at%5D%5B%24gte%5D=`date --date="$START_DATE -4 hours" -Iminutes`&find%5Bcreated_at%5D%5B%24lte%5D=`date --date="$END_DATE +1 days" -Iminutes`"
echo Query: $NIGHTSCOUT_HOST/$query
ns-get host $NIGHTSCOUT_HOST treatments.json $query > ns-treatments.json || die "Couldn't download ns-treatments.json"
ls -la ns-treatments.json || die "No ns-treatments.json downloaded"

# Build date list for autotune iteration
date_list=()
date=$START_DATE;
Expand All @@ -179,76 +176,74 @@ do
fi
done

echo "Grabbing NIGHTSCOUT entries/sgv.json for date range..."
echo "Grabbing NIGHTSCOUT treatments.json and entries/sgv.json for date range..."

# Get Nightscout BG (sgv.json) Entries
for i in "${date_list[@]}"
do
query="find%5Bdate%5D%5B%24gte%5D=`(date -d $i +%s | tr -d '\n'; echo 000)`&find%5Bdate%5D%5B%24lte%5D=`(date --date="$i +1 days" +%s | tr -d '\n'; echo 000)`&count=1000"
echo Query: $NIGHTSCOUT_HOST $query
ns-get host $NIGHTSCOUT_HOST entries/sgv.json $query > ns-entries.$i.json || die "Couldn't download ns-entries.$i.json"
ls -la ns-entries.$i.json || die "No ns-entries.$i.json downloaded"
done

echo "Running $NUMBER_OF_RUNS runs from $START_DATE to $END_DATE"
sleep 2

# Do iterative runs over date range, save autotune.json (prepped data) and input/output
# profile.json
# Loop 1: Run 1 to Number of Runs specified by user or by default (1)
for run_number in $(seq 1 $NUMBER_OF_RUNS)
do
# Loop 2: Iterate through Date Range
for i in "${date_list[@]}"
do
cp profile.json profile.$run_number.$i.json
query="find%5Bdate%5D%5B%24gte%5D=`(date -d $i +%s | tr -d '\n'; echo 000)`&find%5Bdate%5D%5B%24lte%5D=`(date --date="$i +1 days" +%s | tr -d '\n'; echo 000)`&count=1000"
echo Query: $NIGHTSCOUT_HOST $query
ns-get host $NIGHTSCOUT_HOST entries/sgv.json $query > ns-entries.$i.json || die "Couldn't download ns-entries.$i.json"
ls -la ns-entries.$i.json || die "No ns-entries.$i.json downloaded"

# Get Nightscout carb and insulin Treatments
# echo $i $START_DATE;
#query="find%5Bdate%5D%5B%24gte%5D=`(date -d $i +%s | tr -d'\n'; echo 000)`&find%5Bdate%5D%5B%24lte%5D=`(date --date="$i +1 days" +%s | tr -d '\n'; echo 000)`&count=1000"
query="find%5Bcreated_at%5D%5B%24gte%5D=`date --date="$i -5 hours" -Iminutes`&find%5Bcreated_at%5D%5B%24lte%5D=`date --date="$i +1 days" -Iminutes`"
echo Query: $NIGHTSCOUT_HOST/$query
ns-get host $NIGHTSCOUT_HOST treatments.json $query > ns-treatments.$i.json || die "Couldn't download ns-treatments.$i.json"
ls -la ns-treatments.$i.json || die "No ns-treatments.$i.json downloaded"


# Do iterative runs over date range, save autotune.json (prepped data) and input/output profile.json
cp profile.json profile.$i.json
# Autotune Prep (required args, <pumphistory.json> <profile.json> <glucose.json>), output prepped glucose
# data or <autotune/glucose.json> below
echo "oref0-autotune-prep ns-treatments.json profile.json ns-entries.$i.json > autotune.$run_number.$i.json"
oref0-autotune-prep ns-treatments.json profile.json ns-entries.$i.json > autotune.$run_number.$i.json \
|| die "Could not run oref0-autotune-prep ns-treatments.json profile.json ns-entries.$i.json"
echo "oref0-autotune-prep ns-treatments.$i.json profile.json ns-entries.$i.json profile.pump.json > autotune.$i.json"
oref0-autotune-prep ns-treatments.$i.json profile.json ns-entries.$i.json profile.pump.json > autotune.$i.json \
|| die "Could not run oref0-autotune-prep ns-treatments.$i.json profile.json ns-entries.$i.json"

# Autotune (required args, <autotune/glucose.json> <autotune/autotune.json> <settings/profile.json>),
# output autotuned profile or what will be used as <autotune/autotune.json> in the next iteration
echo "oref0-autotune-core autotune.$run_number.$i.json profile.json profile.pump.json > newprofile.$run_number.$i.json"
if ! oref0-autotune-core autotune.$run_number.$i.json profile.json profile.pump.json > newprofile.$run_number.$i.json; then
echo "oref0-autotune-core autotune.$i.json profile.json profile.pump.json > newprofile.$i.json"
if ! oref0-autotune-core autotune.$i.json profile.json profile.pump.json > newprofile.$i.json; then
if cat profile.json | jq --exit-status .carb_ratio==null; then
echo "ERROR: profile.json contains null carb_ratio: using profile.pump.json"
cp profile.pump.json profile.json
exit
else
die "Could not run oref0-autotune-core autotune.$run_number.$i.json profile.json profile.pump.json"
die "Could not run oref0-autotune-core autotune.$i.json profile.json profile.pump.json"
fi
else
# Copy tuned profile produced by autotune to profile.json for use with next day of data
cp newprofile.$run_number.$i.json profile.json
cp newprofile.$i.json profile.json
fi

done # End Date Range Iteration
done # End Number of Runs Loop

if ! [[ -z "$EXPORT_EXCEL" ]]; then
echo Exporting to $EXPORT_EXCEL
oref0-autotune-export-to-xlsx --dir $DIR --output $EXPORT_EXCEL
fi
if ! [[ -z "$EXPORT_EXCEL" ]]; then
echo Exporting to $EXPORT_EXCEL
oref0-autotune-export-to-xlsx --dir $DIR --output $EXPORT_EXCEL
fi

# Create Summary Report of Autotune Recommendations and display in the terminal
if [[ $RECOMMENDS_REPORT == "true" ]]; then
# Set the report file name, so we can let the user know where it is and cat
# it to the screen
report_file=$directory/autotune/autotune_recommendations.log
# Create Summary Report of Autotune Recommendations and display in the terminal
if [[ $RECOMMENDS_REPORT == "true" ]]; then
# Set the report file name, so we can let the user know where it is and cat
# it to the screen
report_file=$directory/autotune/autotune_recommendations.log

echo
echo "Autotune pump profile recommendations:"
echo "---------------------------------------------------------"
echo
echo "Autotune pump profile recommendations:"
echo "---------------------------------------------------------"

# Let the user know where the Autotune Recommendations are logged
echo "Recommendations Log File: $report_file"
echo
# Let the user know where the Autotune Recommendations are logged
echo "Recommendations Log File: $report_file"
echo

# Run the Autotune Recommends Report
oref0-autotune-recommends-report $directory
# Run the Autotune Recommends Report
oref0-autotune-recommends-report $directory

# Go ahead and echo autotune_recommendations.log to the terminal, minus blank lines
cat $report_file | egrep -v "\| *\| *$"
fi
# Go ahead and echo autotune_recommendations.log to the terminal, minus blank lines
cat $report_file | egrep -v "\| *\| *$"
fi

done # End Date Range Iteration
21 changes: 16 additions & 5 deletions bin/oref0-detect-sensitivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

var basal = require('oref0/lib/profile/basal');
var get_iob = require('oref0/lib/iob');
var detect = require('oref0/lib/determine-basal/cob-autosens');
var detect = require('oref0/lib/determine-basal/autosens');

if (!module.parent) {
var detectsensitivity = init();
Expand All @@ -27,9 +27,10 @@ if (!module.parent) {
var isf_input = process.argv.slice(4, 5).pop()
var basalprofile_input = process.argv.slice(5, 6).pop()
var profile_input = process.argv.slice(6, 7).pop();
var carb_input = process.argv.slice(7, 8).pop()

if (!glucose_input || !pumphistory_input || !profile_input) {
console.error('usage: ', process.argv.slice(0, 2), '<glucose.json> <pumphistory.json> <insulin_sensitivities.json> <basal_profile.json> <profile.json>');
console.error('usage: ', process.argv.slice(0, 2), '<glucose.json> <pumphistory.json> <insulin_sensitivities.json> <basal_profile.json> <profile.json> [carbhistory.json]');
process.exit(1);
}

Expand Down Expand Up @@ -62,6 +63,15 @@ if (!module.parent) {
}
var basalprofile = require(cwd + '/' + basalprofile_input);

var carb_data = { };
if (typeof carb_input != 'undefined') {
try {
carb_data = JSON.parse(fs.readFileSync(carb_input, 'utf8'));
} catch (e) {
console.error("Warning: could not parse "+carb_input);
}
}

var iob_inputs = {
history: pumphistory_data
, profile: profile
Expand All @@ -73,9 +83,10 @@ if (!module.parent) {

var detection_inputs = {
iob_inputs: iob_inputs
, glucose_data: glucose_data
, basalprofile: basalprofile
//, clock: clock_data
, carbs: carb_data
, glucose_data: glucose_data
, basalprofile: basalprofile
//, clock: clock_data
};
detect(detection_inputs);
var sensAdj = {
Expand Down
4 changes: 2 additions & 2 deletions bin/oref0-meal.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ if (!module.parent) {
, glucose: glucose_data
};

var dia_carbs = generate(inputs);
console.log(JSON.stringify(dia_carbs));
var recentCarbs = generate(inputs);
console.log(JSON.stringify(recentCarbs));
}

Loading