Package: diyaps-toolbox
DIYAPS ToolboxThe DIYAPS (Do-it-yourself Artificial Pancreas) Toolbox provides a set of functions for working with the data which can be extracted from AndroidAPS, Loop (iOS) and OpenAPS systems.
The following table provides an overview of all the data items which can be calculated using this module. Each of the functions is explained in detail below:Data ItemDescriptionFunctionDays of data donatedThe period of time contained in the donated data based on the earliest and latest timestampcalculate_days_donated(date, date_format = "%Y-%m-%d-%H:%M:%S")Mean sensor glucoseMean of all sensor glucose values in the Entries filecalculate_glucose_mean(glucose_values)Standard deviation of sensor glucoseStandard deviation of all sensor glucose values in the Entries filecalculate_glucose_sd(glucose_values)Coefficient of Variation of sensor glucoseCoefficient of variation of all sensor glucose values in the Entries filecalculate_glucose_cov(glucose_values)Glucose Managment IndicatorFunction for estimating the HbA1c value based on mean sensor glucose, as proposed by [1].calculate_gmi(glucose_values)% Time in RangeThe time spent within the optimal range (by default set to 70 and 180 mg/dL) as a percentagecalculate_time_in_range(glucose_values, lower= 70, upper= 180)% Time below RangeCalculates the time spent below a certain threshold value (default = 70 mg/dL)calculate_time_below_range(glucose_values, lower = 70)% Time above RangeCalculates the time spent above a certain threshold value  (default= 180 mg/dL)calculate_time_above_range(glucose_values, upper = 180)Number of hypoglcemic episodes per dayThe mean number of hypoglycemic episodes per day. This function considers how often the blood glucose level   dropped below the threshold (default = 70 mg/dL)calculate_hypos_per_day(glucose_values, date, lower= 70, date_format = "%Y-%m-%d-%H:%M:%S")Number of hyperglycemic episodes per dayThe mean number of hyperglycemic episodes per day. This function considers how often the blood glucose level rose above the threshold (default = 180 mg/dL)calculate_hypers_per_day(glucose_values, date, upper= 180, date_format = "%Y-%m-%d-%H:%M:%S")Percentage of persistent hypoglcemic episodesThe amount of hypoglycemic episodes that persisted for longer than 2 hours, as a percentage of all hypoglycemic episodescalculate_persistent_hypo(glucose_values, lower= 70)Percentage of persistent hyperglcemic episodesThe amount of hyperglycemic episodes that persisted for longer than 4 hours, as a percentage of all hypoglycemic episodescalculate_persistent_hyper(glucose_values, upper = 180)Percentage of overtreated hypoglcemic episodesThe percentage of hypoglycemic episodes that resulted in subsequent hyperglycemia within 2 hourscalculate_overtreated_hypo(glucose_values, lower= 70, upper = 180)Percentage of overtreated hyperglcemic episodesThe percentage of hyperglycemic episodes that resulted in subsequent hypoglycemia within 4 hourscalculate_overtreated_hyper(glucose_values, upper= 180, lower = 70)Number of meal boluses per dayThe mean number of meal boluses per daycalculate_meal_bolus_per_day(treatment_df, date_format = "%Y-%m-%d-%H:%M:%S")Number of correction boluses per dayThe mean number of correction boluses per daycalculate_correction_bolus_per_day(treatment_df, date_format = "%Y-%m-%d-%H:%M:%S")Grams of carbohydrates per dayThe mean number of carbohydrates entered into the system per daycalculate_carbs_per_day(treatment_df, date_format = "%Y-%m-%d-%H:%M:%S")Units of correction insulin per dayThe mean number of insulin units administered by the system as a correction bolus per daycalculate_correction_units_per_day(treatment_df, date_format = "%Y-%m-%d-%H:%M:%S")Grams of carbs per mealThe mean number of carbohydrates per meal boluscalculate_carbs_per_bolus(treatment_df)Units of insulin per correction doseThe mean number of insulin units per correction boluscalculate_correction_units_per_day(treatment_df, date_format = "%Y-%m-%d-%H:%M:%S")Installationpip install diyaps_toolbox[1]: Richard M. Bergenstal, Roy W. Beck, Kelly L. Close, George Grunberger, David B. Sacks, Aaron Kowalski, Adam S. Brown, Lutz Heinemann, Grazia Aleppo, Donna B. Ryan, Tonya D. Riddlesworth, and William T. Cefalu. “Glucose Management Indica- tor (GMI): A New Term for Estimating A1C From Continuous Glucose Monitoring”. In: Diabetes Care 41.11 (Sept. 2018), pages 2275–2280. doi: 10.2337/dc18-1581. url:https://doi.org/10.2337/dc18-1581.