Abstract
Introduction:
It is important to have accurate information regarding when individuals with type 1 diabetes have eaten and taken insulin to reconcile those events with their blood glucose levels throughout the day. Insulin pumps and connected insulin pens provide records of when the user injected insulin and how many carbohydrates were recorded, but it is often unclear when meals occurred. This project demonstrates a method to estimate meal times using a multiple hypothesis approach.
Methods:
When an insulin dose is recorded, multiple hypotheses were generated describing variations of when the meal in question occurred. As postprandial glucose values informed the model, the posterior probability of the truth of each hypothesis was evaluated, and from these posterior probabilities, an expected meal time was found. This method was tested using simulation and a clinical data set (n = 11) and with either uniform or normally distributed (μ = 0, σ = 10 or 20 minutes) prior probabilities for the hypothesis set.
Results:
For the simulation data set, meals were estimated with an average error of −0.77 (±7.94) minutes when uniform priors were used and −0.99 (±8.55) and −0.88 (±7.84) for normally distributed priors (σ = 10 and 20 minutes). For the clinical data set, the average estimation error was 0.02 (±30.87), 1.38 (±21.58), and 0.04 (±27.52) for the uniform priors and normal priors (σ = 10 and 20 minutes).
Conclusion:
This technique could be used to help advise physicians about the meal time insulin dosing behaviors of their patients and potentially influence changes in their treatment strategy.
Keywords: meal time estimation, type 1 diabetes, multiple hypotheses, data authenticity
Introduction
Challenges With Self-Reported Type 1 Diabetes Data
Because the amount of insulin that a person with type 1 diabetes (T1D) needs fluctuates periodically, endocrinologists often meet with their patients to adjust their various basal and meal time insulin doses.1 Physicians regularly ask patients to keep a record of their carbohydrate and insulin amounts leading up to their visits to provide information that may help them appropriately change treatment.
Self-reported data are still a cornerstone of the latest technology used to manage T1D. Because there are no sensors readily available to measure when someone is eating and how much, it is up to the user of the system to acknowledge when he or she has eaten. For those with insulin pumps or connected insulin pens, the timing and dose of insulin injections is stored automatically, which allows these people with T1D to have a more accurate record of insulin than those using traditional multiple daily injection (MDI) devices (eg, syringes and insulin pens). This allows clinicians to download a verbatim record of all the delivered insulin for a particular individual from their insulin pump. Insulin records for those without insulin pumps or connected pens who use traditional MDI devices, 37% of people with T1D, are recorded manually if at all.2 Self-reported information, especially regarding meals, can be very subjective. Studies have shown that keeping accurate records of meals is difficult and estimates of the amounts of carbohydrates in meals are often inaccurate.3,4
Dissonance Between Meal and Insulin Dosing
Whereas the timing and amounts of insulin injections are often known with a great deal of certainty, what is not known is when food was consumed. It is possible and oftentimes likely that the user of the pump ate and then gave themselves a corresponding bolus sometime afterward. To the clinicians and for purposes of analysis, it can be extremely hard to tell when these meals are occurring.
It is often the case that people with T1D, particularly children, will inject insulin long after meals leading to higher hemoglobin A1c (HbA1c) levels.5 This practice can cause postprandial hyperglycemia and disturb the glycemic balance potentially causing more hyper- or hypoglycemic events if insulin and meals are not aligned properly.6 Furthermore, postprandial dosing is usually a consistent behavioral trend. A study done to gage the prevalence of pre- vs postmeal bolusing behavior showed that 32% of the 21,533 participants surveyed regularly bolused after or during meals.5,7 This practice is not recommended and those who gave insulin after meals reported higher HbA1c values. We propose a method to automatically estimate the time of recorded meals using a multiple hypothesis approach based on insulin pump records.
Methods
Hypothesis Formulation
At each meal event, several hypotheses representing different descriptions of how the meal may have occurred were generated. Initially, the time of the insulin bolus was considered to be the time of the meal and the carbohydrates amount was set equal to the original record. Keeping the bolus at the time that it was known to have been taken, the meal record was altered for each hypothesis (25 in total, with different timings). These hypothesized meals ranged from one hour before the insulin dose to an hour after, each one altered by an increment of five minutes. We ran experiments using three different approaches to setting the prior probabilities of each of the hypotheses. First, we set all the hypothesis priors equal to match a uniform distribution. Then, we used the same estimation procedures, but with normally distributed priors with a mean of 0 minute and a standard deviation (σ) of either 10 or 20 minutes.
Figure 1 shows how the hypotheses were structured. This example only shows nine hypotheses with prospective meal times ranging from one hour before the meal to one hour after to make the structure clearer and so all of the traces could distinctly be shown in one plot. Each of the hypothesis’ meal time differed from the others by 15 minutes.
Figure 1.
Hypothesis structure for posterior probability calculation.
The top subplot shows the continuous glucose monitor (CGM) trace over the course of a day. This was used as the reference signal for each of the hypotheses. The structure of the hypothesis set is shown in the middle subplot. Each bar represents the five-minute interval that the hypothesized meal is said to have taken place. The magnitude of these bars corresponds to the meal amount in grams of carbohydrates. This demonstrates that each hypothesis maintained the original meal size, but offsets the time of that meal from when the bolus was administered. The bottom subplot shows the amount of insulin given at the time of the meal and when that dose occurred. For each of the hypotheses, the insulin record was kept the same. The amount of insulin and timing of the meal time bolus was consistent for each since it is known to be true based on pump records.
Posterior Probability Calculation
At each step in time, predicted glucose for each hypothesis was calculated using the Subcutaneous Oral Glucose Minimal Model (SOGMM).8 The estimated state of this system for each of the hypotheses was updated using a discrete-time Kalman filter where gain and covariance matrices were updated recursively and independent of the disturbance functions. Parameters within the SOGMM model were tuned on a subset of the simulation data. Glucose predictions were then compared to the measured glucose and the posterior probability of each hypothesis was calculated using a formulation of Bayes’ rule. This methodology is largely described in a past work detailing how the posterior probability of disturbance functions imbedded within hypotheses can be found.9 As the model predictions are evaluated, the hypothesis with the highest probability should be associated with the true description of the events that occurred.
In Figure 2, it can be seen how each of the hypothesis probabilities changed as glucose predictions changed following a meal. The top plot shows the respective probabilities of each of the hypotheses in the set, with the correct hypothesis in black. The middle subplot shows the predicted CGM values associated with each hypothesis. The dashed line in this plot represents the actual glucose values and the predicted CGM trace from the correct hypothesis is in black. The bottom subplot shows when the meal and insulin doses associated with that meal occurred. In this particular example, the hypothesis with the highest probability at the end of the evaluation period was the correct hypothesis.
Figure 2.
The posterior probability of the hypothesis set as well as their respective predicted glucose values and when insulin and meals occurred. Posterior probability and predicted blood glucose value from the true hypothesis shown in black.
Meal Time Estimation
The final estimated meal time, , was found by taking a probability-weighted average based on each hypothesis’ final posterior probability, πh, of the time difference between the hypothesized meal time and the time of the insulin bolus, ∆.
Formula for meal time estimate:
| (1) |
Data
To recreate situations where meals and insulin doses were misaligned, simulated data were created using the FDA-accepted UVA-Padova Simulator.10 A total of 100 adult subjects were simulated over the course of a day where they ate breakfast at 6:00 am, lunch at 12:00 pm, and dinner at 6:00 pm. At breakfast, each subject ate 0.5 g of carbohydrates per kilogram of body weight, at lunch it was 1.0 g/kg, and for dinner they had 0.8 g/kg. Insulin doses were randomly distributed for each meal from an hour preceding when the person ate until an hour after. From this data set, 70 subjects were randomly selected to tune the parameters of the SOGMM. The remaining 30 subjects were used as the testing set.
In addition to the simulation data, clinical data collected during a clinical study at the University of Virginia (NCT02558491) where participants used a decision support system during a 48-hour admission were used to evaluate our method. During this admission, subjects exercised and ate meals of varying fat, protein, and carbohydrate compositions. Meal and insulin information was recorded meticulously under the supervision of the study team. The protocol of this study and the data collected is described fully in Breton et al.11 A subset of 11 patients was selected from the clinical data because these subjects used insulin pumps and had complete data for the admission.
For this particular study, there were two separate two-day admissions. These admissions were randomly assigned to be in the training or testing data set. Subcutaneous Oral Glucose Minimal Model parameters were selected for the clinical data set to minimize estimation bias and then tested on the admission data for each subject not used for training.
Analysis
The performance of this algorithm on both simulated and clinical sets of data was evaluated using several different metrics. First, to understand how each was performing in an overall sense, the error for each meal was calculated by taking the difference between the estimated meal time and the actual meal time.
Formula for meal time estimation error:
| (2) |
The mean error (ME) was then found to get a sense if the algorithm was consistently biased toward over- or underestimation. The mean absolute error (MAE) was also measured for each data set so that precision and bias are both reported for the estimation procedure. Additionally, the sample standard deviation was calculated for each metric.
These results were segmented for the simulation data into when the meal occurred. “Late boluses” were instances when the meal happened more than 20 minutes before when insulin was administered. “On-time boluses” were any meals that happened 20 minutes or less from the respective insulin dose and “early boluses” were when insulin was taken at least 20 minutes before the subject ate.
Results
Simulation Data
When applied to the simulation data set as a whole, this method was able to estimate meal times with a ME of −0.77 (±7.94) minutes with uniform priors, −0.99 (±8.55) with normally distributed priors (σ = 10), and −0.88 (±7.84) when σ was set to 20 minutes. For the early boluses, the ME was −3.00 (±3.75), −8.58 (±4.29), and −4.83 (±3.67) minutes for the uniform priors and the normally distributed priors with standard deviations of 10 and 20 minutes. Mean error was 0.12 (±9.10) when priors were uniform, 0.37 (±8.29) when σ was set to 10 minutes, and 0.17 (±8.68) when σ was 20 minutes for the meals that happened within 20 minutes of the bolus. For the late boluses, ME was −1.30 (±6.85) minutes for the uniform priors, 4.70 (±7.34) for the normally distributed priors with a standard deviation of 10 minutes, and 0.56 (±7.03) for the normal priors (σ = 20 minutes).
The MAE for the simulation data when uniform hypothesis priors were used for the early, on-time, and late boluses was 3.85 (±2.82), 7.14 (±5.55), and 5.70 (±3.60) minutes, respectively. When normally distributed priors (σ = 10) were assumed for the hypotheses set, the MAE was 7.22 (±4.62) overall, and 8.58 (±4.29), 6.85 (±4.59), and 6.77 (±5.26) minutes for the early, on-time, and late boluses. When σ of the priors was set to 20 minutes, the overall MAE was 6.30 (±4.69) and 5.03 (±3.37), 6.85 (±5.25), and 5.83 (±3.51) minutes for the early, on-time, and late boluses, respectively. The results for the simulation dataset are given in Table 1.
Table 1.
Algorithm Performance When Applied to the Simulation Data Set.
| Time of bolus | Uniform |
σ = 10 |
σ = 20 |
|||
|---|---|---|---|---|---|---|
| Mean error (±SD) | Mean absolute error (±SD) | Mean error (±SD) | Mean absolute error (±SD) | Mean error (±SD) | Mean absolute error (±SD) | |
| Overall | −0.77 (±7.94) | 6.21 (±4.96) | −0.99 (±8.55) | 7.22 (±4.62) | −0.88 (±7.84) | 6.30 (±4.69) |
| Early | −3.00 (±3.75) | 3.85 (±2.82) | −8.58 (±4.29) | 8.58 (±4.29) | −4.83 (±3.67) | 5.03 (±3.37) |
| On-time | 0.12 (±9.10) | 7.14 (±5.55) | 0.37 (±8.29) | 6.85 (±4.59) | 0.17 (±8.68) | 6.85 (±5.25) |
| Late | −1.30 (±6.85) | 5.70 (±3.60) | 4.70 (±7.34) | 6.77 (±5.26) | 0.56 (±7.03) | 5.83 (±3.51) |
Clinical Data
The clinical data were not broken down into when the insulin dose was taken, because for this trial insulin was dosed very close to the time of the meal. The ME and MAE for this dataset when uniform priors were used were 0.02 (±30.87) and 24.59 (±18.47) minutes, respectively. For the normally distributed priors (σ = 10), the ME was 1.38 (±21.58) and the MAE was 16.19 (±14.23) minutes. When σ was set to 20 minutes, the ME was 0.04 (±27.52) and the MAE was 21.52 (±17.00) minutes. The results for the clinical dataset are presented in Table 2.
Table 2.
Algorithm Performance When Applied to the Clinical Data Set.
| Time of bolus | Uniform |
σ = 10 |
σ = 20 |
|||
|---|---|---|---|---|---|---|
| Mean error (±SD) | Mean absolute error (±SD) | Mean error (±SD) | Mean absolute error (±SD) | Mean error (±SD) | Mean absolute error (±SD) | |
| Overall | 0.02 (±30.87) | 24.59 (±18.47) | 1.38 (±21.58) | 16.19 (±14.23) | −0.04 (±27.52) | 21.52 (±17.00) |
Discussion
Meals where insulin was dosed early, on-time, or late in the in silico test set were all estimated with an MAE of less than nine minutes. Each of these scenarios provides a different sequence of events with regard to insulin and carbohydrate absorption, and the estimation procedure proved accurate in all experimental setups and across different priors that were assumed for each of the hypotheses. The normally distributed priors decreased the MAE and variance for the on-time meals but increased the MAE for the early and late boluses as well as the overall MAE. The ME was increased for the early and on-time boluses when normally distributed priors were used and marginally decreased for the late boluses. In general, when the standard deviation was smaller for the assumed normal distribution of the priors, the ME and MAE, as well as the respective standard deviations of the error, were larger. The uniform priors produced the best ME and MAE values for the simulation dataset overall. The normally distributed priors yielded meal time estimates that were earlier than what was true for the early bolused meals and later than the actual meal times for the late bolused meals. The algorithm performed with acceptable precision (MAE < 9 minutes) with a small degree of variance (SD < 6 minutes) when applied to all of the simulation data.
For the clinical test data, meals were estimated with error values that were almost zero-mean on average, but with large amounts of variance that was dependent on the distribution of the hypothesis’ prior probabilities. For this dataset, the ME was closest to zero when the uniform priors were used. This also led to the highest standard deviation in the mean estimation error (30.87 minutes). When normally distributed priors were used, the MAE and the standard deviation of the ME and MAE decreased in line with the assumed standard deviation of the normal priors. Although the use of normal priors reduced the variance of the estimation error, there was still a large amount of deviance in the error values. The standard deviation of the MAE ranged from 14.23 to 18.47 minutes and the standard deviation of the ME ranged from 21.58 to 30.87 minutes, a considerable increase from the estimates of the simulated meals.
There are numerous reasons why this clinical data set may provide a difficult set of challenges for the algorithm to overcome: (i) Some individual’s treatment parameters such as carbohydrate ratio, correction factors, and basal rates may not be properly tuned. For this data set, insulin dosing parameters were provided by the patient at the onset of the trial and may be suboptimal. (ii) There is still no established method for precisely estimating insulin sensitivity due to its nature to change on an intra- and interday basis. A subject’s actual insulin sensitivity at the time of the meal may differ from what was calculated in the algorithm. This may change the insulin-glucose dynamic and lead to postprandial glucose excursions to be different than what is expected in the model. (iii) An additional factor is that the SOGMM does not incorporate physical activity. If a person exercised before or after a meal, their insulin sensitivity is increased and blood glucose (BG) would behave differently than if they had not. In silico subjects are not affected by the kind of BG variability caused by physical activity, whereas actual patients are very much affected by this. This could lead to differences in predicted and actual BG values when the algorithm is applied to the clinical data set. A possible way of dealing with this kind of uncertainty is to impose priors, such as what was done when the normally distributed priors were used, to weigh the hypotheses that have meal times close to the bolus as more likely. The prior probabilities of each of the hypotheses could be tailored based on the past insulin dosing behavior of a particular individual.
For this evaluation, we emphasized minimizing the bias of the estimation overall. Therefore, parameters from the testing data were selected based on what minimized the average error. Although there was a large spread in the error values, there is a significant benefit of having this kind of error distribution. Having error values that are evenly distributed around zero would allow for an aggregate assessment of behavior to be close to the truth instead of having a distinct skew in one direction or another. Ideally, the variance would be as small as possible.
Conclusion
It is important that meal information is known precisely when analyzing BG data because the timing of meals has a significant impact on postprandial glycemia. The proliferation of insulin pumps and connect insulin pens has made insulin records precise and has gotten us much closer to having complete meal records for individuals who use them. A limitation of this method is that it requires an accurate insulin record. This would have to be manually recorded for those on traditional MDI therapy and may not be accurate for all pump users. In future work, meal detection and estimation techniques could integrate into this approach which would allow for less stringent meal record requirements and could improve accuracy especially if carbohydrate amounts were not recorded properly.
An additional limitation is that, even though estimates have low ME, there is a large amount of variance in the estimates that are produced. This means that, in aggregate, this will provide an unbiased estimate of meal times, but in individual cases estimates could be far off from the truth. In its current form, this algorithm could be used to ameliorate records that have not been verified, but more work would have to be done to make this directly usable in a clinical setting. In future work, we could personalize this method by profiling people’s eating behavior to update the priors related to the possible meal time hypotheses. Additionally, more complex modeling techniques that incorporate the interactions of concurrent meals could be used in addition to personalized glucose-insulin model parameters. The impact of this work is to serve a foundation that can be built upon to create accurate meal time estimation tools. These tools when tuned properly could then be used so that clinicians can work with their patients to demonstrate to them how BG may improve if insulin was delivered properly at meal times.
Footnotes
Declaration of Conflicting Interests: The author(s) declared the following potential conflicts of interest with respect to the research, authorship, and/or publication of this article: Breton is a consultant for Air Liquide and Tandem Diabetes Care and he received unrelated research support from Sanofi, Dexcom, and Tandem Diabetes Care and honorarium from Dexcom. Patek and Breton are the cofounder of TypeZero Technologies, acquired by Dexcom in 2018.
Funding: The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This work was supported by NIH 5R01LM012090-03.
ORCID iD: John P. Corbett
https://orcid.org/0000-0001-5674-3696
References
- 1. American Diabetes Association. 6. Glycemic targets: standards of medical care in diabetes-2018. Diabetes Care. 2018;41(suppl 1):S55-S64. [DOI] [PubMed] [Google Scholar]
- 2. Foster NC, Beck RW, Miller KM, et al. State of type 1 diabetes management and outcomes from the T1D exchange in 2016–2018. Diabetes Technol Ther. 2019;21(2):66-72. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 3. Cordeiro F, Epstein DA, Thomaz E, et al. Barriers and negative nudges: exploring challenges in food journaling. Proceedings of the 33rd Annual ACM Conference on Human Factors in Computting Systems; April 18-23, 2015; Seoul, Republic of Korea. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 4. Meade LT, Rushton WE. Accuracy of carbohydrate counting in adults. Clin Diabetes. 2016;34(3):142-147. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 5. Peters A, Van Name MA, Thorsted BL, Piltoft JS, Tamborlane WV. Postprandial dosing of bolus insulin in patients with type 1 diabetes: a cross-sectional study using data from the T1D exchange registry. Endocr Pract. 2017;23(10):1201-1209. [DOI] [PubMed] [Google Scholar]
- 6. Cobry E, McFann K, Messer L, et al. Timing of meal insulin boluses to achieve optimal postprandial glycemic control in patients with type 1 diabetes. Diabetes Technol Ther. 2010;12(3):173-177. [DOI] [PubMed] [Google Scholar]
- 7. Cameron F, Niemeyer G, Buckingham BA. Probabilistic evolving meal detection and estimation of meal total glucose appearance. J Diabetes Sci Technol. 2009;3(5):1022-1030. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 8. Patek SD, Lv D, Ortiz EA, et al. Empirical representation of blood glucose variability in a compartmental model. In: Kirchsteiger H, Jørgensen JB, Renard E, del Re L. (eds) Prediction Methods for Blood Glucose Concentration: Design, Use and Evaluation. Cham: Springer International Publishing; 2016:133-157. [Google Scholar]
- 9. Patek SD. Open-loop feedback control under multiple disturbance function hypotheses. In: Proceedings of the IEEE Conference on Decision and Control; December 15-17, 2010; Atlanta, Georgia, USA.. [Google Scholar]
- 10. Kovatchev BP, Breton M, Dalla Man C, Cobelli C. In silico preclinical trials: a proof of concept in closed-loop control of type 1 diabetes. J Diabetes Sci Technol. 2009;3(1):44-55. [DOI] [PMC free article] [PubMed] [Google Scholar]
- 11. Breton MD, Patek SD, Lv D, et al. Continuous glucose monitoring and insulin informed advisory system with automated titration and dosing of insulin reduces glucose variability in type 1 diabetes mellitus. Diabetes Technol Ther. 2018;20(8):531-540. [DOI] [PMC free article] [PubMed] [Google Scholar]


