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

Etn/get settings and events #44

Open
wants to merge 78 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
917d739
update gitignore
ed-nykaza Jan 11, 2019
f295c17
initial commit
ed-nykaza Jan 11, 2019
d21d5dd
add ISF and CIR
ed-nykaza Jan 11, 2019
16297bf
update to rounded time for tidal data analytics python tools
ed-nykaza Jan 11, 2019
c8db909
add bolus events
ed-nykaza Jan 11, 2019
7418a81
flatten embedded json to cover all column headings
ed-nykaza Jan 11, 2019
a288778
update bolus events to include isf and cir associated with events
ed-nykaza Jan 11, 2019
ace918b
get ISF from pump settings
ed-nykaza Jan 11, 2019
f58ed64
get CIR from the pump settings
ed-nykaza Jan 11, 2019
964c3dc
add the correction target from the pump settings
ed-nykaza Jan 11, 2019
cd79cbd
clean up unused pieces of code
ed-nykaza Jan 11, 2019
73e6228
add logic for missing data
ed-nykaza Jan 11, 2019
71f9000
get actual basal rates and scheduled basal rates
ed-nykaza Jan 12, 2019
eb7a77d
changes related to time
ed-nykaza Jan 12, 2019
aa00704
expand correction target cases and auto mode basal rates
ed-nykaza Jan 12, 2019
88682af
handle insulinSensitivities and carbRatios schedules
ed-nykaza Jan 12, 2019
9d1349f
refactor correction target
ed-nykaza Jan 12, 2019
307bb2e
handle multiple correctionTargets
ed-nykaza Jan 12, 2019
2190b24
add cgm data
ed-nykaza Jan 12, 2019
1050b63
make an actual basal rate delivered df
ed-nykaza Jan 12, 2019
53cfe1f
add in extended boluses to the actual basals delivered
ed-nykaza Jan 12, 2019
3258b1b
get day level summary stats by age and years living with (ylw)
ed-nykaza Jan 12, 2019
5cf9cdc
require pump and cgm data for this analysis
ed-nykaza Jan 12, 2019
75b78a2
remove dependence on tidals
ed-nykaza Jan 12, 2019
28a4654
edge case where the active schedule is a float (convert back to string)
ed-nykaza Jan 12, 2019
2ceaf15
save all preprocessed data
ed-nykaza Jan 12, 2019
ba45b20
calc local time and save settings and events
ed-nykaza Jan 13, 2019
334f19b
add isf day stats
ed-nykaza Jan 13, 2019
7076aba
calculate day summaries for settings (isf, cir, ct, and sbr)
ed-nykaza Jan 13, 2019
98d10f6
day summaries only include summary stats
ed-nykaza Jan 13, 2019
0dbe2d9
get settings summaries across for each age and ylw
ed-nykaza Jan 13, 2019
fc4a253
fix edge case 'US/Pacific-New'
ed-nykaza Jan 14, 2019
b5ed0c6
fix scheduled isf and cir
ed-nykaza Jan 14, 2019
cf7759c
fix correction target age summaries to include min, wMean, and max
ed-nykaza Jan 14, 2019
72e568b
add insulin/carb events and basic cgm stats
ed-nykaza Jan 14, 2019
42c86bf
add argparse to run from commandline
ed-nykaza Jan 14, 2019
640eaf6
add try catch to help batch process
ed-nykaza Jan 14, 2019
ef2f955
update flatten_json to include a list of fields to NOT flatten
ed-nykaza Jan 16, 2019
c10f4c6
syntax of new flatten_json function
ed-nykaza Jan 17, 2019
7750289
setting summaries per day should only have one entry per day
ed-nykaza Jan 18, 2019
a2c02e4
get rid of break
ed-nykaza Jan 18, 2019
7ce58a9
add deviceId to correction target data
ed-nykaza Jan 18, 2019
d576b42
fix correction target to match how pumps set correction target
ed-nykaza Jan 18, 2019
5ed3690
only check deviceId if payload exists
ed-nykaza Jan 18, 2019
39eee21
add age and years with summaries, and save all data
ed-nykaza Jan 18, 2019
4833b06
get rid of print correction target
ed-nykaza Jan 22, 2019
47025c6
ignore copy of slice warning
ed-nykaza Jan 22, 2019
ca91f4e
sense units of isf
ed-nykaza Jan 22, 2019
691b0e0
make sure n670g days returns 0 instead of False when no data
ed-nykaza Jan 22, 2019
a746978
allow for valid cgm to account for free style 15 minute data interval
ed-nykaza Jan 22, 2019
d925214
comment out breakpoints (for now while developing)
ed-nykaza Jan 22, 2019
62202bd
make sure nDays with closed loop data is 0 and not False
ed-nykaza Jan 22, 2019
748d375
deal with edge case where schedule has no information
ed-nykaza Jan 23, 2019
76b83cf
deal with edge case where there is not enough pump and/or cgm data
ed-nykaza Jan 23, 2019
f4fdd04
edge case where active schedule is null
ed-nykaza Jan 23, 2019
61c97b8
rename schedule basal rate summary data columns
ed-nykaza Jan 24, 2019
9961c0c
update to the todo list at end of file
ed-nykaza Jan 24, 2019
c43efc5
add to list of issues to investigate
ed-nykaza Jan 24, 2019
9d69760
adding to list of potential issues to examine
ed-nykaza Jan 24, 2019
b015a1e
changing a day to reflect local time
ed-nykaza Jan 29, 2019
5597a85
add total daily dose and correct basals that extend past midnight
ed-nykaza Jan 29, 2019
99c0de7
add cgm and episode stats
ed-nykaza Jan 30, 2019
6423aee
fix return typo
ed-nykaza Jan 30, 2019
6934f7c
turn the try-except back on for run on AWS
ed-nykaza Jan 30, 2019
0f8dd25
remove input argument bypass
ed-nykaza Jan 30, 2019
7d183b0
gather and combine files for analysis
ed-nykaza Jan 31, 2019
f78f128
pumpEvents no longer exists, change to basal and bolus Events
ed-nykaza Jan 31, 2019
ec8b7cb
add dayData back to output
ed-nykaza Jan 31, 2019
500c124
update packages to include allow static figure recreate with plotly
ed-nykaza Feb 8, 2019
f5f146e
add a work in progress (wip) to gitignore
ed-nykaza Feb 13, 2019
effb6ad
code used to generate summary tables
ed-nykaza May 20, 2019
1c9f0fc
exclude parser output in gitignore
ed-nykaza May 20, 2019
7542bf1
change location of data path and file name
ed-nykaza May 23, 2019
07ccf94
change figure output path
ed-nykaza May 23, 2019
a8048ca
ignore local plotly plot
ed-nykaza May 24, 2019
795d642
plots of isf and tdd (local only)
ed-nykaza May 24, 2019
c709afd
update environment
ed-nykaza May 28, 2019
7b4d0f9
plots using jos age and ylw groups
ed-nykaza May 29, 2019
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ work-record-archive
export
internal
data
figures
isf-basal-figures
fonts
wip
projects/parsers/output/

