Reset G5 Transmitter

First, let me preface by saying that I adore, love, respect, and covet my Dexcom system.  It gives us a stability with type 1 diabetes that we would never be able to do without now.  But what I’m about to tell you is a bit of a hack on their system.

There’s been one thing I really have not enjoyed about moving from the G4 to the G5 system about four months ago.  The G4 transmitters were warrantied for 6 months, but usually the battery in those would go for a year…meaning we had the opportunity for much of the transmitter’s useful life to have a backup on the shelf at all times.  If the G4 transmitter failed for any reason, we could pick one off our shelf and not stress about how long it would take to get a new one.  Overseas travel and 2-week long diabetic summer camps were not a big deal…we could pack a backup.

Then we switched to the G5 system at the beginning of this year so that Anna didn’t have to carry a receiver while she did track team workouts.  This dramatically improved the likelihood that she would stay in good BG range during workout because our DIY loop system would have BGs available the entire workout to help her insulin needs.  If Anna had to carry a receiver during track workouts, that would’ve been the straw that broke the camel’s back in terms of diabetes gear she was willing to manage.

So, we’ve loved the G5.  It has worked well; not really having any problems with signal loss, BGs are accurate, we have enjoyed Clarity reports.  All good EXCEPT those G5 transmitters being shut-off by Dexcom  at 112 days.  At 90 days, you get a warning and your warranty is up.  At 112 days, your transmitter is artificially shut-off even though the batteries have some useful life left.  How much life?  Well, that depends, but for most users it is about a couple more months of life.

The problem with this system is that my insurance covers 2 transmitters in one order every 6 months.  So, for the first 90 days (3 months) after a transmitter order, I will nicely have a backup sitting on the shelf in case things go wrong.  BUT, for the next 3 months, I will have no backups on the shelf.  If that second transmitter dies early, I would have to wait for Dexcom to send us a new one.  If we were overseas or traveling, this could be very inconvenient.  I definitely won’t have one to send with Anna to her 2 weeks of summer camp based on how I can forecast our insurance refills already.

And here’s the really great news.  You can now reset the clock on that 112 day shut-off by building your own iPhone app.  This doesn’t buy you heaps of extra time…as the battery will only go for about 2 more months (maybe even less?) past 112 days…but that could be just enough time to start to be able to keep a backup transmitter on the shelf for longer between orders.

Another really good plus?  You can use this reset on G5 transmitters that have had their batteries replaced AND still use the Dexcom official app…you won’t have to try to use a different app (like Spike-App or X-drip+).

HOW TO BUILD RESET APP

What you will need:

  • iPhone (iOS 11.0 minimum)
  • (this may also work on iPod…but I haven’t tested it yet)
  • Apple computer (macOS 10.13.2 High Sierra minimum)
  • Xcode 9.3 (newer versions will work too…blogs are bad for “current” version references lol)
  • Apple ID email

Check to see if you need to update your macOS based on the version of iOS you have.  You can check your macOS by clicking the apple logo in your computer display’s upper left corner and selecting About this Mac.   If you are due for an update, click the Software Update button.

Download and install the app called Xcode from the App Store on your computer.  When the installation is finished, open Xcode by double-clicking on it from your Applications list.

Note: If this is the first time you are opening Xcode, you may get an initial message telling you that Xcode is installing command line tools.  Please let that run and complete the installation.  Command Line tools are a needed installation.

Go to the Xcode menu on the top of your screen, and click on Xcode and then Preferences...

Within Preferences, click on the Accounts tab and then the + button in the bottom left corner to add an account.  You are going to add an Apple ID type account.

Enter in your Apple ID email and password.  This process automatically makes a free Apple Developer account associated with your Apple ID email.  The account will show up in your Xcode preferences now with your name and (personal team) as a suffix in the name.  Once your account is added, close the Preferences screen by clicking on the red circle in the upper left corner.

Download the code for the ResetTransmitter app that we are going to build by clicking HERE

Open your downloads folder and navigate to the CGMBLEKit-master folder and then find the file CGMBLEKit.xcodeproj folder.  Double-click on that file and the project will open in Xcode automatically.

Click on the open button when the message appears asking:

“CGMBLEKit” is a project downloaded from the Internet. Are you sure you want to open it?

{Take the time now while the project opens to plug in your iPhone to the computer using your lightning cable.  Please accept any prompts about trusting your computer and unlock your phone so that it stays awake through the build process of the app that we are about to finish.}

Now click on the CGMBLEKit at the top of the left column, and then click on the small box as shown on the screenshot below to show the list of “Targets” below it.  Select the “ResetTransmitter” target.

Now, look at the screenshot above.  See that part highlighted in blue? You will need to change the loopkit part of the Bundle Identifier to a unique-to-you word.  Make sure that when you make the edit, you do not delete the period before and after.

Once you have the name edited, then go down to the Team section and select your (personal team) signing name from the drop down menu selection.  [Note: if you have a paid developer account, you can use that signing name instead.]

After you finish signing, a Provisional Profile will automatically be created and you’re close to done.

If you see a prompt under the status area below the Team about your device not being registered, please click on the Register Device button provided there to register the iPhone to your developer account (see screenshot below).

Now, navigate up to the top of your window and select two things; one from the left side of the box you’re going to select ResetTransmitter and from the pop-out, you’re going to select your phone’s name from the very top of the device list (not just your phone model…you want to go all the way to the top of the list for your phone’s name).


Stop and double check….most common mistake is forgetting to select ResetTransmitter as shown in the screenshot below and mentioned above.  Do not leave the selection on CGMBLEKit…if you do, your app will build properly nor will it appear on your phone.


If your phone/device name has (untrusted) after the name (see screenshot below), please open the phone and click on the Trust button that should appear on the main screen.  If the (untrusted) tag hasn’t disappeared after that, just unplug and replug the phone into the computer.  That should get rid of the (untrusted) tag.  If you try to build an app onto an “untrusted” device, you’ll get an error message reminding you to do the steps above.

