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

Modified CGM Generator #154

Merged
merged 4 commits into from
Feb 29, 2024
Merged
Changes from 1 commit
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
Next Next commit
Changes to CGM Generator
  • Loading branch information
TrafficCop committed Feb 29, 2024
commit f7d940672a244984f524466408cb3aaea9a32c3d
12 changes: 6 additions & 6 deletions wearipedia/devices/nutrisense/cgm_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def gen_data(start_date, end_date, seed=0):
summary = gen_summary(Y)
stat = {
"today": gen_stats(Y),
"average": gen_stats(Y, weekly=True),
"average": gen_stats(Y, weekly=True, seed=seed),
}
return (scores, continuous, summary, stat)

Expand Down Expand Up @@ -81,9 +81,9 @@ def gen_glucose(t, index, seed=0):
Y.append(y)

added = local_rng.normal(scale=1) * 10 + 0.01 * (160 / y)
if y < 80:
if y < 95:
added = abs(added)
elif y > 130:
elif y > 120:
added = -1 * abs(added)
y += added

Expand Down Expand Up @@ -149,7 +149,7 @@ def gen_scores():
return score


def gen_stats(Y, weekly=False):
def gen_stats(Y, weekly=False, seed=0):
"""Generate random scores for the daily statistics

:param Y: the synthetic sensor data
Expand Down Expand Up @@ -188,8 +188,8 @@ def gen_stats(Y, weekly=False):
"healthyRange": first,
"range": second,
"timeWithinRange": timeWithinRange,
"min": max(70, low),
"max": min(140, high),
"min": low,
"max": high,
"mean": avg,
"median": median,
"standardDeviation": std,
Expand Down