Revised Humalog model in a closed loop

I have recently made some changes in my oref1-based AID/loop system which have dramatically improved the behaviour with Lyumjev. And it seemed those changes may also apply to Humalog, so it was time to test it out.

Insulin models

This is not about some fancy new algorithm, it’s just about optimising the insulin activity profile that the oref1 AID algorithm uses. I believe this is a fundamental tool which can lay a solid foundation for a stable loop.

The insulin models using in the oref systems have been characterised by two parameters: peak activity time and total duration. I have previously written that the parameters that work for me with NovoRapid and Fiasp are both using a 9-hour duration. The 75-minute peak of NovoRapid moved forward to 55 minutes for Fiasp. This seems logical when we consider that the underlying insulin is the same, with an accelerant to speed most of the absorption. I have settled on these times through experimentation and observation.

Here’s how those parameters affect the Insulin On Board calculation. The IOB curves throughout this article are using the exponential formula taken directly from the source code (as found in AndroidAPS) just with various duration/peak parameters.

In “the looping world” in general there’s reasonable consensus on the peak activity time of the insulins. But the duration has largely been “left as an exercise for the reader”. But it’s unfortunately very easy to just pick values we assume are correct when in fact they’re not. This does affect the loop’s “foundations” and thus the rest of our settings.

Terminology: “hybrid” vs “fully”-closed looping

Most people using an AID/loop system are using it as a “Hybrid Closed Loop”. They interact with it (mainly through boluses and sometimes separate food declarations) while it automates much of the background work.

Where I’m using an AID/loop in a mode where I don’t have to bolus or declare food I sometimes refer to this as “fully” closed. It’s probably more of a middle-ground between a “hybrid closed-loop” and “artificial pancreas”, and maybe “fully automatic” isn’t the perfect term. I still interact with the system to tell it about exercise for example. But for now I will continue referring to it with as simply “fully closed”.

Other insulins?

For almost 2 decades (up to 2019) I mainly used Humalog before switching to Fiasp, but since then I have learnt a lot more about the oref1 algorithm and insulin activity modelling. I did eventually find with Fiasp that 9 hours worked better than shorter times. But the best parameters for the other insulins was still a question.

In 2021 I switched back to Humalog for a while, and decided that a 7-hour duration worked well. When I tested NovoRapid for a few weeks I found that 9 hours definitely worked better than 7, and the correlation with Fiasp was obvious. So when I tried out Lyumjev it seemed likely that the duration would be the same as Humalog (again: the same underlying insulin). So I was using 7 hours for both Lyumjev and Humalog. And this seemed to work well.

9 hours for Lyumjev

But I have since used Lyumjev for a long time. In early 2022 I discovered that using a 9-hour duration worked even better. It avoided some of the subtle lows that had been annoyingly affecting my time-in-range statistics in my fully-auto looping. I have now settled on this as being a good setup for Lyumjev (9 hours with a 45-minute peak).

Here’s how that change pans out for Lyumjev:

It’s a very subtle change, but I have found it made a significant difference to the system. 5-6 hours after a meal (where the IOB generally peaks) I would sometimes drop below 3.9 into “hypo” territory. Not far below 3.9 and it would come up again, but when I kept that IOB-curve difference in mind when reviewing my Nightscout records, the association became clear. The tails of the earlier doses do add up over time, and the system had been underestimating the IOB when calculating what was needed with new doses. With this change my average Time Below Range has reduced significantly.

Just taking some 28-day examples here’s one using 7-hour duration from just before I changed:

And one for the 4 weeks after I had switched to a 9-hour duration with the same insulin:

The average BG (and thus eHbAc and GMI) is unchanged, but that change in time below 3.9 mmol/L (4.3% down to 2.6%) has been dramatic. Noticeable to me as the person living with the system, not just on paper! The decrease in the Coefficient of Variation has been gratifying too.

I am of course still looking to improve these further, but this simple change made a big difference. I did get tighter results back when I was carb-counting and bolusing for food, but this is a fully-automatic system without meal announcements being used.

Was I wrong?

But this raised questions about Humalog. Had I been wrong about the best parameters for it?

Had I mistakenly claimed that it was “better” than NovoRapid (by having a 7-hour duration instead of 9)? I certainly hadn’t tested it with the benefit of my current knowledge/experience for as long as Lyumjev. Here’s the updated IOB calculation for Humalog:

Because the peak of Humalog action is 30 minutes later than with Lyumjev, the change later on could be much more significant with Humalog!

Why didn’t I see this earlier?

A matter of circumstances I think. Where I had first identified that 9 hours was better than 7 was when I had been living with Fiasp for a long time. Here’s the IOB graph for those two configurations. Although the difference is much less than on the above Humalog graph, it was just enough for me to notice while I had been using the system in a fully-closed setup for long enough.