When you’re done, the screen should look like the screenshot below; ResetTransmitter on the left, your phone’s name on the right, and no red error messages under the signing team area.  If your screen looks correct, then go ahead and press the build/play button.

Depending on if this is the first time you’ve built on Xcode, you may get prompts for codesign access and keychain access.  If those prompts appear, please enter your computer’s password and click on the always allow button to confirm.

Also, if this is your first time building with this developer account onto your iPhone, you may get another warning that the app could not launch because an issue with trust on your Developer Account on your phone.

Follow the directions on the warning.  Open your iPhone Settings >> General >> Device Management and then select your Developer App certificate and trust it.

Once you click the Trust on your iPhone, go back to Xcode, click on the blue OK button for the warning and then press the build/play button one more time.  This will finish the build of the app onto your phone.  Success!  You can unplug your phone from the computer and use the app now.

 

USING THE RESET APP

There is some warning messages in there about the use of this app.  When the app was first written, the code writers were uncertain how Dexcom Share and Clarity servers would treat information coming from a clock-reset transmitter (i.e., would data still be uploaded properly). The app has been in-use by many people now and the Share and Clarity services are, thankfully, not impacted by the reset transmitters.

You cannot reset a transmitter that is currently in a session and/or paired with Dexcom or Spike, or any other device/app.  So, stop any currently running sessions, and quit the dexcom app.   Forget the transmitter from your iPhone’s bluetooth list.  Forget all Dexcom transmitters from the list…no reason to keep old ones that you aren’t using anymore anyways. Re-open the ResetTransmitter app, enter your Transmitter ID and press the red Reset button.  Within 5 minutes you should get a pairing request.

If you do not get a pairing request and instead see a message “Unable to parse auth challenge: timeout” that means your transmitter is still busy with another app.  Double-click the iPhone’s home button and scroll through the open apps.  Upswipe on the Dexcom and the Reset apps to close them.  Restart the phone, re-open the Reset app, enter in the transmitter ID again and press the red Reset button again.  Within 5 min you should now see a pairing request.

If you STILL don’t see a pairing request, some users have reported that turning off Dexcom’s cell data within the iPhone Settings >> Dexcom G5 app can also help release the transmitter from Dexcom app’s influence.  If that fails…you can try deleting the Dexcom app and reinstalling it at the end of the reset process.

If you still don’t get a pairing request, make sure the transmitter is within pairing range of the iPhone (but not in active session).  The Reset app needs the transmitter close enough to be able to pair with it in order to reset the clock.

Once you press the pairing request, the reset command is immediately issued and you should get a confirmation screen like below:

You can now close the Reset app (double-click phone’s home button and upswipe Reset app) and forget the transmitter in the iPhone’s bt list again.  Reopen your Dexcom app and you’ll be able to use your transmitter for another 112 days or until the battery gives out…whichever comes first.

The free developer account that you signed the Reset app with only allows the app to be used for 7 days.  After 7 days, the app will simply produce a quick white screen and self-close if you try to open it.  You can rebuild the app anytime after the 7 days to use it again.  Simply double-click on the file in your CGMBLEKit folder download to open the project in Xcode again, plug in your iPhone, and press the build/play button.  All your previous changes will have been saved, so the rebuild is quite easy.

You can reset any amount of transmitters.  The app does not know transmitter ownership, nor does it have a limit on how many times you can use the app to reset transmitters.

The transmitter does not have to be on a sensor in order to be reset, just needs to have battery life left and not be paired already with another app.

Fine-Tuning settings

It is totally true that there is no one place to read How To Adjust Your Settings in any looping documents.  The reason being…the answers are basically the same as other non-looping situations…test basals, test carb ratios, test insulin sensitivities.  The difficulty is that once people are already looping, nobody wants to turn off their loop to go and test settings again.  Everyone just wants to adjust settings on the fly while also keeping a closed loop.  So…I’ll try to explain a little of both methods.

Before we start, let me say this in case it isn’t obvious…I’m not your medical professional, nor anyone else’s medical professional.  Don’t take my words as a substitution for conversations with your doctor.

Ok…that warning provided…Think Like a Pancreas is a great reference for understanding some of the guiding principles in pump therapy.  Let me summarize the important parts:

  • Basal rates should keep your BGs steady in the absence of other influences (such as food, medications, etc).
  • Boluses should return your BGs to target after a meal.
  • ISF should be the amount one unit of insulin drops your BGs without other influences.

If you are new to looping, I recommend planning for a time to retest/reset all your assumptions about your diabetes settings.  Keep an open mind if you want to keep a closed loop. (how’s that for a catch phrase?)

It is absolutely possible to have two wrong settings look like a right setting when they balance out.  The problem is that those wrong settings won’t balance out in all situations.  Example:  Too low of basals can be offset by regular eating of meals with too strong of a carb ratio.  If you stop eating though, you’ll start going high because that extra insulin from the meal boluses won’t be there to help the lack of basals.  Taking the time to validate your settings by truly testing them is really good practice.

1st: Insulin Duration

New loopers’ number one settings issue will likely be too short of a duration of insulin action (DIA).  Almost all of us have cut our DIA at about 3 hours on traditional pump therapy.  There’s a reason for that.  In traditional pump use, DIA is only used to calculate the remaining IOB at any given time after a bolus.  That’s it.  And when do we use remaining IOB in traditional pump therapy?  Usually when we want to give a correction because a BG is stuck high or going low…in other words, DIA is used as a rough approximation to correct off-target BGs.  It doesn’t have to be rocket science then…we’re making an approximation because some other numbers (carb count, basals, etc) weren’t behaving the way we were expecting either and therefore leading to an off-target BG.

