Abstract
Introduction:
Continuous glucose monitoring (CGM) is emerging as a transformative tool for helping people with diabetes self-manage their glucose and supporting clinicians in effective treatment. Unfortunately, many CGM users, and clinicians, find interpreting the large volume of CGM data to be overwhelming and complex. To address this challenge, an efficient, intelligent method for detecting and classifying discernable patterns in CGM data was desired.
Methods:
We developed an automated artificial intelligence (AI)-driven method to detect and classify different discernable CGM patterns which called “CGM events.” We trained different models using 60 days of CGM data from 27 individuals with diabetes from a publicly available data set and then evaluated model performance using separate test data from the same group. Each event is classified according to clinical significance based on three parameters: (1) glucose category at or near the beginning of the CGM event; (2) a calculated severity score that encompasses both signal shape and temporal characteristics (e.g., how high the CGM curve goes (measured in mg/dL) and how long it stays above target (as established by published consensus guidelines); and (3) the glucose category at or near the end of the event.
Results:
The system accurately detected and classified events from actual CGM data. This was also validated with expert diabetes clinicians.
Conclusions:
Advanced pattern recognition methods can be used to detect and classify CGM events of interest and may be used to provide actionable insights and self-management support to CGM users and decision support to the clinicians caring for them.
Keywords
Introduction
Continuous glucose monitoring has emerged as a transformative tool for helping people with diabetes and their care teams in managing diabetes. More favorable reimbursement policies, decreasing CGM unit cost and improved CGM accuracy have all contributed to a significant acceleration in CGM adoption, resulting in an increase in the volume, of dense CGM data now available.1 -4 The complexity of interpreting this large amount of data can be overwhelming and challenging for people with diabetes and the clinicians who care for them. 5 Many primary-care providers—who are the frontline for treating type 2 diabetes—may be unfamiliar with and not sufficiently trained on how CGM data can be interpreted and acted upon. 6 As adoption of this technology continues to expand, it will be critical to integrate CGM technology and the resulting data into clinical practice, including in the primary-care setting where most people with diabetes are cared for. 7
Our objective was to leverage pattern recognition science and advanced artificial intelligence (AI) to develop an automated method aimed at detecting and classifying discernable, self-management events reflected in a CGM data trace, to ultimately aid in how the data should be interpreted and acted upon by both patients and clinicians.
Any pattern-recognition system is trained to take an input signal (e.g., any 1D, 2D, or 3D signal as a function of time), remove noise and clutter, detect reference patterns of interest, extract key features to characterize the detected pattern, and then classify/identify detected patterns based on a set of predefined rules. 8 While the application of such systems is quite prevalent in statistical process control, defect identification in manufacturing, spatial image analysis and facial recognition, 9 the application to aid the analysis of a CGM signal in health care is considered novel. 10
Methods
Our data set for both training and testing our algorithms was derived from a publicly available data set, 11 an online source of patient-level CGM data that is available for researchers to use for statistical analysis purposes. Our sample data contained 48 121 unique CGM readings with time stamps for the first 30 days taken from six de-identified individuals with type 1 diabetes. 11 We split the data into two sets: data from the first 25 days was used for training models, and data from the last 5 days was used for testing models.
We developed a computationally efficient detection algorithm based on time series analysis and pattern matching. The main steps and applied methods are as follows: (1) reference pattern creation, (2) pattern detection, (3) event attributes extraction, (4) CGM event classification, (5) training and testing, and (6) validation.
In step 1, reference pattern creation, we applied dynamic time warping (DTW), hierarchical clustering, and DTW Barycenter averaging 12 to identify the major event patterns of interest as shown in Figure 1.

Four reference patterns used for training the model.
In step 2, pattern detection, the algorithm searches for and detects reference patterns by examining the encoded sign changes (i.e., positive or negative slope changes) of the first derivative of the smoothed CGM series. Such techniques are well researched 13 and applicable here, given the “noisy” fluctuations typical in a CGM signal.
In step 3, event attributes extraction, for each detected event, we extract related information to characterize the event and classify it according to clinical significance based on three parameters: (1) glucose category at or near the beginning of the CGM event; (2) a calculated severity score that encompasses both signal shape and time (i.e., how high the CGM curve goes and how long it stays above target); and (3) the glucose category at or near the end of the event.
In step 4, CGM event classification, we used a 3D characteristics vector to label and classify each detected CGM event. “B”: glucose status at the beginning of a CGM event; “S”: a calculated severity score defined by time above target glucose and the shape of the CGM event, and “E”: glucose status at the end of a CGM event.
Possible levels for B and E were based on the glucose categories defined in clinical practice guidelines: 14 high (H) glucose >180 mg/dL; normal (N) glucose 70 to 180 mg/dL; low (L) glucose 54 to 70 mg/dL, and very low (VL) Glucose <54 mg/dL.
Table 1 describes the rules used to assign a severity score to a detected shape. TAR is time above range (i.e., time during a CGM event when the glucose value > 180 mg/dL), and TVH is time very high (i.e., time during a CGM event when the glucose is >250 mg/dL). Severity varies from a good score of 0 to a worst score of 9. Note that the serverity score refers to the severity of the hyperglycemia only. Hypoglycemia is indicated in B and E with the L and VL thresholds.
Derivation of the Severity Score.
Abbreviations: TAR, time above range; TVH, time very high.
To validate the assignment of severity score against industry consensus guidelines, we sought to correlate severity scores against a known CGM metric such as time-in-range (TIR). We calculated average TIR in any given month and also average severity score in that month and plotted the two variables. This is seen in Figure 2. We found the Pearson correlation to be −0.96, depicting a strong correlation between the industry standard metric TIR and our assignment of severity score.

Correlation between average TIR and average severity score.
In Step 5, training and testing, our algorithm used two tuning parameters, smoothing degree and slope adjustment threshold. We optimize the parameters by minimizing a modified 0 to 1 loss function on training data. We trained for optimal parameters at both the individual and global levels. The performance of the algorithm was tested on a separate testing dataset from the same patients as discussed earlier. The 10-fold cross-validation method was used to iteratively tune the necessary parameters. 12
In the final step, step 6, validation, the outputs of our algorithm were applied to new CGM traces that were not used during training. In addition, the outputs of the algorithm were compared with that determined by a panel of six endocrine diabetes experts familiar with CGM. We thus compared the performance of machine-detected and classified CGM patterns of interest against that which a trained clinician would detect and classify.
Results
Figure 3 shows an example of the model and its output. The green zone depicts a normal glucose target range of 70 to 180 mg/dL. The light blue curve shows the actual CGM input signal with its normal perturbations. The thick red lines show the smoothed events detected by the system. These events are labeled 1 through 6 in Figure 3.

Sample model output and detected patterns of interest.
Table 2 summarizes the parameters associated with the detected CGM event patterns in Figure 2. Each event is characterized by a starting and ending time, a starting and ending glucose value status and the classified score per our algorithm.
Parameters Associated With CGM Patterns in Figure 3.
Abbreviation: CGM, continuous glucose monitoring.
To further validate the ability of the model to accurately detect and classify CGM patterns of interest, we formulated a small study to compare the model outputs to that from trained diabetes experts. A protocol for study was developed and reviewed by the University of Maryland Institutional Review Board. Continuous glucose monitoring data from six individuals from the data set were used for this validation analysis. The raw CGM data were processed using the automated detection and classification algorithm. The same raw data were given individually to a group of six diabetes experts in an endocrinology practice. The CGM events detected by the system as well as their respective severity score classification ranging from 0 to 9 were compared to those determined by the diabetes expert group. Figure 4 shows the aggregate results for each of 6 days of CGM data, including the events detected and classified by the model as well as those for each of the six diabetes experts, superimposed into one chart per day for ease of visual comparison.

Event detection for 6 days of CGM data: “Machine vs. human.”
To compare “machine vs. human” ability to detect and classify different CGM patterns of interest, we performed a simple correlation analysis for both outcomes. A scatter plot showing the correlation of the mean of severity scores as determined by both the system as well as by the diabetes experts is shown in Figure 5.

Scatter plot comparison of mean severity scores as determined by diabetes experts and the automated system.
The human diabetes experts took an average of 14.5 minutes to complete the CGM worksheet to identify and classify CGM events of interest (range: 8-22 minutes). The automated system identified 12 events over the 6 days of CGM data, compared to 15.7 ± 5.4 events in the human expert group (range: 8-22 events (Figure 3). Eleven events were detected by both the system and the human experts, though three of those events had significant differences in the duration of the event. There was one event detected by the system but not by the human group, and there were two events detected by the human group and not by the system, yielding a sensitivity for the system of 89%. The severity scores computed by the system and those assigned by the human group were highly correlated (Pearson’s r = 0.87; Figure 5).
Discussion
As the volume, variety, and frequency of personal health data available to individuals increases, it is paramount to translate that data into meaningful insights and visualizations to inform self-management behavior and clinical decision support. In doing so, it is important to ensure that individuals are able to understand and, when appropriate, act upon health data in a safe and effective manner. 15 Continuous glucose monitoring data and its associated patterns and events present a great opportunity for AI to be applied to extract and convey value to a patient and their clinical team in a simple and understandable way. Figure 6 depicts an example of how the automated event detection and classification model has been safely integrated into the Welldoc App, a U.S. Food and Drug Administration (FDA)-cleared, class II software as a medical device solution for people aged 18 years and older diagnosed with type 1 or type 2 diabetes. In this example, the patient who uses the solution is presented with a daily CGM “pattern summary” that provides not only basic CGM information such as amount of time spent in-range, below-range, and above-range but also any detected events of interest along with an explanation of the clinical significance of that event, which could aid in supporting patient education and behavior modification to learn from these events and improve their glycemia over time.

Inclusion of event detection and classification in a digital health solution.
Conclusions
Machine learning and pattern recognition techniques can be applied to accurately detect and classify CGM events of interest. The classification of detected events may give CGM users and clinicians more insights into interpreting glucose data and may be useful in automated coaching of people with diabetes, in remote patient monitoring applications and additionally, for clinical decision support. Further research using larger data sets across various diabetes populations is needed along with ongoing validation work with expert clinicians.
Continuous glucose monitoring, in and of itself, holds tremendous potential for illuminating better pathways for diabetes self-management and care by the person with diabetes and their clinical team. Integrating dense CGM data in an advanced AI-driven digital health tool transforms volumes of data and distills it into personalized coaching insights that provide a clear and connected picture of food, medication, activity, and glucose patterns best supporting individuals in their daily self-management decisions and informing clinicians in timely therapy adjustments. A combined CGM and digital health solution inherently provides the ability to track self-management actions against a dense, passively collected outcome variable of glucose. By taking data from a patient cohort and segmenting into two classes—those who improve glycemic control versus those who do not—machine learning models can be employed to determine the effects of single or multiple self-management actions. This analysis was not possible with intermittent finger sticks with a blood glucose meter, due to the lack of dense glucose data against which to correlate the effects of self-management actions. It may be possible in future work to explore the relationship of new CGM metrics such as the Glycemic Risk Index (GRI) with the event classification capability. 16 Ongoing research will continue to explore the synergy of CGM plus AI-driven digital health tools in diabetes self-management and care.
Footnotes
Acknowledgements
The source of the data is the T1D-Exchange, but the analyses, content, and conclusions herein are solely the responsibility of the authors and have not been reviewed or approved by the T1D Exchange.
Abbreviations
AI, artificial intelligence; CGM, continuous glucose monitoring; DTW, dynamic time warping; ML, machine learning; PWD, person or patient with diabetes; TIR, time in range.
Author’s Note
Editorial writing assistance was provided by Janice Macleod, Janice Macleod Consulting. Welldoc Diabetes and Welldoc Diabetes Rx is an FDA-cleared medical device, intended for use by health care providers and their adult patients with type 1 or type 2 diabetes. For full labeling information, visit
. The other Welldoc App products are non-FDA-cleared and intended to promote general wellness and education/self-management of various long-term disease states.
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: MS, AK, and AI are employees of Welldoc, Inc. SL and GG received funding from Welldoc, Inc.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This study was funded by Welldoc, Inc.