# Test
htmlcov
.pytest_cache



projects/get-donors-pump-settings/temp-plot\.html
9 changes: 5 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ dependencies:
- xlsxwriter
- matplotlib
- scikit-learn
- pip
- plotly
- r
- r-essentials
- plotly::plotly-orca
- poppler
- psutil
- pytest
- pytest-cov

- pip:
- python-dotenv
- -e git+https://github.com/tidepool-org/data-analytics#egg=tidals\&subdirectory=tidepool-analysis-tools
- python-dotenv
71 changes: 71 additions & 0 deletions projects/get-donors-pump-settings/gather-data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
description: gather the ouput from get users settings and events
version: 0.0.1
created: 2019-01-30
author: Ed Nykaza
dependencies:
*
license: BSD-2-Clause
"""

# %% REQUIRED LIBRARIES
import pandas as pd
import datetime as dt
import os
import argparse
import glob


# %% USER INPUTS (ADD THIS IN LATER)
codeDescription = "Get user's settings and events"
parser = argparse.ArgumentParser(description=codeDescription)

parser.add_argument("-d",
"--dataPulledDate",
dest="dataPulledDate",
default="2018-09-28",
help="date in '%Y-%m-%d' format of unique donor list" +
"(e.g., PHI-2018-03-02-uniqueDonorList)")

parser.add_argument("-p",
"--dataProcessedDate",
dest="dataProcessedDate",
default="2019-01-21",
help="date in '%Y-%m-%d' format")

args = parser.parse_args()


# %% START OF CODE
dataPulledDate = args.dataPulledDate
dataProcessedDate = pd.to_datetime(args.dataProcessedDate)

phiDate = "PHI-" + dataPulledDate
donorPath = os.path.join(
"..", "bigdata-processing-pipeline",
"data", phiDate + "-donor-data")

outputPath = os.path.join(donorPath, "settings-and-events")

for name in ["allMetadata", "allAgeANDylwSummaries",
"allAgeSummaries", "allYlwSummaries",
"dayData", "basalEvents", "bolusEvents"]:
allDF = pd.DataFrame()
if name.startswith("all"):
files = glob.glob(os.path.join(outputPath, name + '*'))
else:
files = glob.glob(
os.path.join(outputPath, "data", "**", "*-" + name + ".csv"))
for f in files:
dateModified = \
pd.to_datetime(dt.datetime.fromtimestamp(os.path.getmtime(f)))
if dateModified > dataProcessedDate:
tempDF = pd.read_csv(f, low_memory=False)
tempDF.rename(
columns={'Unnamed: 0': 'originalIndex'}, inplace=True)
tempDF["from"] = f
allDF = pd.concat([allDF, tempDF], ignore_index=True, sort=False)
allDF.to_csv(os.path.join(outputPath, "combined-" + name + ".csv"))
print("completed " + name)
Loading