But in looping, DIA (and its related IOB) plays a HUGE part in how the loop is anticipating and evaluating your BG movement.  IOB is used literally every single minute for every single loop calculation for where to go next in setting a temp basal or providing a bolus recommendation.

Not only that, but the STRENGTH of the insulin at any given time is also being used.  Closed-loops know and care about whether your insulin was given recently and is due to peak soon (like between 60-90 minutes with novolog/humalog), or if it is in the slow tail portion hours later where BG impacts are going to be way less dramatic.  So, DIA means a lot in your closed-looping world.

What will happen if you use too short of a DIA in closed-looping?  You’ll see it in a variety of ways, but too short a DIA will give the equivalent of insulin-stacking.  The loops will be assuming insulin is disappearing faster than it actually is.  If you are getting steady BGs while closed looping with a short DIA, it’s likely that your basals are being set too low to compensate.  If instead you have your basals correctly set and use a short DIA in closed-looping, you will likely find yourself going low from corrections.  One good indication of this is going lower than target carrying negative IOB from previous loop low/zero temp basals.

General recommendation:  Set your DIA to 5 or 6 hours for novolog/humalog, do not keep using your old, short DIA from traditional pump therapy days.  If you are using the newest versions of Loop or OpenAPS, the code is defaulted for 6 hours.  Test your basals (see below) with the new longer DIA and make sure that you can get steady BGs with the new basals.

2nd: Basals

Now that you have a reasonable DIA set, make sure to test your basals.  Personally, we find testing basals can be pretty painless and doesn’t require days of fasting.  Instead, we look for easy opportunities.  If you are willing to open-loop test, that is going to give the most accurate information in the quickest way.

It’s a pretty easy test.  Turn off your loop.  Don’t eat food, don’t do crazy exercise, don’t sit in a hot tub.  Just have a relaxing average time period and see if your basals are able to hold you roughly steady.  Doesn’t matter if you are at target or not…the idea is to simply have zero extra insulin on board from any boluses or corrections and watch what happens during those hours.  Typically we like to see about two hours of BGs without the influence of food boluses.

Believe me when I say that Anna is not enthusiastic about fasting basal testing…so I look for opportunities to make it less cumbersome.  For example, use a meal that I know like the back of my hand how to bolus for it and that generally needs no corrections.  For us…that’s two extra large scrambled eggs (or three small ones) with cheese bolused at 8g.  If she eats that meal, the BG response is slow and measured and by 3 hours after that meal…the bolus and food effects are really muted and we can start watching to see if BGs stay pretty steady for the next two hours.

For example, here’s some of a recent open-loop basal testing we did with Anna…confirmed that the BGs could stay pretty steady without the involvement of temp basal help from looping.  The 8g of eggs at the end of almost 3 hours…looks like she went a little lower (and may have deceased even more if she hadn’t started the next meal) than she had started.  Since basals appeared to be keeping her pretty steady, I made a mental note that carb ratio might be just a touch too strong, but didn’t adjust right away.  I waited to see how the next meal was going to behave.

basal-open-loop

If you absolutely don’t want to turn off your closed loop to test this…see if you can find a time where BGs are steady, you are at/close to target, and you are not carrying positive or negative IOB.  If you can’t find a time like that, chances are you may need to adjust settings.  Nighttime is usually the easiest to find that…but having well-set nighttime basals does not mean that daytime is also necessarily well-set.  That needs to be tested as well.

3rd: Insulin sensitivity factor

Insulin sensitivity factor (ISF) is the next logical setting to test.  If you’ve just done the basal test and gotten steady BGs with an open loop…try taking a glucose tab or two.  Wait for your BGs to be steady at the higher BG, and give a safe correction that you think will get you close to target.  Watch the resulting BG drop over the next 2-3 hours.  You should see BGs come to a steady level again.  How much did the BG drop?  How many units of insulin did you use?  Divide the two numbers and you will have your ISF.  If your BG dropped 15 mg/dl with half unit of insulin, your ISF is approximately 30 mg/dl/unit.

If your ISF is too weak (in other words the actual number is too low compared to reality of how strong the insulin is) in closed-looping, one of the most common symptoms you’ll see is a roller coaster of BGs where the temp basals are cycling between zero and high temping.  I’m going to borrow a couple of example graphs from Looped group.  These are examples where too weak of ISF is more than likely a large factor in the roller-coaster (doesn’t mean it is the only culprit, and is more difficult to ferret out when food is involved like the second graph).  But, lightning bolt high temp basals followed by very quick BG drops and zero temps is usually too weak of ISF…raise the ISF number to help looping know that each unit of insulin is actually doing more BG dropping.

19248027_10155510691426450_4212861104795372164_n

15591479_10154031400407115_2525671186696153617_o

Screen Shot 2017-10-28 at 12.20.02 PM

4th: Carb Ratios

Now that you have basals, ISF, and DIA all set-up…here’s where it gets really tempting to close loop and move on.  And, truthfully, it’s not that hard to test carb ratios on a closed loop vs an open loop if you’ve solidly tested all these other factors.

A good carb ratio will bring your BGs back to the starting point of the meal within about 3 hours or so.

A bad carb ratio will leave you higher or lower than the starting point of the meal.

For example, these are two examples of carb ratios being too strong.  In this first example, there’s 2.27 units of IOB and BGs are at 103 and headed down at a pretty good clip at about 2 hours after the meal.  If the next meal hadn’t been eaten then, low treatment certainly would’ve been needed.

carbratio1

This next graph also shows too aggressive of a carb ratio.  Three hours after the meal, there’s nearly 0.50 units IOB, BG is well below where the meal started, and definitely low treatments needed.

carbratio2

If you are finding that a correct carb ratio is yielding good BGs 3 hours later, but you aren’t happy with the peak BGs during the meal…then it may be time to explore increasing or adding prebolusing time to your meal or implementing “eating soon” targets an hour before meals to help control the post-meal BG spike.  Artificially strengthening carb ratios to help control post-meal BG spike will likely yield lows 2-3 hours after a meal.

