Tuning My Pump Settings With AndroidAPS and Nightscout

This is going to be an interesting week. My Omnipod subscription is about to run out and I am getting an Ypsopump at the end of the week. I love Omnipod but, as it is completely unsubsidized/insured in Australia, my hip pocket dictates I need to move to something else. This means I will be moving from AndroidAPS to CamAPS and, in the intervening days, I am going to run AndroidAPS with MDI to see what that looks like.

I assume it means the looping engine will give me recommendations for injections, rather than automatically applying them.

I am going to miss AndroidAPS as it has been excellent. With my settings tuned, the loop was completely closed; I did not declare meals and yet I still maintained an HbA1c of 6.0% and a Time in Range of around 90%. I avoid overly carby food but I am far from a low carb regimen. A completely closed loop will not be possible with CamAPS but I do hear it is excellent.

Before I leave AndroidAPS though I thought I would document how I tuned my settings in case others were looking to do so and so, when I return to AndroidAPS, I will have this as a reminder of what I did.

Tuning So Far

In a couple of previous blogs, I talked about how I found things like my basal rate, and pump settings through finger pricking and CGM use. Here I use the full power of AndroidAPS and Nightscout to analyse my CGM data across multiple days for a much more accurate result. Before I launch into my method, I should explain what AndroidAPS and Nightscout are.

AndroidAPS is an open source looping system adapted from OpenAPS and made specifically for Android phones. I spoke about it previous here in my tech/CRM blog.

Nightscout is, effectively, an online website with your CGM data in it. I have been running it for years now and, if you are wanting more information on it and how to set it up, you can find it here. As well as showing CGM data, AndroidAPS can also push up data from AndroidAPS. For me it was a great way to have all of my data online so I could do things like access it via Zapier or Power Automate. In fact there is a lot you can do with the Nightscout data. I previously mentioned how I use it to generate reports for my endocrinologist. It turns out you can also use to to tune your pump settings via Autotune.

Autotune

The easiest way to access Autotune is via Mark Carrington’s online interface at https://autotuneweb.azurewebsites.net/.

Here we put in our Nightscout URL and tune the values of interest.

In my basal profile I have six values covering four hours each so I often run Autotune six times to cover each time period.

The result is a set of recommendations for the basal rate per hour, the value for the Insulin-Carb ratio and the Insulin Sensitivity Factor.

The problem with all of this is how it comes up with these recommendations is not clear so I prefer to compare it to my own conclusions before implementing.

Comparing the Recommendations to Observation

AndroidAPS allows you to display a lot of useful graphs which become meaningful once you start using the system,

The first graph here is the blood glucose level (yes, it had been quite an interesting 24 hours due to business travel, airport lounges, and all you can eat party pies). The second called “IOB COB” shows the Insulin on Board (IOB). In the case of AndroidAPS this considers basal and bolus insulin and can go negative. Negative IOB means the loop reduced insulin delivery due to a pending low for a sufficiently long time as to affect the usual blood insulin level for basal insulin. A sustained negative IOB can imply that the basal rates are set too high. In the above case the IOB is positive in all six time periods which suggests perhaps the rate is too low.

The second graph shows insulin sensitivity with the white line or, more accurately insulin resistance as a high value means more resistant. The green/yellow/red bars indicate deviations from the expected response of insulin to a carbohydrate intake. In the case of positive values in the deviation it means the insulin was not as effective as expected i.e. the ratio is incorrect.

Running the Comparison of the Graphs to AutoTune

I manage the comparison in Excel. I take values over three days and use Excel formula to compare.

If both my conclusion and Autotune agree with each other, I accept Autotune’s recommendation. Otherwise I leave the value alone.

In the above tables we see that, for this particular period, there was an adjustment made to a couple of time periods for my basal rate, a couple for my insulin sensitivity factor, and no change for my insulin-carbohydrate ratio.

Conclusions

The ability to tune my pump settings with Autotune’s analysis is really powerful and has given me something which is practically a closed loop system. However, as I do not know how it comes up with the recommendations, I prefer not to completely hand over control to the machine. To this end I do my own analysis and move slowly. The three day review removes outliers from any one day (such as crazy numbers from a business trip) and allows for trends to reveal themselves. Working in partnership with the machine has proven to be very powerful and I hope I can achieve similar outcomes with the commercial CamAPS.

ISPAD 2022: What We Know About Type 1 Diabetes May Be Upside Down

