Arsalan Shahid

Next Generation Diabetes Management and the Power of Large-Scale Data Analysis

My dear reader, how are you? السلام عليكم

“There is no disease that Allah has created, except that He also has created its treatment.” (Sahih al-Bukhari 6412) 

This post highlights the evolution and advancements of insulin administration technologies for addressing diabetes management effectively.

Background and Problem Impact

One in ten people around the world is living with diabetes, which is a lifelong condition. Diabetes is listed by the World Health Organization in 2019 as one of the top ten leading causes of death globally. Over 537 Million people globally suffer from diabetes (i.e., 10.5% between ages 20-79). The predicted rise is 643 million by 2030 and 784 million by 2045. Ireland is in the top 25% of diabetes incidence worldwide. According to International Diabetes Federation Atlas, Ireland is ranked 7th in the world for diabetes-related health expenditure per person. Diabetes has been found to be associated with an 87% increase in outpatient visits, a 52% increase in hospital admissions and a 33% increase in emergency department attendances.

Instruments and Technologies

Let’s get a recap and familiarity with existing tools. You might be familiar with syringe injections and insulin pens for insulin input in the body of diabetic patients.

Another tool for insulin administration being used nowadays is the insulin pump that gets attached to the belly and acts as a reservoir for insulin. People with diabetes can keep it in their pockets and insert insulin as they require it.

Similarly, you might be familiar with the blood glucose meter that most people keep at home to test glucose levels. Another technology to monitor glucose levels is a continuous glucose monitor that is a sensor attached to the body and takes a blood glucose reading after every 5 minutes and sends it to the cloud. So, one can track your glucose levels actively on their mobile phone.

Manual and Automated Insulin Delivery (AID)

So, what does the process of manual insulin delivery looks like? Read the data from CGM, read the data from the pump regarding the available insulin, do the maths and insert the required amount of insulin in your body. Human is the decision maker here and this activity keeps on repeating over and over again. But, one gets to sleep and just asks diabetic patients how sleep-less their nights could look like at times …

Then comes into the picture the AID systems that replaced the human effort with a computer to do the maths and make the decisions about how much insulin should be inserted in the body and when. The human here is just monitoring the system and doing minor adjustments based on his exercise and routine.

The first of these systems was developed by, Dana Lewis, who is a diabetic patient and thought of building something for her to get a good night’s sleep and manage diabetes effectively. She connected the tools such as CGM, and Pump, and took a small computer board. Carry all of these in her pockets and made the process of insulin delivery smarter.

And her life got better … she was not going out of the bounds of normal glucose range and started getting uninterrupted nights of comfort. The glucose levels were more stabilised within the normal range of 70-180 mg/dL. Note that anything below 70 mg/dL is considered to be hypoglycaemia and above 180 hyperglycaemia.

Afterwards, seeing the extraordinary improvement in diabetes management, Dana decided to open-source the technology and allow people to use it as a free DIY project that people can use to manage their diabetes effectively at their own risk. A number of algorithms were developed to serve the decision-making process for insulin delivery. And today hundreds and thousands of people worldwide are using closed-loop AID technologies. The open-source disclosure of the technology along with the guided movement called OpenAPS have already been making lives better but not so long after some of these technologies have been approved commercially after FDA approvals.

OpenAPS Data Commons

Early adoption of open-source AID, such as OpenAPS, led to great interest from clinical and research communities regarding data and their outcomes.

With the ever-increasing interest in accessing data from open-source AID users, a method was formulated to allow individuals to anonymously and seamlessly donate data for research. The goal was to remove the burden on individual People with Diabetes (PwD) who wanted to support research but did not want to be frequently contacted individually and asked to share their data. A key developer and founder of OpenAPS worked to build the OpenAPS Data Commons on the OpenHumans platform, which enabled individuals to anonymously upload their data and share it.

OpenAPS Data Commons dataset contains:

Why Study Glucose Variability (GV)?

GV has been observed to have a correlation with hypoglycemia. Previous studies have found glucose variability to be a predictor of severe hypoglycemia, but the exact relationship between them is unknown. Hyperglycemia and glycemic variability are considered to be a factor inducing oxidative stress and overproducing reactive oxygen species. With AID data, it is possible to assess rates and incidents of hypoglycemia and hyperglycemia and study their exact relationship with glycemic variability.

Our recent contributions using OpenAPS Data Commons 

We recently published a paper in Nutrients Journal to study the GV outcomes of Open-source AID systems using large scale data analysis and registered the following main contributions.

Material and Methods

Following are the summarised material and methods we introduced in the paper starting from Diabetes data collection, to preparing it for analysis, and selection of appropriate metrics.