But what about diabetes?

Of course, as soon as you test and dial-in all these things, diabetes will throw you a curve ball and change your insulin needs.  That’s the way it works.  It’s not just YDMV (your diabetes may vary), it’s actually YDWV (your diabetes will vary).  So how do you adjust settings without needing to open loop every time?  Short answer: it takes practice.

For us personally, hormones play the largest variable in settings.  If we estimate average basal rate of about 1 u/hr for Anna, hormones can make her range from 0.55 to 3 u/hr.  Illness or heat can make her ISF change from typical 35 to a range between 30-45.  We have gotten used to changing settings (basal rates mostly) to accommodate hormone fluctuations.  Illness and heat we tend to use shorter-term fixes like temp targets to help rather than changing settings.

One of the easiest tells we have that basals need to change is hanging out above/below target with positive/negative IOB.  Here’s one recent example.  During the day before this screenshot, Anna was busy with some stressful things at school…like being front and center during the school’s pep rally for Homecoming around noon to 2pm.  So, the unusual red spot on her graph didn’t immediately make me think anything was “wrong”.  Then she went to Homecoming dance that night, hung a little higher than target, but nothing too bad and she wasn’t looping during dance (her choice).  She came home around midnight, and at about 5am I noticed that she was hanging out steady at about 130s and carrying positive IOB.  Fingerstick showed she was at 195 (thanks Dexcom).  Gave a correction and started to wonder if may her basals were too low, because she shouldn’t have been that high under normal operations (but maybe homecoming dance was to blame?).  I didn’t make any changes to her settings at this point, but did start to watch for signs.

first

In the morning, Anna had a typical breakfast with some toast and fruit.  With fiasp, she hasn’t really been going above 150 (and usually not above 130)…so when she hit nearly 180 for the meal, I definitely started to think basals may indeed be low…but I waited to see how the meal would land.

second

As you can see above, about 2.5 hours after her meal of fairly quick carbs, she started to rise.  And she started to rise with about 0.75 units IOB.  This is odd for her.  Ideally, we wouldn’t be seeing sharp, steady rises with a good amount of IOB.  Additionally, this meal didn’t have protein or fat involved so I knew the rise wasn’t a late food contribution (even if Loop had some cob still on board).

So, once it looked like (1) the rise really wasn’t slowing down even like Loop thought it should, (2) she was climing with fiasp for nearly an hour of high temping with (3) positive IOB…then I finally decided to adjust basals.  I moved her basals from 0.85 to 1.2 u/hr.  Why that number?  A guess based on basal rates she tends to move between during her regular variations.  Trial and error have shown us that a rate slightly above 1 u/hour is usually needed sometimes.

third

One of the things I like to watch is the IOB pill when we make a basal change.  Ideally, I like to get the IOB back to a number that is roughly how much I think may help get a correction going again.  So, changing the basals from 0.85 to 1.2, Loop recalculated IOB from 0.52 to -0.48.  Which was roughly in line with what I’d expect…Anna was about 27 mg/dl over her 95 mg/dl target with an ISF of 55…meaning she’d need about 0.49 units to correct to target.  Perfect…seemed like a reasonable amount of movement for basals then.  Loop started running a high temp and I wait to see how things look in about 2 hours.

fourth

About 1.5 hours later, Anna wasn’t quite coming down as fast as I would’ve expected. She was still holding 0.57 IOB and at same BG as she was 80 minutes before.  So…I waited a bit and adjusted again to 1.4 u/hour.  Again, just a guess, but nearly two hours after that adjustment we are sitting just about at target and just about even IOB.  I’ll probably split the baby and use 1.3 u/hr going forward.

So…that’s how I look for and make tweaks to my settings while closed looping.  The basis is knowing what “good” times look like and how foods normally behave.  Open-loop testing really helps with that.  Then, when you find yourself with some of the telltale signs (food going differently than expected, BGs holding steady but not at target, moving up/down without IOB helping, etc) over an extended period of time, you can make small adjustments and watch for the resulting behaviors.  I don’t adjust based on just one meal or one period of above-target BGs.  There’s too often another reason (stress, sensor issues, etc) that could explain a short term high/low BG pattern…but if I notice the trend continuing for a period of time/several meals, I adjust.  Shorter term issues from stress or exercise we deal with using temp targets or just have a little more patience and wait for them to come down when the issue has passed.

Exponential Insulin Curves + Fiasp

One of the new updates that came to both sides (OpenAPS and Loop) quite recently are Exponential Insulin Curves.  I’ll spare you all the detailed history of development and discussion, but there’s several threads of discussion on GitHub regarding the new curve developments like the PR here in OpenAPS, the issue here in OpenAPS, and the issue here in Loop if you want to read up.  What you’ll notice is that there was a lot more cross-communication between the different DIY groups than usually happens…so this particular feature happens to be where OpenAPS and Loop have the greatest degree of similarity right now.  And something must have spurred this sudden cross-system work, right?  Yes…and that something is Fiasp.  The new “faster” insulin.

What’s so special about Fiasp?

Fiasp is like Novolog, except it has an additive that “speeds up” the insulin effect.  To quote from the official paperwork:

Fiasp is a mealtime insulin aspart formulation in which the addition of nicotinamide (vitamin B3) results in a faster initial absorption of insulin compared to NovoRapid.

The onset of action was 5 minutes earlier and time to maximum glucose infusion rate was 11 minutes earlier with Fiasp than with NovoRapid. The maximum glucose-lowering effect of Fiasp occurred between 1 and 3 hours after injection. The glucose–lowering effect during the first 30 minutes (AUCGIR, 0–30 min ) was 51 mg/kg with Fiasp and 29 mg/kg with NovoRapid (Fiasp/NovoRapid ratio: 1.74 [1.47;2.10]95% CI). The total glucose–lowering effect and maximum (GIRmax) glucose–lowering effect were comparable between Fiasp and NovoRapid. Total and maximum glucose–lowering effect of Fiasp increase linearly with increasing dose within the therapeutic dose range.