Last year, when I attended ATTD 2021, I wrote about Dr. Walter Pories and his observations in people with type 2 diabetes undergoing gastric bypass surgery. You can read that article here but, in short, obese people with type 2 diabetes, immediately after gastric bypass surgery, begin seeing significant improvements in insulin resistance/requirements. Literally in the days following surgery insulin requirement drops by a factor of 10 and, within a month, remission often occurs. Now the surgery does not remove the fat, visceral or otherwise, and yet there is such a dramatic improvement in insulin needs.

Dr. Pories concluded type 2 diabetes was not caused by “lifestyle” or visceral fat deposits but by a faulty gut which processed food poorly generating excess fat and little energy. The net result is increased weight, low energy levels, and overeating to compensate generating a vicious cycle. This subsequently strains the pancreas in certain individuals whose pancreas cannot keep up and we have type 2 diabetes.

Rather than being a disease of the lazy or a disease of the gluttonous, if Dr Pories is right, type 2 diabetes is a disease of the gut.

This month I was fortunate enough to attend ISPAD 2022 as a dedoc Voice and it turns out there is a controversy with type 1 diabetes which also challenges the cause.

Conventional Wisdom On The Cause Of Type 1 Diabetes.

The conventional thinking on the cause of type 1 diabetes begins with what we can observe and that is the immune system. Generally speaking, in people with type 1 diabetes, we see auto-antibody markers. In other words, the body’s immune system is attacking the pancreas and, specifically, the beta cells.

The idea often put forward is an “environmental factor” interacts with the body somehow, and the immune system responds to what it believes is a threat. As the immune system is a learning system, it remembers the threat and is prepared to attack it in the future. The theory is that the threat looks similar to the beta cells in the body and so the immune system begins attacking them, leading to depletion and type 1 diabetes.

That environmental factor might be a virus, or it could be gluten causing a “leaky gut”, exposing the immune system to food particles and confusing it. Professor Bart Roep is suggesting pinning it on the “environmental factor” is missing the mark.

What If The Beta Cells Were The Problem?

Professor Roep gave his talk in the first session of the first day and set quite the benchmark.

He is looking at how we are approaching cancer treatment and whether the lessons learned there can be used for the treatment of type 1 diabetes. Rather than seeing type 1 diabetes as caused by a confused immune system, he suggests it is caused by stressed beta cells.

To explain this he cited the late Gian Franco Bottazzo who promoted a radical idea; rather than the immune system causing indiscriminate destruction of beta cells (homicide), the beta cells are literally asking to be killed (as also happens with cancer cells) and the immune system is obliging.

Rebalancing The Immune System

When I was first diagnosed with type 1 diabetes, and told it was a problem of the immune system, my first thought was to turn to immune suppression drugs, as we do with organ transplants to prevent the immune system from attacking the new organ. So why do we not use immune suppressions drugs to slow the destruction of the pancreas? Because, in this case, the treatment is considered worse than the disease.

There are significant side effects from immune suppression drugs not the least of which is an increased risk of cancer. It turns out the body’s cells know they are cancerous or infected by a virus and literally put their hand up to be killed by the immune system. When we suppress the immune system this goes unchecked; infections and cancers are left unhindered and compromise the host.

On the other side of the coin, if we boost the immune system, this can trigger a disease very similar to type 1 diabetes.

The idea being that the immune system becomes much more sensitive to stressed cells and attacks cells with less discrimination. Great for cancer but not so great for beta cells.

Beta Cells Are Stressed

So why are beta cells the outlier in being attacked? Why does the immune system focus here and not on the entire body? It turns out beta cells are some of the hardest working cells in the human body producing literally a million copies of insulin every minute.

It therefore makes sense that it would not take a lot to tip a beta cell over the stress threshold and be targeted by the immune system.

Evidence That Stress Is The Problem

LADA forums frequently advise that to prolong the honeymoon (time when beta cells are still producing substantial amounts of insulin), you must reduce the stress on the beta cells. Often recommendations include dietary adjustments, such as eating low carbohydrate, supplements to reduce inflammation, and early-intervention insulin to reduce the requirement of the beta cells.

Even in the medical literature there is evidence (or, at least, consistency) that beta cell stress accelerates the destruction of beta cells. In “Latent Autoimmune Diabetes in Adults: A Review on Clinical Implications and Management”, a summary of findings from other studies included:

  • Insulin sensitizers plus insulin therapy preserve beta cells function better than insulin alone
  • Progression to insulin dependence was slower when insulin therapy was used compared to the use of sulfonylureas (a class of drugs which force beta cells to produce more insulin)

“Beta-Cell Preservation…Is Weight Loss the Answer?” presents evidence that weight loss can lower insulin resistance and preserve beta cell function.

All of the above findings are consistent with this stress model for Type 1 diabetes.