Some of the analysis metrics we selected and studied in detail include the following

Summary of Glucose Data in OpenAPS Data Commons

Glucose mean and distribution for insulin-requiring individuals using open-source AID systems are shown in the figure below. The average glucose mean and SD across the individuals is 139 ± 49.8 mg/dL.

OpenAPS Data Common Demographics Data Analysis

The below heatmap figure on the left shows the highest correlation of 69% between weight and daily insulin units. Second-highest correlation is between weight and basal units equal to 61%.

The plot on the right shows the distribution of self-reported demographics with respect to gender and highlights a greater intake of carbs and basal in males as compared to females. The average insulin intake by males and females is 45.58 and 49 units, respectively.

Glucose Data Analysis

We did perform a number of analysis on glucose profiles alongside calculating the metrics we previously selected for statistical and variability analysis. We individually visualised each glucose profile for insulin-requiring individuals in OpenAPS data commons as shown below for a random (n=1) person.

Summarized results of GV metrics for insulin-requiring individuals in OpenAPS Data Common are shown below:

The following interesting plot shows the TIR and TOR for glucose data from OpenAPS Data Commons dataset. The average TIR for insulin-requiring individuals in OpenAPS Data Commons dataset is 77%. There is a higher tendency for individuals to have more TOR situations over the higher TIR limit (180 mg/dL) as compared to TOR situations less than the lower TIR limit (70 mg/dL).

Another analysis we performed was to understand the glucose rate of change. The following plot summarises the analysis. The minimum, average, and maximum of SD ROC calculated separately for males and females are {0.60, 1.36, 2.6} and {0.7, 1.4, 2} mg/dL per minute, respectively.

We did perform a lot of glucose variability distribution analysis and plotted the distributions for males and females individually. This post will not cover all the explanations to avoid redundancy. But the following snapshot gives a glimpse of the distributions we analysed in-depth.

Furthermore, we performed timeseries analysis. Both individual (n=1) and overall (n=122) analyses were performed on the datasets. The following screenshot gives a glimpse of glucose distribution plots we developed for each patient individually over the hours of a day, days of week/month, and months of a year.

The following plots show the average glucose mean and standard deviation for insulin-requiring individuals in the OpenAPS Data Commons dataset during days of the week based on gender. The mean glucose levels for females are slightly greater than for males throughout the week, and similarly, SD is higher in females than males, although there is a different pattern throughout the week between genders. In this dataset, female SD is highest on Monday whereas males have a higher SD on Saturday.

The following plots show the average glucose mean and standard deviation for insulin-requiring individuals in the OpenAPS Data Commons dataset during hours of the day based on gender. Moving to an assessment of the hours throughout the day, both females and males follow a similar pattern of glucose means dropping between midnight and 8:00 am, then rising throughout the day and evening until midnight.

The following plots show the average glucose mean and standard deviation for insulin-requiring individuals in OpenAPS Data Commons dataset during months of the year based on gender. For assessing changes throughout a calendar year, glucose means and SD is again higher in females than males; however, the variation in terms of SD between gender are greater in the first and last 4 months of the year. The summer months (i.e., May through August) result in lower SD for both males and females. This matches the existing population-based literature findings of seasonal variation among people with diabetes.

The following plots show the average glucose mean and standard deviation for insulin-requiring individuals in OpenAPS Data Commons dataset during days of the month based on gender. Throughout a typical calendar month, the mean glucose of females is relatively flat throughout the month but with changes in SD throughout the month. This matches findings from studies with commercial AID systems where glucose is well-managed on average by AID systems throughout the menstrual cycle. However, up to two-thirds of women may experience a menstrual cycle phenomenon, so further analysis should be done within the female-specific sub-population to assess the two thirds who experience cyclical changes separate from those who do not.

Important Considerations and Discoveries

Graphical Summary/Conclusions

We believe that there is a huge potential in making millions of lives easier and better with recent advancements in technologies and through the power of data analysis platforms. As the world is becoming data-driven, so are the healthcare devices and tools that need to be further developed to unleash the potential of technologies for next-generation diabetes management.

Full Publication Reference and Code

Shahid A, Lewis DM. Large-Scale Data Analysis for Glucose Variability Outcomes with Open-Source Automated Insulin Delivery Systems. Nutrients. 2022; 14(9):1906.

All analysis notebooks from this publication are available Open Source on GitHub.


I hope you find this post useful. If you find any errors or feel any need for improvement, let me know in your comments below.

Signing off for today. Stay tuned! Happy learning.

Exit mobile version