What is the most important take away for most of us?  Less need for prebolusing in order to control post-prandial spikes in BG.  Translation for Anna…she doesn’t have to wait nearly as long to eat that donut.  So you can see the appeal of the product if it works as they advertise…a 2-minute prebolus or even post-meal bolus?!

Why can’t Fiasp work with the old curves?

As a gross simplification, the insulin curves are made by “drawing” a smooth line through a bunch of individual, discrete data points collected from all the users in insulin study groups.  Mathematician’s version of art could be envisioned as HOW they connect all those data points, because there are many different methods (such as straight-line, bilinear or exponential) they can use, each with pros and cons.  Typically, mathematicians try to pick the method that provides the “best fit” to the data points.  In picking that method they may need to ask themselves…what are the important areas of the dataset?  Do they want those areas to match up best?  This wiki page offers a great overview of the concept of curve fitting.

The old insulin curves (bilinear curve for OpenAPS, Walsh curve for Loop) didn’t fit Fiasp data well.  Our looping community needed a new piece of art (aka curve)…and ideally the new curves could also be slightly individualized for YDMV (your diabetes may vary) and still work for the rapid insulins such as novolog and homolog.

What are the Exponential Insulin Curves?

The new way that the looping systems model insulin impacts in their system is through exponential insulin curves.  The exponential insulin curves have two user-adjustable inputs; peak time (PT) and insulin action duration (DIA).

For Loop, there is one legacy insulin curve (Walsh) and three new exponential curves to choose from when you configure your Loop app.  The first 3 listed below are for rapid-acting insulins (novolog/humalog) and the last one is for Fiasp. (Note: the Loop docs contain the instructions for individualizing the exponential curves’ DIA and PT settings.)

  • Walsh – default DIA =360 min, PT not user-configurable
  • Rapid-acting adult – default DIA = 360 min, PT = 75 min
  • Rapid-acting child – default DIA = 360 min, PT = 65 min
  • Fiasp – default DIA = 360 min, PT = 55 min

For OpenAPS (currently in dev branch, as of this blog date), there are three curves; the legacy curve, and two new exponential curves (one for novolog/humalog and one for fiasp).  The peak times for rapid-acting and ultra-rapid can be set in the preferences, DIA is set in the pump (and must be at least 5 hours for the exponential curves).

  • Bilinear – old OpenAPS curve
  • Rapid-acting – default DIA = 300 min, PT = 75 min
  • Ultra-rapid -default DIA = 300 min, PT = 55 min

For fun, here’s what the math looks like inside the Loop code:

Parameters: td = duration, Ia(td)=0, IOB(td)=0, tp = peak activity time, both expressed in minutes.
Time constant of exp decay: tau = tp*(1-tp/td)/(1-2*tp/td)
Rise time factor: a = 2*tau/td
Auxiliary scale factor: S = 1/(1-a+(1+a)*exp(-td/tau))
Insulin activity curve: Ia(t) = (S/tau^2)*t*(1-t/td)*exp(-t/tau)
IOB curve: IOB(t) = 1-S*(1-a)*((t^2/(tau*td*(1-a)) - t/tau - 1)*exp(-t/tau)+1)

And the math inside the OpenAPS code is pretty similar, too.

IF you take that math and boil it down into pictures (because don’t most of us like pictures better?), you get curves kind of like these based on what DIA and what PT you select (thanks Sulka Haro):

28734122-0efb3e0e-73e8-11e7-9ffd-05dfffcc6ff5

Looking at the chart above, you can see the grey and blue lines would roughly represent Fiasp, while the orange and yellow lines would represent slower Novolog.

So this default curve will work for me, right?

Most of us are so excited when something new is released for our loop, and we think it will be as simple as just turning on the new feature and looping gets even easier.  The developers do a great job of reminding us YDMV, test these features for yourself…but somehow we all get so darned excited we forget that warning soon after we enable the new feature.

The new insulin curves are no different.  There are a lot of assumptions that go into these curves, not the least of which is that they represent a consolidation of data from THOUSANDS of insulin users in study groups.  They are not derived from data gathered from YOU in a study group.

My personal understanding of insulin curves has grown a lot since beginning to loop, and it still has a long ways to go.  When I started, I’d swear on a stack of bibles that our insulin duration was 3 hours.  Then, after looping for a bit, I’d sheepishly admitted that 5 hours was indeed actually a smoother ride once my settings adjusted.  Finally, I even moved it out to 5.5 and 6 hours and still had a smooth ride (the difference between the two durations was not enough for me to readily notice in my data).  I would say that if there’s one bit of consensus in the looping community development group, it is that your DIA should not be less than 5 hours.  If you aren’t at 5 hours DIA yet, you should take the time to fine-tune your settings.  If you are using less than 5 hours DIA, you are probably relying on a loop-induced insulin stacking to make up for basals that are too low.  (Ahem, looking at you 670G users who are using 2 hour DIA in order to trick those loops into providing more aggressive BG control…but alas, that’s the only variable they have to control their loop.  Lucky us, Loop and OpenAPS give us options.)

But, since Anna started on Fiasp October 11th, my whole head exploded and I had to rethink my insulin curves all over again.  In fact, if you read those discussion threads linked at the beginning of this post…people have been having success at lots of different settings while trying fiasp (2 hours, 5 hours, 7 hours DIA and various peak times as well).  How could the same person be having “success” at such varied settings?  The answer is multi-faceted.

What are the impacts of DIA and PT?

This is a great set of graphics (thanks Dragan Maksimovic) illustrating the effects on the curves at varying settings.  This first set is the insulin activity where you are only varying the PT, and keeping the same DIA.  Notice, as the peak time increases, more of the insulin’s strength to bring down insulin is used up earlier.  You’d expect to see BGs drop sooner with a quicker PT and slow up more as the insulin wears off.

