Menu

Linear predictor, my first approach to a closed-loop system…

If I can know what my blood glucose will be in the future, I can bolus for or stop bolusing for it in advance.

A little bit of history…

Back in 2014, when I had absolutely no idea of how my metabolism worked and how most of the elements that control our blood glucoses interact, one of my first ideas was:

If I can know what my blood glucose will be in the future, I can bolus for or stop bolusing for it in advance.

Looking back at this idea now… I am very happy I decided to erroneously believe I could solve this super complex problem employing this approach. It really helped me become frustrated at not achieving a good result and pushed me into learning more and understanding my condition better.

What is a linear predictor good for in a closed-loop system?

In my opinion, a predictor helps in two important ways:

a) It helps to have a better view of what is going on with your blood glucose given that most CGMs have around a 15 minute data delay ( what the CGM shows, actually is 15 minutes in the past ).

b) It helps to give an advantage over the delay our modern insulins have from the time it gets in our bodies to the time it starts acting.

What are its limitations?

In order for me to show the predictor limitations, I must show a couple of examples using data that would be available under some circumstances of a person with T1D.

Example I
I am asleep without any carbohydrates on board and my bg is super steady. This is the T1D dream come true.

Scenario A

If you look at the graph, the predictor tries to react really aggressively to any “indication” of an increment / decrement of bg.

Example II
I am awake and although my bg has some variations, they are not aggressive. This scenario is a bit more common once you have a closed loop system in place.

b

The predictor here is really efficient when trying to reduce any unexpected increment / decrement in bg.

Example III
Something is going on… my variations are starting to be more aggressive… It could be a change in my insulin sensitivity, sudden physical activity…

c

d

For me, this is what is going on with my body on any “normal” day with activities… The predictor here starts missing out on some important events.

Example IV
Diabetes nightmare. There are a lot of examples for these situations… ranging from sickness, to a bad sensor, to miscalculated food carbohydrate intake…

e

In these situations, the predictor will not help much in controlling bg as it will be basically chasing the data. Hopefully for these situations you already have your own closed-loop system in place.

If you still haven’t, please take a look at:

OpenAPS
http://github.com/openaps

Loop
www.github.com/Loopkit

The Code

If you are interested in the code, I invite you to take a look at it on the following link:
https://github.com/bustavo/simpancreas_predictor

The code will be updated as we go… please make sure to submit an Issue if you have any questions. Feel free to use the code on your own projects, if you do any updates, please submit a pull-request so everyone can have access to it.

#wearenotwaiting

Comments

comments