So I had been using 9 hours for Fiasp for many months, and when I went back and checked NovoRapid it was also good with 9 hours. When I re-tested Humalog for a short period I think the difference was probably there, but partly hidden by an assumption that this was an aspart-specific thing, and I wasn’t looking closely enough.

When I switched to Lyumjev (using 7 hours) it seemed good at first, but part of that would have been the improvements in initial speed. So I assumed that 7 hours was still OK for Humalog too. We can see on this Lyumjev graph (as shown earlier) the difference to 9 hours is a lot smaller, but eventually I have switched to 9 hours with Lyumjev. But that left the question of whether Humalog was better on 7 or 9 hours.

The Humalog IOB graph hints that the difference should have been be easier to notice with Humalog, but the combination of spending enough months living with a fully-closed loop with Fiasp and that “in between” difference in IOB ended up meaning that’s where I discovered it.

So in April 2022 I switched back to Humalog for a while, using a 9-hour duration. This is still in my “fully closed” setup, with no carb announcements and no manual bolusing. So hopefully it would soon show up any flaws in the modelling.

A new Humalog profile

In this context a “profile” contains the basal rates for the day along with ratios for insulin sensitivity (ISF or “correction”) and insulin-to-carb (CR or “carb ratio”). My profiles have for some time included 20 or so different basal blocks (in a vaguely circadian rhythm: lower at night and higher in the day). My ISF and CR are each a single number for the entire day.

I had a working profile for Lyumjev, and didn’t want to go back to my last Humalog profile. I’ve tweaked my profile in the intervening months with basal changes as well as correction/carb factors. But as I’ve mentioned in the past, I had a short-cut to calculating the new profile.

The basal rates were likely to remain the same. I have noticed a slight scaling difference in basal between the aspart insulins (both Fiasp and NovoRapid are the same) and the lispro insulins. But last time I switched between Humalog and Lyumjev the basal rates remained unchanged.

But the ISF and CR were going to have to change. To consider why, let’s have a look at the inverse of the IOB: the “Insulin Used”.

From a simplistic point of view, you can see that at the two-hour mark, more of the Lyumjev (75.5%) should have had effect than the Humalog (50.2%). So when we’re calculating how much insulin to give for a correction, we should tell it to give more Humalog up-front to get the same result after 2 hours. The system will of course be tracking the IOB and forecasting the BG curves for hours into the future, so we do have some safety built in regarding the extra insulin.

Why 2 hours? It started out as just an estimate, but it’s turned out to seem surprisingly significant. This calculation has worked for me when switching between different insulins in the past.

Scale both factors

My Insulin Sensitivity Factor (ISF) for the Lyumjev profile was 2.7 mmol/L (how much 1 U drops my BG). So I scaled that by 0.665 (50.2/75.5) and rounded off to 1.8 mmol/L.

The Carb Ratio (CR, or I:C) also needed to change, even though I haven’t been declaring carbs. It’s used to calculate the Carb Sensitivity which is used for tracking carb absorption and for UAM detection. Assuming my carb sensitivity was not changing, I simply had to scale the CR by the same amount. It went from 11.6 to 7.7 g in this case.

So there I had my new profile. I loaded up the pump with Humalog, activated the new profile, and set off. Of course I did this early in the day so I would be able to watch its behaviour. Also keeping in mind that things might be a bit “whiffy” until the 9 hours duration of the last Lyumjev dose had expired.

Dynamic ISF?

Note that I am using fairly regular oref1 (“SMB”) code.
I have not been using any of the current experimental dynamic-ISF code in this exercise.

9 hours seems to work very well for Humalog!

It turns out that new profile was spot on! I have experimented since with ISFs of 1.7 and 1.9, and neither seem right. One leaves me too high, and the other introduces a classic “BG/IOB wave” as the system slightly overdoses and then corrects. Of course Autosens does vary the sensitivity slightly over time, but with 1.8 it’s been oscillating around 100%.

Also note that this implies a tweak may be required when converting from a 7-hour Humalog profile to a 9-hour one. Look at the Humalog IOB graph earlier: the 7-hour model assumed that 52.7% of the insulin had been used after 2 hours (instead of 50.2%). That’s about a 5% relative change. But because we’re not actually making the insulin slower (just the model) an inverse change may be required. An ISF of up to 1.05x the original may be effective.

Earlier I referred to the insulin action profile (including duration) as one of the “foundations” of the loop. If we rebuild the foundations of a building we should expect to have to make some changes higher up in the structure. But hopefully the new building will be stronger.

Actual data

I have run it for just over a week of no-bolus, no-announce looping with Humalog, and I’m quite happy. Don’t get me wrong: Lyumjev is noticeably better at making faster corrections and keeping me closer to target, but Humalog is doing a decent job.

Here’s the summary of the last 7 days:

Comparing this with the earlier Lyumjev data:

  • CV has climbed from 22% to 26%. Not really surprising with a slower insulin.
  • The average BG has gone up fractionally.
  • The Time Below Range (TBR, below 3.9 mmol/L) has actually gone down to 2.0%.
  • The TIR for 3.9-7.8 has decreased. 90.3% to 85.1%.
  • But the TIR for 3.9-10 has only changed from 97.2% to 97.1% (85.1% + 12%)!
    Basically unchanged.
  • Impressively there’s only 0.9% spent above 10 mmol/L. The highest peak was 11.1.

But most of these are tiny changes, which could really have gone either way in this 7-day sample. The most significant differences I can see are the increase in CV and in the time spent above 7.8 mmol/L. Overall this seems to me like an excellent result regarding that change from Lyumjev to Humalog.

This period has as usual included some significant bike rides and walking, as well as eating some early Easter chocolate (because I could: I wasn’t treating a hypo) along with having normal meals, so it hasn’t been me just sitting around being quiescent.

I was doing all those things on Lyumjev too. In use it’s obvious that Humalog is not able to control the rises as promptly as Lyumjev, but the fact that it is still coping overall in a fully-auto loop is not something I really expected to see several years ago.

I would normally run the system for longer so I’m not trying to compare a 7-day sample with a 28-day sample. But I have an immediate personal constraint where I want to be back on Lyumjev for our Easter trip. I will be returning to Humalog for some other work soon (which will also include declaring carbs again, so that’s going to be interesting).

But in the meantime I feel I have at least shown that 9 hours is not a bad duration for Humalog (which also correlates with the use of 9 hours for Lyumjev).

Any change to overall insulin levels?

With the new ISF and CR causing stronger dosing for corrections and meals, you might suspect that the overall insulin use was going to go up. But not noticeably. My 7-day average TDD has gone from 34.4 U to 34.9 U. In the face of the normal daily variations of food and exercise, to me that counts as “unchanged”.

But while the TDD has not changed, the instantaneous insulin levels have.
When the system has been fighting post-meal “highs” (still usually below 10 mmol/L) the IOB has often climbed to above 8 U with Humalog. Compare this with Lyumjev where it’s been unusual for it to get above 3 U (and with tighter BG control). It doesn’t stay high for hours, but the peaks are noticeable.

Although the average overall level remains similar, this might have some implications for the concept of hyperinsulinaemia. This may be a subtle advantage of faster insulins.

Summary

To recap my current (new) favourite parameters for these four insulins:

Insulin Peak time (minutes) Duration (hours)
Lyumjev 45 (“Lyumjev” in AAPS) 9
Fiasp 55 (“Ultra-rapid” in AAPS)
NovoRapid 75 (“Rapid-acting” in AAPS)
Humalog

I expect that later this year I may be comparing NovoRapid and Humalog again just to be sure…

Note that although my selection of 9 hours has been through iterative experience, I can’t say that 10 hours wouldn’t be better. But I do think we’re starting to reach a point of limited returns, which is why I’ve stopped here for now.

Also do note that those numbers are for the exponential decay models used in the oref1 family of AID/loop systems. I am not suggesting 9 hours for use in other systems (especially ones that assume a linear decay).

7 thoughts on “Revised Humalog model in a closed loop”

  1. These numbers are incredible David! You are an inspiration to other diabetics for what is possible. Thanks for sharing.

  2. Thanks for sharing your findings. An inspiration for T1D’s to become more tech savvy. Am amazed you do not need to dose for meals. A great step forward for T1D’s.

    1. David Burren

      Nothing changes in the model. In fact I think a good model of the insulin action is ESSENTIAL if you are using algorithm changes which rely on it.

      I am currently experimenting with AutoISF which is very similar, and have not had to change the model.

      1. Randy Ludacer

        Have you come to any conclusions about AutoISF?

        I’m currently using Jon Björn Mårtensson’s bdb branch (of FreeAPS-X) which gives one the option of choosing between “Dynamic ISF” and “AutoISF.”

        And while I’ve gotten my settings working quite well in the “Dynamic ISF” mode, I’ve yet to finesse the settings for “AutoISF.”

        Perhaps, I should just embrace the “Dynamic ISF” mode and leave it at that…

        But the promise of AutoISF is very tempting: “AutoISF is meant for the advanced user who has a deep understanding of AAPS and who has tuned the system to achieve a TIR of about 90% or better. If such a user is ambitious and wants to improve further, the methods contained can very well help.”

        Of course, I cannot claim to have “a deep understanding of AAPS.” And while I have achieved “TIR of about 90% or better” I suspect that the settings I’ve “tuned” while in “Dynamic ISF” mode, may not be helping matters while in AutoISF mode.

        1. You’re talking about a different “AutoISF”.
          I’m talking about one of my own creation. In it there are no settings (other than the on/off switch, and my prototyping controls which I’ve been gradually removing) beyond what you would normally see with these systems. In fact it might eventually reduce the overall number of settings required. It’s intended as a platform to explore and test the “variable sensitivity” concepts.

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.