28603367-d54aed1c-7180-11e7-800e-f43c0ca17042

This next set of curves shows what happens when you keep the same PT, but vary the DIA.  If the peak time is the same, the shorter the DIA then the stronger the insulin will impact the user at the same time post-prandial.

28603372-dc754042-7180-11e7-93de-190fcd4536fe

Keep these curves in mind, as they may provide good reference in later discussions about fine-tuning your insulin settings.

Actually, this is probably a good place to end this post.  We can carry over the discussion about Fiasp and insulin curves to the next post, where I’ll share how the first 6 days of Fiasp led me to actually stop looping, go full manual mode for 2 days to recalibrate all my settings and search deeper about where my problems with Fiasp and looping were coming from.  Don’t worry…so far it has a happy ending.

Why DIA matters

DIA: Duration of Insulin Action

At our first endocrinologist appointment, I distinctly remember the doctor telling us that rapid acting insulins (like humalog and novolog) had insulin durations of about 5 hours.  I remember looking at the insulin curves…and I remember that the curves were distinctly skewed to the left.  Meaning, most of the insulin “action” seemed to be in the first few hours and it peaked around 90 minutes.  I also remember them saying to wait until about 2 hours had passed since the last insulin dose before considering a corrective dose of insulin…to give that insulin its due time to work.  Based on that information, I had concluded that the “tail” of the insulin duration (from hours 3-5) contributed relatively little to the insulin experience.  After all, looking at curves like the one below, it would pretty easy to say that the effect of insulin seems pretty darned small between hours 3-5 compared to hours 0-3.

insulins1

Back when we were on omnipod, we used a 2 hour DIA.  Basically, we picked that setting because it seemed like after about 2 hours we noticed that insulin seemed to wear off…corrections from high BGs slowed way down after 2 hours, or our BG control of food seemed to falter for big meals around 2 hours and we’d need to give more.  We had pretty great control with 2 hours of DIA.

Our omnipod system basically only used the DIA to calculate the insulin remaining after it had been given…the insulin-on-board (IOB).  So, if BGs were coming down too quickly (have you seen what happens to kids’ BGs on trampolines?), we would look at the IOB and eat an appropriate amount of carbs to try to offset the remaining IOB.

I always knew my estimate of DIA was probably a little off.  I knew I was ignoring that little bit of insulin effect from hours 3-5.  Especially because when we had large carb meals…the system would tell me that her insulin had gone to zero, but Anna would still be dropping.  On large carb meals, those “little bits of tail” between hours 3-5 added up to a significant amount because our boluses were proportionately bigger.  The “noise” of everyday diabetes variations were less apt to hide the 3-5 hour insulin on those big meals.  But most of the time 2 hours seemed to work “about right”…so we stuck to it.

Since we’ve started to manage diabetes with closed loop systems (OpenAPS and Loop), the effect of DIA (and especially that late insulin effect tail) has become more apparent and important.  So, I thought it would be good to discuss just how DIA can impact closed loop operations.

I like to visualize carbs and insulin as opposite effects on BGs; one upward and one downward.  I have several visuals that I typically imagine…my favorite two are crowd surfers at concerts and wet paper towels holding coins.

Imagine carbs are the hands below.  Imagine insulin is the weight of the crowd surfer.  If you had a bunch of weak little kids trying to hold up The Rock (an all fat/protein meal bolused upfront entirely)…BGs would get crushed low.  If you had a tiny little baby being held up by rambunctious steroid-filled weight lifters (underbolused slurpee)…that BG might go sailing high.

crowd-surfer

Or how about the wet paper towel is a meal and the coins are insulin dosing. Can you put too many coins suddenly on that wet paper towel such that it can’t support the weight of the coins?  Yup…low BG.  Give that towel time to dry out, get strong (carbs absorb)…then it would be able to support those coins later.

maxresdefault

With those comparisons in mind, we can look at the geeky explanation a bit more.  Simply put, carbs make your BGs go up.  Loop used to predict the “shape” that carbs would absorb as a static value much like shown below.  You’d tell Loop the time for carb absorption, and the model said it would peak halfway through….BG impacts would look much like my hand-drawn sketch below.  (Please keep in mind these are conceptual drawings…not to any scale exactly.)

dia 1

And insulin makes your BGs go down…

dia 2

If you add the up and down effects together…you hope to get a fairly even final BG curve.  We’re all aware of the difficulty in lining all of this up to achieve that…some foods absorb faster than insulin kicks in (so we try to prebolus to help that), some foods absorb so slow that insulin wears off before the food is done (so we do extended boluses to help that).  If the stars aligned, you may get a fairly good match between the downs and ups…to get a fairly flat BG result.

dia 3

If we take a closer look at those downward forces, the insulin effect, we can conceptualize that as an “area under the curve”.  All that drawing is a bunch of little tiny insulin effects added up together.  If that was one unit of insulin with an ISF= 30 and a DIA of 4 hours…you’d expect your BG to drop 30mg/dl over the entire 4 hours (assuming your basals are correct).

dia 4

But, what would happen if you considered DIA of 2 hours?  Like I’d been doing with my omnipod?  Well, all that insulin action (aka “area under the curve”) still needs to be there, so the shape of the curve changes as a result.  Like moving play-doh into a new shape.  Since the length is cut in half, the height of that curve will necessarily get longer.  The curve become more pointy, less like a upside-down bell and more like an upside-down mountain.

dia 5

In effect, BGs will still drop 30 mg/dl in both situations based on the “math” but the BGs will drop MUCH faster and stronger with the shorter DIA.

dia 6

The shape of the curves didn’t make much of a difference to us when we were using omnipod because we typically only were using the omnipod’s DIA setting much later after the bolus had been given…way down near the post-2 hours, post-3 hours after a bolus had been given when the two different curves might start to look more similar again.  We were checking IOB at times well after a meal had been bolused.