Similarly, this model does not exclude things like viruses as being involved, it simply recasts their role as stressors of the beta cells rather than antagonists of the immune system.

The Opportunity For New Treatments

Looking at cancer treatment breakthroughs and applying an inverse approach we get a novel set of approaches for curing/managing type 1 diabetes.

CAR T cells

In cancer, the immune cells (T cells) are reengineered to attack cancer cells. For type 1 diabetes, the reengineering would be with the cells that regulate the T cells (Regulatory T cells) to supress the immune response specifically for beta cell destruction.

Bionic: therapeutic Ab conjugated with toxin

In cancer, antibodies are engineered to carry a toxin so when they attack the cancer cell they deliver a toxic payload to wipe out the cancel cell. This same technique would be used but to deliver a growth factor to revitalise the beta cell.

Reduce hypo inflammatory tumor environment

Cancer cells actively reduce inflammation to limit the immune response. Treatments often seek to reverse this. In the case of type 1 diabetes, treatments would look to enhance the low inflammatory state.

DC vaccination (Dendreon)

In cancer, a company called Dendreon has a vaccine which selectively activates the immune system. For type 1 diabetes, we can selectively suppress the immune system through the use of vitamin D3.

In the case of this last approach Professor Roep’s team has tested it with excellent results; the general immune system was preserved but the immune component responsible for attacking the pancreas was suppressed.

Professor Roep also made the point that having a variety of treatments means they can be tailored to individuals, just as cancer drugs provide a set of tools in the toolkit of the oncologist with patients responding to different ones.

Conclusions

While I enjoyed the entirety of ISPAD 2022, this was, for me, the stand out presentation. Challenging the type 1 origin story, presenting a model which is consistent with a broad range of observations, and pioneering resulting therapies is, for me, what these conferences are all about and I look forward to seeing the progress of Professor Roep’s work at conferences in the future.

LADAs Can Loop Too!

A little over three months ago I started looping with AndroidAPS and I could not be happier; my Time in Range is 90% and my HbA1c has gone from 6.8% and climbing, down to 6.0%. In case other LADAs find themselves in a similar situation to me, with their pancreas slowly failing, and wondering if looping is for them, I thought I would document the journey and confirm it is completely safe. As usual there is the tl;dr at the end for those who want to jump ahead the last page in the book.

September 2021-June 2022: Moving to Insulin

From diagnosis back in 2017 until September 2021, my HbA1c had always been less than 6.0%. Then in September my bloods came back with 6.1%. Considering that it could be due to the error margin I waited until my next appointment six months later to see the results. Unfortunately, my HbA1c in March was 6.6%. It seemed my pancreas was finally on the way out. Given I had set the line as not going over an HbA1c of 7.0% if I could avoid it, it was time to move to insulin. Discussing my glucose data with my endo we agreed that night-time was the area for immediate improvement and I moved to injecting long acting insulin before bed.

Three months on my HbA1c was 6.8% so night-time insulin was not enough an it was time to become fully insulin dependent., which I did starting with Multiple Daily Injections (MDI).

June 2022-July 2022: Injecting is not for Everyone

It turns out MDI was not for me or, at least, it was a skill which I was struggling to master. Using a flash glucose monitor, it was clear my injecting was doing little to stop mealtime spikes and Sugar Surfing with small boluses along the way was very inconvenient when using a pen injector, what with the changing of needle every time. I now understand why some people with diabetes do not swap out their needles with every injection, as is recommended. While I was intending to finally loop, even if I just moved to a pump I could more easily handle the spikes through mini-boluses at the press of a button and tracking my insulin on board should also be simpler.

At the same time, Insulet began offering half-price deals on their Omnipod wearable pumps (in Australia, Omnipod is completely unsubsidized via the public system or through private health insurance so this was compelling). I knew Omnipod was loop compatible so I jumped on board.

Concerns with Looping

Going from needles to a pump can be a big change given it comes with a loss of direct control; a machine is now putting insulin in the body, not your hand. This means there also has to be complete trust in the device not to fail. While national bodies such as the FDA in the US, and the TGA here in Australia set strong standards to ensure safety, as a LADA I have an advantage because I am still producing some insulin (in fact, my fasting c-peptide was tested in July and still sits in the normal range). A complete pump failure, for example, is unlikely to result in DKA and a trip to the hospital for me.

