|Home | About | Journals | Submit | Contact Us | Français|
Automatic compensation of meals for type 1 diabetes patients will require meal detection from continuous glucose monitor (CGM) readings. This is challenged by the uncertainty and variability inherent to the digestion process and glucose dynamics as well as the lag and noise associated with CGM sensors. Thus any estimation of meal start time, size, and shape is fundamentally uncertain. This uncertainty can be reduced, but not eliminated, by estimating total glucose appearance and using new readings as they become available.
In this article, we propose a probabilistic, evolving method to detect the presence and estimate the shape and total glucose appearance of a meal. The method is unique in continually evolving its estimates and simultaneously providing uncertainty measures to monitor their convergence. The algorithm operates in three phases. First, it compares the CGM signal to no-meal predictions made by a simple insulin–glucose model. Second, it fits the residuals to potential, assumed meal shapes. Finally, it compares and combines these fits to detect any meals and estimate the meal total glucose appearance, shape, and total glucose appearance uncertainty.
We validate the performance of this meal detection and total glucose appearance estimation algorithm both separately and in cooperation with a controller on the Food and Drug Administration-approved University of Virginia/Padova Type I Diabetes Simulator. In cooperation with a controller, the algorithm reduced the mean blood glucose from 137 to 132 mg/dl over 1.5 days of control without any increased hypoglycemia.
This novel, extensible meal detection and total glucose appearance estimation method shows the feasibility, relevance, and performance of evolving estimates with explicit uncertainty measures for use in closed-loop control of type 1 diabetes.
Type 1 diabetes mellitus afflicts approximately 1 in 500 children and adolescents in the United States.1 It requires frequent attention and careful insulin dosing to avoid seizures associated with low blood glucose (BG) or eye and nerve decay resulting from high BG.2,3
Currently, many patients inject a bolus of insulin before a meal to better compensate for the meal's glucose appearance. This advance bolusing allows the slower-acting insulin to better counteract the meal's faster effect on the BG level. Many proposed diabetes controllers use knowledge of meals as an input to provide a similar early compensation.4–7 The input meal size is then translated through a model of digestion into a total BG appearance and then converted to an insulin dose. We seek to free the patient from needing to log meal times and sizes by providing automatic meal detection and total glucose appearance estimation using the continuous glucose monitor (CGM) signal. In this article, detection refers to the approximation of the binary truth of whether a meal occurred while estimation approximates the continuous quantities of meal start time and meal size.
The available BG sensors only observe the induced glucose rise and are further subject to noise and normal glucose fluctuations. In practice then, it is impossible to detect a meal instantly or to estimate the meal start time and total glucose appearance accurately at the start of the meal. We propose that an estimator should refine its estimate of meal start time and total glucose appearance as it receives new readings. It should further provide a confidence measure of these estimates so that a potential closed loop controller can take only properly justified actions. In effect, the meal start time and total glucose appearance estimates should gradually converge while their uncertainty drops to near zero.
Two explicit meal detection algorithms exist: a voting algorithm8,9 and a finite impulse response filter algorithm.10,11 They detected meals between approximately 9 and 45 min after the meal start. The finite impulse response filter algorithm includes an estimated meal size at the time of detection.
We present a new algorithm that refines its detection of meal presence and its estimates of meal total glucose appearance with each new sensor reading. In addition, it estimates the shape of the future meal effect and provides explicit uncertainty measures. We show its real-time performance on the Food and Drug Administration (FDA)-approved University of Virginia/Padova Type I Diabetes Simulator12 separately and in cooperation with a closed-loop controller.
The algorithm uses an insulin–glucose model to calculate the expected sensor readings in the absence of a meal. The difference between these predictions and the actual sensor readings is the source for all the meal information. We fit the difference against multiple assumed meal shapes, also iterating over all possible meal start times. In particular, for each meal shape and start time, we assess the probability that the data stem from a meal with the assumed shape. We find the start time corresponding to the most probable match. We then refine the estimates of meal total glucose appearance, probability, and total glucose appearance uncertainty for that start time.
We model the rate of change of interstitial glucose (ISG) as dependent upon only insulin action and endogenous glucose production (EGP):
where k refers to the current time step. The sample period was omitted for clarity as we set it to 1 min for the results. Endogenous glucose production is assumed to be constant and is set to make the known patient basal infusion rate effect a constant BG. The insulin action, InsulinAction(k, IS, PI), represents the rate of change of the ISG over the kth time step due to past insulin injections, PI, and the patient's known insulin sensitivity, IS. It is calculated as the convolution of the past insulin injections with an assumed insulin time action profile (ITAP) that provides unit insulin sensitivity multiplied by the insulin sensitivity:
This model explicitly ignores any glucose dependence in the insulin action as well as renal clearance and the autonomic response to low BG levels. We assume tight glucose control that maintains the BG between the BG bounds for renal clearance and the autonomic response to low BG levels.
Figure 1 shows a plot of the assumed cumulative ITAP in blue and some cumulative ITAPs from various references in red.
Specifically, the solid red curves are taken from Reference 13, while the red dashed curve is from Reference 14, the dash–dot curve is from Reference 15, and the red dotted curve is from Reference 16.
To fit meal shapes to the residual between the observed data and the nonmeal model, we need to assume a representative set of meal shapes. Figure 2 shows our representative meal shapes in black. These meal shapes were calculated using the inverse of our method applied to simulator test cases. Specifically, we ran 88 test cases containing meals with a random size between 0 and 100 g carbohydrate (CHO) and a random duration of consumption between 0 and 30 min. For each case, we subtracted predicted BG, assuming no meal, and normalized the difference. The resulting glucose curves are shown in green. We then chose the 10 cases that represented the span of the sample glucose curves. Since we believe the simulator meal shapes drop after the peak due to glucose-dependent action, and we are explicitly ignoring glucose-dependent action in our model, we enforce monotonicity on our 10 representative meal shapes to avoid the negative slopes and remain consistent with our model. The 10 monotonic glucose curves are the representative meal shapes.
We perform the analysis on the rate of change residuals, r(k), defined as the difference between the rate of change of CGM data and the modeled rate of change of ISG. Here k again indexes the time steps. We use rate of change residuals instead of absolute residuals to avoid any uncertainty about the starting glucose of the meal. mj(k) represents the rate of glucose appearance for representative meal shape j and time step k relative to the start of the meal. The meal shapes are scaled for a total glucose appearance of 1 mg/dl. Finally, we assume the rate of change residuals are independent, identically distributed Gaussian noise with a standard deviation s.
We begin by calculating the probability of the data assuming that there is no meal P(data|no meal). The probability of the data assuming no meal is the product over the entire currently available dataset of the probability of the residual at each time step:
We then evaluate the probability of the data under different assumptions about a meal. In particular, we recalculate for a meal having each of the 10 representative meal shapes and each of the possible meal start times. For each meal shape, mj, and start time, k0, we first calculate the meal scale, Sj,k0, to minimize the sum of squared difference between the scaled meal shape and the data:
This scale naturally gives the best estimate of the total glucose appearance for the selected meal. The probability of the data, given the selected meal, is then
To convert to the probability of the meal, mj, at the start time, k0, we apply Bayes rule:
We set the prior probability of a single meal shape, mj, by assuming that all meal shapes occur equally often. We also assume four meals per day that are uniformly distributed across the 16 wakeful hours, or 960 min, between 6 AM and 10 PM. With 10 possible meal shapes, the prior probability during the wakeful hours of a meal with meal shape, j, and start time, k0, is
The prior probability of no meal is
We specifically chose general meal priors to better test the meal detection. The more accurate the meal prior probabilities, the less powerful the meal detector needs to be to succeed.
We now have the probabilities of all possible meal shapes, mj, for each possible start time, k0. We select the start time, that corresponds to the start time with the highest probability across all the representative meal shapes:
The best estimate of the meal shape, , is a composite of the possible meal shapes, mj, calculated as the probability-weighted average of the meal shapes:
The best estimate of the meal total glucose appearance, , is similarly a weighted average of the meal scales, :
The uncertainty of the estimated meal's total glucose appearance, , is found from the probability-weighted sample standard deviation of the 10 possible total glucose appearances, :, about the composite total glucose appearance, :
The composite meal probability given the data and the start time, , is recalculated as shown assuming only the composite meal or no meal.
We use a diabetes simulator approved by the FDA as a substitute to animal trials in the preclinical testing of closed-loop control strategies. This simulator has 100 validation and 10 training adult “subjects” and models both “CGM sensor errors representative of Freestyle Navigator™, Gaurdian RT, or Dexcom™ STS™, 7-day sensor,” and “discrete [subcutaneous] insulin delivery via OmniPod Insulin Management System or Deltec Cosmo™ insulin pump.” 12
We evaluate the algorithm from a variety of perspectives. In particular, we invert the algorithm to recover ITAPs, we examine the real-time performance of the algorithm as it collects information from the sensors, we review performance in a retrospective fashion, and we test the algorithm in combination with a basic controller.
The algorithm assumes that meal action and insulin action superimpose to influence blood glucose levels. Under normal operation, it uses knowledge of insulin action and measurements of blood glucose to estimate meal actions. It can, however, also use knowledge of meal glucose appearance to recover insulin action. With the insulin injection history, it is further able to compute the ITAP from the insulin action.
We use this invertability to recover ITAPs consistent with the detected meals. Specifically, we recover an ITAP foreach of the 100 validation patients in the University ofVirginia/Padova Type I Diabetes Simulator. We use 43 h of simulated data on each patient, subtracting our meal glucose appearance estimates from the blood glucose readings. We then calculate the ITAP and insulin sensitivity for each patient according to our insulin–glucose model using an unconstrained least squares optimization.
Figure 3 shows the cumulative sum of the recovered ITAPs for each patient as black dotted lines. The average of these is shown in green. For comparison, our assumed cumulative ITAP is shown in blue.
The algorithm detects meals of varying sizes in a probabilistic, evolving fashion. This means that it has gradations of belief in whether there is a meal, and that that belief changes over time. To illustrate the probabilistic, time-varying performance of the detector, we show two examples of real-time performance, accuracy of estimates of meal total glucose appearance, and accuracy of estimates of the uncertainty of meal total glucose appearance.
First, we show three examples in Figure 4, where a patient received meals of 0, 33, and 69 g CHO, respectively. The top plot shows the differences between the observed and expected BG and CGM measurements. The middle plot shows the evolving probability of a meal. Meanwhile, the bottom plot shows the estimated meal total glucose appearance in milligrams per deciliter and its 95% confidence bounds when the meal probability exceeds 10%. Measuring the total glucose appearance instead of the meal size avoids the uncertainty caused by digestion and is more relevant for control. For reference, each gram of CHO converts to approximately 4 mg/dl for these simulated patients.
In the 0 g CHO case, the algorithm never calculates any meal probability greater than 9%. As such, any total glucose appearance estimates would be without merit and are not graphed.
For the large meal of 69 g CHO, the meal probability rises to 100% as the difference increases between the observed and expected CGM signal. The estimated meal total glucose appearance and 95% confidence bounds converge to 213 ± 60 mg/dl. The meal probability passes 50% at a CGM residual of 58 mg/dl, approximately one-fourth of the total meal size.
For the 33 g meal, the CGM residual stays low for nearly an hour, so the probability of a meal does not reach 50% until the CGM residual climbs quickly to 39 mg/dl. This high slope causes the algorithm to overestimate the meal total glucose appearance. This overestimation is maintained by the significant positive bias of the CGM versus BG between 70 and 140 min. Because the CGM returns to, but stays above, the BG for the rest of the meal length, the estimated meal total glucose appearance drops but still stabilizes to a high 86 ± 11 mg/dl when the true meal total glucose appearance is 43 mg/dl. This example serves to show that there is a very significant amount of error in the sensor signal that often adds error to the estimated meal total glucose appearance.
In Figure 5, we consider the accuracy of estimates of the meal total glucose appearance over time for meals with a total glucose appearance between 100 and 400 mg/dl (25 to 100 g CHO). The algorithm is given 40 min of noisy data before the meal and is allowed to select any time as the meal start time. The vertical axis shows the standard deviation of the error as a percentage of the actual meal total glucose appearance. The horizontal axis shows number of minutes of data available since the start of the meal. The standard deviation starts at approximately 40% and slowly declines to 13% as more information becomes available. This indicates that the algorithm is capable of harnessing additional meal information encoded in the CGM signal as time progresses.
In Figure 6, we show the usefulness of accuracy estimates versus available information. Specifically, we estimate the standard deviation of the difference between the estimated meal total glucose appearance and the actual meal total glucose appearance. The standard deviation is easily convertible to symmetric theoretical confidence levels (x axis). These confidence levels can be verified by getting the actual incidence of the meal total glucose appearance within the confidence level bounds (y axis). Ideally, these confidence levels would be equal (the black dotted curve).
For 30 to 150 min after the meal and across the full spectrum of confidence levels, the actual and theoretical confidence levels match closely, with a slight bias toward overestimating the accuracy of the meal total glucose appearance estimate. The data for 180–300 min after the meal is omitted due to the lack of the tight glucose control that we assume.
Figure 7 graphs the algorithm's retrospective performance. The algorithm was applied to 99 simulated scenarios that either had no meal (11 cases) or had a meal (88 cases) with a random size (26–98 g CHO) and duration (0–30 min).We graph the steady state meal probability versus estimated meal total glucose appearance for each.
The 11 cases where there are no meals (blue X) receive retrospective meal probabilities that are always below 10%. For the 88 cases with a meal (black circle scaling with the actual meal size), there is a clear correlation of meal size, and estimated total glucose appearance, with the retrospective meal probability. There is a smooth crossover from low meal probabilities to high meal probabilities around an estimated meal total glucose appearance of 100 mg/dl. This transition is expected because small meals are much harder to separate from sensor noise than large meals. Some of the larger meals receive low estimated meal total glucose appearance partially due to the glucose-dependent action caused by the lack of compensation for these meal cases.
We also evaluated the algorithm in combination with a simple controller on the University of Virginia/Padova simulator.
The controller predicts BG into the future as the sum of the CGM measurement, meal information, and insulin–glucose dynamics. The meal information comes from our algorithm in the form of the scaled meal shape and the meal probability. We combine them into an expected future glucose appearance by multiplying the meal probability by the future portion of the scaled meal shape. The estimated effect of meals on the future prediction is then the cumulative sum of the expected future glucose. The effect of the insulin–glucose dynamics on the prediction is the cumulative sum of the insulin–glucose model output from the current time assuming basal insulin delivery.
The controller also observes three sources of noise that corrupt the prediction. The first is the noise in the CGM measurement versus the actual BG. The second is the insulin–glucose modeling error. The third is the noise in the estimation of meal glucose appearance. The standard deviation of the CGM noise is estimated a priori while the standard deviation of the other two sources of noise are estimated online from past prediction accuracy.
Using the prediction and prediction uncertainty, the controller calculates the risk of going below the hypoglycemic threshold of 60 mg/dl during the prediction horizon. It then gives an insulin bolus to set the risk of hypoglycemia to a preset level.
This controller was evaluated on 100 simulated subjects, each with 36 h of closed-loop operation from midnight on one day to lunch on the following day. Closed-loop operation began after 7 h of basal bolus operation from 5:00 PM to midnight. The simulated patient was provided with breakfast at 7:00 AM, lunch at noon, a snack at 4:00 PM, and dinner at 6:00 PM. These meals were 40, 50, 20, and 60 g CHO, respectively.
Table 1 shows various patient population statistics with and without the meal detector and total glucose appearance estimator. With the algorithm, the average BG dropped by 5 mg/dl from an already low glycated hemoglobin A1c (A1C) of 6.4% to an A1C of 6.2%.18 This drop was achieved without incurring any cases below 50 mg/dl, while reducing the percentage of time above 300 mg/dl, and increasing the percentage of time within the target BG range of 70–180 mg/dl.
Meal detection and total glucose appearance estimation increased performance by predicting impending glucose appearance. This allows earlier, more optimal compensation. An example is illustrated in Figure 8. The top graph shows the BG (dotted) and CGM (solid) measurements for the case with (blue) and without (red) meal detection and total glucose appearance estimation. The bottom graph shows the corresponding insulin injections as a function of time. The case with meal detection and total glucose appearance estimation provides a large insulin bolus up front for the meal, causing a significantly more desirable blood glucose level for the 8 h from about 7:00 PM to 3:00 AM. The controller, through the evolving nature of the meal detection algorithm, realizes just after the meal bolus that it over-bolused slightly and compensates by withholding for a period of time. With ouralgorithm (blue), the CGM and BG stay safely lower than without it (red) from shortly after the start of the meal until early morning due to a large bolus applied at the beginning of the meal.
Blood glucose dynamics and measurements are naturally very uncertain and noisy. Performing meal detection and estimation of meal parameters within a probabilistic and evolving framework provides an appropriate structure to this challenge. In particular, we have presented and validated such an algorithm. We demonstrated that meal uncertainty measures, including probability and meal total glucose appearance estimate uncertainty, can be easily calculated and correspond meaningfully to the simulated reality of the University of Virginia/Padova Type 1 Diabetes Simulator. We have further shown that, on average, it is possible and beneficial to refine estimates and uncertainty measures over time. Specifically, the probability of meals can converge, the estimated meal total glucose appearances can become over twice as accurate, and the meal total glucose appearance uncertainties can retain the ability to generate accurate confidence levels.
We also believe this approach to be extensible. For example, future efforts will aim to extend the meal detection and total glucose appearance estimation to multiple meals. It is debatable whether the glucose appearance effects of overlapping meals obey superposition,19 and this will need further study and appropriate consideration in the estimation. Related extensions may detect set failures and night-time attenuations in the CGM signal, estimating their parameters. From an estimation perspective, such failures may be considered disturbance events similar to meals. Again, the probabilistic and evolving properties will allow controllers to curb reactions based on the uncertainty of estimation.
Of course, the main driving force behind our work is the application to closed-loop controllers. Future controllers should leverage the estimation's full power, incorporating uncertainty estimates to better manage insulin administration not only for isolated meals, but for overlapping meals, and would incorporate changes in diurnal insulin sensitivity and changes in insulin sensitivity with exercise. Detection of insulin infusion set failure would also easily fit into our estimation and probabilistic controller. We anticipate that the implementation of these controllers will have a positive impact on the care and daily lives of people with diabetes.
The authors acknowledge Dr. B. Wayne Bequette, Dr. Hyunjin Lee, and Dr. Darrell M. Wilson for their support during the development of this work.