Additionally, we weren’t using DIA to calculate boluses ahead of time…all the boluses were based strictly off carb ratios and MY ABILITY to guess whether Anna would go low if I gave all the carb ratio based bolus upfront.    Quick carbs…I gave all the insulin up front.  Slow carbs…ummm, let me think about how much to give now and how much to extend and for how long.  Anyone have a calculator?  My omnipod PDM never suggested  proactively “Hey Katie, if Anna is eating pizza, you may want to give that 10 units broken up as 6 units now and 4 units extended over the next 2 hours or else she’ll be low in an hour.”  Wouldn’t that have been nice?! (hint: that’s what Loop is able to do now!!!)

So why is DIA different with Loop?  Well, it matters a whole bunch now because Loop is calculating what your curve will look like as soon as you enter carbs and a carb absorption time before you bolus.  If your upward effects (carbs) are not able to keep up with the downward effects (insulin), Loop is going worry about you going below your target BG.  It wants you safe.  If you have a short DIA, the chances increase that your Loop will think that the insulin will overpower the carbs early in a meal and you’ll have a low sag in BGs before carbs can catch up. (because hey…all that orange “area under the curve” has been crunched up into the front part!)

dia 7

So, when Loop does its number crunching and sees that low BG sag…Loop’s checking whether that low is “low enough” to take you below your target BG.  If that low is low enough, Loop will shave off some of your recommended bolus upfront from meal.  How much?  JUST ENOUGH to keep your predicted BG from going below your target anytime after you bolus.

dia 8

If you’re starting the meal near your target BG, you’re likely to see a prediction line something like the graph below after you use the recommended bolus from Loop.  And you will scratch your head and say “WHAT THE HECK IS GOING ON?”  Why would Loop SHOW that you’re going to be going high just after giving a meal bolus and not suggest more?  (some people may even take matters into their own hands and say “hey, it shorted me on a bolus…it should’ve been offering 6 units and only  recommended 4 units!”  And you’ll shortly find that if you manually change it to deliver 6 units, you’ll find Loop suspending you quickly afterwards)

BUT, take a pause and think about the situation.  What you aren’t seeing is that Loop is offering that amount of bolus to keep you from going low early…before carbs can catch up.  Based on the meal specs (carbs and carb absorption time) you entered and the DIA you are using, Loop is helping you know that an extended bolus is a good idea!  Don’t worry, Loop still knows about the upward carbs…it hasn’t forgotten about them at all.  In fact, it is literally SHOWING you that it has not forgotten about those carbs that still need insulin.  Loop will make up the remaining bolus needed through high temp basals as soon as the predicted BGs aren’t showing you’ll go below target.

dia 9

Isn’t that awesome?!  In the pre-Loop days, you’d have to recognize the meal needed an extended/dual wave bolus, do some guessing and memory games, watch the CGM to help decide when it was safe to give more insulin.  Now with Loop, you tell it “hey this is a kind of long slow meal” and it does the work of helping you extend the bolus.

The problem comes if you are using too short of a DIA…you’ll regularly get boluses that are lower than you’d expect (or likely want) because Loop is predicting a significant downward insulin effect early in the meal.  Going back to the simple models, you are telling Loop that you have a wet paper towel (slow carb meal with weak upward support) but want to drop a huge stack of coins immediately.  Loop is telling you to “hey, don’t drop an huge stack of coins on that wet paper towel right away…drop a few coins, wait for the towel to dry out a bit and you’ll be able to add more later safely.”

All of this was to demonstrate the not-so-trivial weight that DIA has in your Looping.  If you set that DIA too short, you’re not just going to see it in IOB calculations, you’re also going to be having boluses and predicted BG curves that aren’t realistic.  Looping in those situations will be less than optimal and you’ll likely feel frustrated.  Out of all the variables that are YDMV (your diabetes may vary) such as basal rates, ISF, and carb ratios…DIA is the LEAST person-specific variable and most likely to be uniform across the population.  DIA is more dependent on the type of insulin being used rather than the person using it.

So I encourage you to set your DIA realistic for the insulin type you are using, and check if your other YDMV variables might need tweaking as a result of changing your DIA.  The work you put into getting those variables more realistic will be rewarded with a much easier bolusing experience.

We’ve regularly been using this “fake extended bolus” technique on Loop now for several weeks and it has been nothing short of remarkable.  The new dynamic carbs model is better able to adjust the insulin delivery (downward pressure) to match observed carb absorption (upward pressure) rather than leaving the upward pressure as a fixed curve.  We have had nearly half a dozen meals over 120g carbs each (donuts, Chinese food, spaghetti) and given single boluses upfront.  Just a single bolus.  I did not calculate or guess how much of the 120g I should bolus for vs try to split bolus for later.  I just told Loop that it was a long meal, took the recommended bolus, and then we walked away to let Loop handle the remaining decisions.  The results have been great.  Very large carb meals peaking between 150-180 mg/dl, no lows, and smooth landings.  Something that used to take a lot of effort and attention has been reduced to a reliable, less stress interaction.

On the left, donuts…large maple bar, large chocolate bar.  Single bolus, Loop calculated…high of about 125mg/dl using a carb absorption time of 2 hours.  On the right, big bowl of spaghetti using carb absorption time of 4 hours.  High of 173 mg/dl, single bolus given, Loop calculated…let Loop do the rest.

meals

For meals that are quicker absorption (where DIA is not an issue because the carbs come in fast enough), Loop functions just like it did before…the full bolus is given upfront and Loop picks up the slop around the messy edges of real life.  But for these big, long meals…if you get your DIA well set, the experience can be one of the most significant reliefs to your t1d burden in a long time.


