This project is the result of about 2 years of research ( looking for people & tools ) beginning in 2013 plus a year of continuous development in a process that has been characterised by learning about this condition I thought I was an expert at.
My project, like many others, began as an alarm system to wake up at night in case I was not able to hear the alarms from my continuous glucose monitor ( CGM ).
Before reading, you have to understand a little more about this condition. If you know nothing and want to better understand the importance of this project, please, read here.
If you know about Type I Diabetes, the most important question always is:
How do you manage to keep control of your blood glucose all the time?
The only way to be within normal blood glucose ranges when you have Type I Diabetes is:
By measuring and calculating everything you do in the day to know how much insulin you require (what the pancreas did when it worked).
Before my artificial pancreas, on any average day, I had to do more than 100 mental calculations to try and be within range.
The fewer mental calculations made, the more variation was added to my blood glucose graph throughout the day.
Well then, you do calculations and problem solved, right? You’ll get better over time. Yes, but what happens when you’re in a meeting? When you’re going through airport security? When you’re asleep? When you’re in the middle of something that you can not distract? Like playing video games 😀 ?
Check out my: Why I want an artificial pancreas post.
There are devices that have been developed over the years to make this management process easier. The two most important for me are:
The insulin pump.
This device, which resembles a radio beeper from the 90’s, administers insulin using a pre-programmed schedule ( basal profile ) throughout the day according to your body needs.
Decisions to build your basal profile schedule, are reviewed in detail with a specialist who monitors various measurements such as blood glucose and other indicators like body weight.
Having an insulin pump, eliminates the need for injections, but you still must have the same and/or more caution to ensure that, before the insulin pump makes any decision, it will not hurt you.
The continuous glucose monitor (CGM for its acronym in English).
This is my favourite device. It is basically a sensor inserted under the skin that measures the resistance of an electric current being passed through it. This resistance is converted into a glucose measurement.
Measurements are calculated every 5 minutes and you can observe trends and be aware of what happens to modify and optimise your treatment almost in real time.
A big advantage is that it has alarms so you can pay attention when you are too low or too high or rising too fast or descending very fast.
One drawback: You have a 15 minute delay for the information you receive. So if your measurements are more or less like this: 115, 110, 105, it means that in reality, you are probably around 90 mg/dl.
To me, the most important thing about the CGM has been my ability to take greater risks on the level of blood glucose I can have. Before using these devices, my blood sugar was on average about 135 mg/dl.
Closing the Loop
When researching online, I found the incredible work of Benjamin West ( www.github.com/bewest ) who started working on a project to reverse engineer Diabetes treatment devices in order to restore reliability and fidelity.
As patients, we must be able to know that these devices are doing and the way they make decisions for us.
Benjamin, to whom I am extremely grateful, decided to open source all of his work.
By using the tools developed by Ben, I developed my own open source library ( http://github.com/bustavo/carelink_notificator ) to use a Raspberry Pi microcomputer and extract measurements from my CGM and send them to my phone with alarms if necessary, alerting me and my loved ones from whatever was happening to me.
With this, I realised that I could continue manipulating the information obtained from the sensor. At this point I was downloading it and sending it over the Internet.
There was still a big problem:
The available information, by itself, does not resolve the variation in blood glucose levels. You have to act on it. On time. Correctly.
To this point in time, my attitude towards this project was more or less like:
I was not the first to achieve closed-loop. Dana M. Lewis and her now husband Scott Leibrand, who began with a project very similar to mine in order to have better alarm quality, developed an application that manipulates the insulin pump’s basal profile.
Their project, now known as OpenAPS ( openaps.org ), makes emphasis on making it clear that the project is not: “set and forget” for safety reasons, which we all agree.
Being the most stubborn person in the world, I decided to develop my own “set and forget”system I ended up calling simPancreas.
Each step in this process has been more or less like this:
I still have to tell the system how much carbohydrates I am having for meals and their approximate absorption time ( related to the glycemic index ) but the rest of the time I can say I have sort of achieved the “set and forget” part.
I still work daily on optimising the system, one of the reasons I still have not decided to make the tools open-source.
The following were the iterative steps I have been through up to now:
Fuzzy Logic Controller
It was my first approach to tackle the problem for the number of mental calculations I had to do.
A fuzzy controller takes 2 values with a reference to each other and may determine an intermediate value between them.
Usually we refer to things with reference values:
Someone is tall
Someone is short
What happens when we say someone is too tall? How tall is too tall?
For me, from day to day, I could observe my glucose levels and according to their speed and current value, I could determine an amount of insulin required at that time to return to a “normal” value.
The controller emulated my behaviour, but for some reason I could not understand at that time, I always ended up with a lower blood glucose than desired.
Predictive Controller with Active Insulin ( Insulin On Board – IOB )
This was my second iteration. I decided to discard Fuzzy Logic and went down a path of greater logic:
If I look at my blood glucose records, I can determine a future value (prediction) and according to that prediction I can make insulin dosing decisions considering the next three hours the insulin will be active in my body, thereof, determining if it will sufficient or not.
This iteration was very successful in its implementation, but it still was not enough. When leaving the system running by itself ( the forget part ) and had a meal, my insulin resistance changed and decisions were basically incorrect. In the short term, I needed more insulin, but in the long term (2 hours) it ended up being too much.
I had to tell the system when I had food in my body.
Predictive Controller with Active Insulin ( IOB ) + Active Carbohydrates ( Carbohydrates on Board – COB )
The system works with the following steps:
1. Study the glucose past to predict its future. These predictions are 20 minutes ahead, for now.
2. Consider insulin delivered in the past, which is still active, to determine how much glucose will continue to decline for the remaining active time. For me, insulin has a 3 hour duration/effect. I have to live with the insulin dosing decisions I do now for the next 3 hours.
3. In case of meals, consider the effect that these have on glucose as they are absorbed during the indicated absorption time ( still have to be an expert at counting carbs! ).
4. With this resulting glucose, calculate required insulin to return to the desired blood glucose level. If it is excessive, the pump will stop until the correct level is reached again.
5. Whatever the system does, it should be sent through Pushover (http://pushover.net) to my cell phone and my loved ones.
The algorithm considers the dynamics that occur with insulin sensitivity throughout the day, something they never teach us, because, well it is dynamic and it is difficult to calculate when you do not have the required data.
The system runs autonomously 24/7 and is updated every 5 minutes. All carbohydrate entry for meals and monitoring records are controlled from my mobile phone with the following interface:
So, what are the results?
1. I have not used the buttons on my insulin pump for months, other than for blood glucose calibration and battery changes.
2. This has been my glucose graph for the last month (average 120 mg/dl):
I have decreased considerably my blood glucose standard deviation.
I managed to have measurements below 80 mg/dl in less than 6% of the time.
I managed to have measurements above 160 in less than 18% of the time.
I managed to be in a range between 80 mg/dl and 160 mg/dl in 75% of the time.
What am I looking for with this publication?
1. When you see that bulge hanging on my side, know what it is … it’s what allows me to temporarily enjoy life, making by itself the decisions that keep me from doing so.
I’m already working to make it fit in my pants pockets.
2. I would like more people with open source software & electronics skills to get interested in this.
There are people around the world working on projects and tools that can be integrated into a solution as simPancreas / OpenAPS:
One of the groups that started it all. They focus on developing tools for patients with Type I Diabetes and their families, so they can have access to blood glucose data in real time.
The tools that helped make the interface between the CGM and insulin pump for the generation of existing solutions today.
Open Source Artificial Pancreas System. If you have expertise in some of the things I mentioned here, I think it’s the best place you can go to start working on your own solution.
Finally, I would love to continue contributing to advances in technologies to treat these conditions, if you have not noticed, technology has not moved considerably in 15 years compared to what few daring people have done in one year. In their homes. In their spare time. With cheap components and open source software.