The looping algorithm also needs to be trusted. In the case of AndroidAPS, the documentation clearly sets out the algorithms used. The original algorithm was oref0, followed later by oref1. They are explained in detail here. Anyone concerned about the safety of OpenAPS and its derivatives, such as AndroidAPS, should read this. As a novice pumper, even if I did not quite understand everything in the oref0 and oref1 documentation, it was crystal clear the algorithms had been designed with safety as the first priority. Combined with the multiple studies on the efficacy and safety of the OpenAPS system, I was confident, as long as I took things slowly, everything was going to be fine.

In fact, AndroidAPS forces you to take things slowly through the Objectives in the app. You are literally unable to activate features such as looping until you have completed the designated tasks and shown a level of proficiency with the application.

It should also be noted that, unlike some commercial systems, OpenAPS/AndroidAPS has no machine learning/AI component. The reason I mention this is AI systems effectively generate their own algorithm without transparency so it is impossible to know precisely why an AI system performs a specific action.

The final concern I had, unique to LADAs, was the fact that I am still producing some insulin. The OpenAPS system was, arguably, built for classic Type 1s as an artificial pancreas, not as a supplementary pancreas. Speaking with one of the great minds behind OpenAPS, Dana Lewis, via Twitter, I raised this concern. Her response was:

“It doesn’t assume anything about insulin production. It takes your input settings (basal rates, ISF, carb ratio, etc) and uses that to assess whether you appear to need more or less insulin based on BG, trend etc.”

Considering the Issue of Endogenous Insulin Production in the Context of Looping

Let us look at the settings for a typical pump which relate to insulin delivery:

  • Basal Rate (how much insulin to trickle into the body to keep the liver from flooding the blood with glucose, fatty acids, and ketones)
  • Insulin Sensitivity Factor (how strongly the body responds to insulin for lowering blood glucose levels)
  • Insulin/Carbohydrate Ratio (how much insulin is needed to offset a specific amount of carbohydrate)

Let us also assume a hypothetical situation similar to my own where the body can produce enough insulin to cover the basal requirements for most of the day with perhaps a little extra insulin available, if needed.

The basal rate will simply be the additional insulin needed throughout the day. For my hypothetical this means much less (if any) in the day and more at night. No problems here.

Similarly, the insulin sensitivity factor should be largely unaffected by endogenous production when blood levels are stable. If I pump in a unit of insulin, it should have the same effect on my blood glucose level regardless of what my pancreas is doing.

The final parameter though, the Insulin/Carbohydrate Ratio, is affected by endogenous production. We can see this in the situation where the person eats a low carb snack. If the snack is eaten during the day, the pancreas can likely cover the snack without the need for pump insulin but, if I tell the pump what I have eaten, no matter how small, it will recommend a bolus. I cannot set a daytime ratio of infinity i.e. no insulin required, because if I eat a meal which has too many carbs for my pancreas to handle I will need insulin. What is missing is an offset value. So rather than using the formula:

Insulin required = (Carbohydrates consumed) / (Insulin/Carb Ratio)

it might be

Insulin required = (Carbohydrates consumed) / (Insulin/Carb Ratio) – maximum amount of insulin the pancreas can deliver above the basal rate

Let us consider an example to demonstrate what I am saying. If I eat an apple (10g of net carbohydrates) and my ratio is 5 then, according to my pump’s bolus wizard I will need 2 units of insulin (10/5) but, if my body can produce that additional 2 units, the pump does not need to do anything. However, if I eat a meal with 60g of net carbohydrate, the requirement will be for 12 units of which the pump will need to give me 10 on top of the 2 my body can produce.

The formula goes from I = C / 5 to I = -2 + C / 5.

How This is Resolved in Looping

So is there a flaw in oref0 or oref1 which puts LADAs in harms way? It has taken me this blog article to realise it but the answer is “no” and Dana is completely right. While blindly declaring carbs to a pump and bolusing will be inaccurate for low carb snacks, this is not how OpenAPS and AndroidAPS work. The very short version is they only give you insulin when the carbohydrates are seen in the blood, not when you declare them. Therefore, in the case of the apple, the loop will do nothing because the blood glucose levels do not change because the pancreas does its job whereas it will kick in the extra 10 units for the meal because there is a reaction in the blood due to the pancreas not being able to keep up.

Based on this difference between blind bolusing and reactive looping, it could be argued that OpenAPS looping is actually safer than manual management because there is a hypo risk in blind bolusing when eating low carb snacks which looping removes.

tl;dr

If you are a LADA considering looping, I recommend it without hesitation. In the case of AndroidAPS, the system guides you at a pace which allows you to understand what is happening as you go and, even though you may still be producing some amount of insulin, the looping system will accommodate this unlike the bolus wizard calculators of most insulin pumps on the market. The OpenAPS system is transparent in its approach and well worth considering if you have the means.