A few side notes:

  • To fully take advantage of the “fake extended bolus” technique, I did have to increase our max basal rate so that the extended bolus could be delivered in a reasonable time to help control BG spikes later in meal.  It took me some time to feel comfortable raising the max basal rate, since the previous carb absorption model was not forgiving at all…we’d kept the max basal rate fairly restricted to prevent unwanted high temping for quickly rising BGs after a meal.  Our previous max basal rate was 3 u/hr, and now it is 10 u/hr.  Anna’s regular basal rate on average is about 1 u/hr.
  • OpenAPS also uses DIA in calculating your predicted BG curves.  So, while the discussion above is mostly Loop specific, there are many parts that apply to OpenAPS as well.  If you are frustrated and wondering “why is my rig suspending basals so much?”, check if OpenAPS is predicting low BGs before your meal would be done…and ask yourself is it possible that the low BG prediction is due to a DIA set too low for the carb absorption being observed?
  • If you prebolus, make sure you forward-timestamp the carbs when you enter them in the Loop.  That helps Loop better line up the upward and downward curve peaks…and therefore you’ll get a better bolus recommendation upfront.
  • Loop’s Dynamic Carb Absorption model takes your entered carb absorption time and multiplies it by 1.5x as a starting point for its model.  This helps Loop be able to anticipate later carbs (past DIA) but not bolus for them upfront where a low would be more likely otherwise.  This multiplier has been working well for us.  Loop’s dynamic absorption has been able to adjust on-the-fly to situations where the carb absorption was not like we originally anticipated (because hey…that’s life with diabetes).
  • When we started on DCA, we were using 4 hours DIA.  We moved up to 4.5 hours and now are finally pretty pleased at 5 hours.  Our landings from the peak of a meal are more predictably coming in at target at 5 hours vs 4.
  • We still have a growing, hormonal teenager.  We still have to adjust basals regularly during the month.  Our good experiences on Loop still require us to be aware that diabetes presents ever-moving YDMV variables that we need to tweak.  But, it’s easier to be less emotional about that work when the meal bolusing has been made suddenly easier.  Diabetes feels a little lighter on our shoulders.

 

Think Like a Pancreas

Secret handshakes for special groups.  Decoder rings to translate hidden messages.  Star-bellies and not-star-bellies (for the Dr. Suess fans).  I felt like I’d finally been given the membership to the special club when I’d read Think Like A Pancreas.  Suddenly, the burden of type 1 diabetes management felt ever so much lighter.  Not quite as feel-good as Julie Andrews singing on top of a Swiss mountain, but pretty damn close.

happy day

The book lays out how to figure out insulin needs.  Basals and boluses.  Pumps and multiple daily injections.  It has all the information.

I’m an engineer by training, and a numbers geek by birth.  I have always felt comfortable with math and this book broke diabetes down into numbers.  It finally allowed me to look at all those numbers I was collecting in the log books and make sense of them FOR MYSELF.  I didn’t have to call the endo to have her do it for me…I could participate in the management and likely do it better because I simply had more hour-to-hour information than the endo had about what was going into those numbers (exercise, stress, sleep, etc).

The first take-away from the book was basals.  That a correct basal should hold you steady throughout the day.  This hadn’t been really well explained by any of the medical professionals we’d talked with.  All we’d been told is that basals were involved in your keeping your waking number steady, but it’s actually a far more complex system than that.    The book discusses the value of doing a good basal testing program periodically to test whether your basal is holding you steady.  If you’re seeing drifts in blood sugar trends up or down in the absence of food or rapid insulin, that basal might need adjusting.  The book helps define an overnight target of <30 mg/dL change from bedtime to wake.  If you’re dropping or raising more than 30 mg/dL, it might be time for a change in basal doses.

The second take-away from the book was insulin action time.  The doctors had explained that Anna’s rapid insulin (humalog, at the time) would last 4 hours in her body, with a peak action time at about 1 hour after injection.  In other words, her blood sugar would still potentially be dropping up to 4 hours after she bolused for food.  Most online sources from diabetes websites to drug manufacturer’s quote an action time of about 4-6 hours, like this one from Diabetesnet.com

insulin action time

This book gave me the knowledge that in practice, insulin action time varies from person to person.  When we tested Anna’s insulin action time, it actually showed that rapid insulin only lasts 2 hours in her system.  What a difference!  This meant we understood a little better what mechanisms were at play (or not at play) when we were looking at how her blood sugars were behaving more than 2 hours after a meal.  If we saw rising blood sugars more than 2 hours after a meal or correction, we started to know that maybe her basals weren’t enough (and the opposite for falling blood sugars).

The third take-away from the book was about insulin correction factor.  We learned how to test, in the absence of food and exercise, how much one unit of insulin would drop her blood sugar.  We did the experiment several times and came up with a consistent result.  One unit dropped Anna’s blood sugar by 30 mg/dL, not 50 mg/dL like the doctors had been giving us to work with.

Armed with this new knowledge, I started to fine-tune Anna’s basal and bolus numbers based on the daily numbers we’d been collecting.  I made little tweaks to the dosing, timing, and started to try to predict what number she’d be two hours after a meal.  When she wasn’t near that prediction, I’d look for possible reasons why…exercise, faulty carb counting…and I’d keep notes to help me see if I could find patterns.  After just over a week or so, I’d figured out that Anna needed 12 units of lantus, a carb ratio of 1:8, and a correction factor of 1:30.  We stopped calling our numbers into the doctor and were making adjustments as needed.  Ourselves.  It felt great to finally see some insight into the numbers.

The numbers showed the progress (average blood sugar and the standard deviation):

Week 1: 230 mg/dL ± 75 (hospital and home)

Week 2: 160 mg/dL ± 54 (with endo adjustments)

Week 3: 144 mg/dL ± 49 (Think Like a Pancreas)

Week 4: 144 mg/dL ± 41

Week 5: 120 mg/dL ± 33

But wait until you see what happens in week 6!!  The CGM arrives!