Loop - my new build of FreeAPS - my mods and some questions

I’m on FreeAPS.

Well I could do that. But I could also do that with the normal PDM.

I’d rather not reduce my insulin unless I need to do that to prevent a low.

My ideal scenario is simply that it cuts insulin if I’m low. But that it won’t CAUSE a low or high. Reducing my insulin to prevent a low might end up causing a high. And I could do that without Loop.

So what about my idea of setting a big target, like 70-300. Wouldn’t that keep my basal exactly as scheduled unless I go below 70?

Yes, I know that wouldn’t prevent highs, it would be the same as the normal PDM - except it would prevent lows, right?

2 Likes

300 as an upper limit may not be enough. Sometimes Liam’s loop predicts 400 or higher after meals. I suppose you are only referring to 300 as an upper limit in a fasting state? If so that may work unless your bgs actually hit (or project to hit) 300 then you’d start getting the micro boluses again.

And whether loop projects whether or not you will hit that number depends on your loop settings.

2 Likes

Yes, it should as long as you stay between 70-300.

3 Likes

Or “projected” too stay.

4 Likes

I am not sure what my “projections” look like, I’ve only looked at them a few times. I don’t pay attention to that. But I very rarely go over 300. And I would never enter carbs into Loop, so it wouldn’t think I ate anything, which I assume is part of the prediction.

2 Likes

Projections matter, though. Loop automatically boluses based on future projections as much as it boluses based on current BGs. If your projection dips below your threshold, Loop gives no insulin; however, if your projection is above the limit you set and isn’t coming down under the threshold, loop will give insulin whether or not you are currently high.

But you are using loop in a non-traditional way…Loop is supposed to be able to take all things into consideration within the algorithms when determining how much insulin to give. Because you never enter carbs, loop really never has a full picture of what’s going on in your body other than those fasting periods.

I would say in your use case, it’s best to just play around with settings and change things how you feel would best serve your use case and test those theories!

4 Likes

With FreeAPS, you can turn off micro-boluses and it will only adjust basal, right?

But you have a good point! If I am going to set my target at 70-300 to prevent extra insulin, why not just set it at 70-500, or whatever the highest value is!

(BTW, it looks like the correction range is capped at 180. So I will need to change that to a higher number and rebuild it!)

2 Likes

Yes, you can revert back to the Main branch basically by disabling the Micro-bolusing. That’s really the only major difference between the Dev (FreeAPS) branch and the master branch.

Sounds like you have a solid plan. Test and observe just like you’ve taught all of us to do! :smiley:

4 Likes

Ya, I thought it would be better to pull down the code for FreeAPS and just disable micro-boluses, rather than getting the other branch. That way I could always add it if I wanted to.

It’s very easy to disable:

2 Likes

I found the file and place to make the change in the code for the correction range.

The default code lets you pick a correction range anywhere between 60-180.

I made the change to allow me to pick a range anywhere between 50-500. Here I have it set for 80-500.

If anyone is interested in making the change to allow you to pick a bigger range (the intent is that you DON’T want loop to give you insulin, so you pick a higher target), here is the file:

LoopWorkspace\Loop\LoopCore\LoopSettings.swift

Edit LoopSettings.swift and look for this:

public func allowedCorrectionRangeValues(for unit: HKUnit) -> [Double] {
    switch unit {
    case HKUnit.milligramsPerDeciliter:
        return (50...500).map { Double($0) }

It’s the 50…500.

2 Likes

Here is another mod I made. The default range for a temporary override for “Overall Insulin Needs” is 35% to 200%.

I wanted to be able to change those ranges to allow smaller and bigger ranges.

So this file:

LoopWorkspace\LoopKit\LoopKitUI\Views\InsulinSensitivityScalingTableViewCell.swift

Edit this file “InsulinSensitivityScalingTableViewCell.swift”

and change this line:

private let allScaleFactorPercentages = Array(stride(from: 35, through: 200, by: 5))

and change the 35 and 200 to whatever higher and lower percentages you want.

I changed mine to allow anywhere from 5% to 350%.

2 Likes

Dumb question, but wanted to check this.

Suppose I have a temporary override set for a certain percentage of more insulin. But then my sensor stops working for a few hours.

I assume that Loop will abandon the override, but I am not sure. Is that right?!?

Does Loop bail out of everything if the Dex signal goes out?

1 Like

https://loopkit.github.io/loopdocs/operation/features/workout/?h=temporary+over

In your scenario, since the G6 isn’t working (and assuming you aren’t entering BGs manually every 20 min to keep loop working), loop would not work and overrides wouldn’t work.

3 Likes

Hi @Eric, if I understand correctly what you are trying to do, I suggest you simply remove carbs, insulin, and retrospection from Loop’s BG prediction algorithm. This can be accomplished by editing this line in Loop/Loop/Models/PredictionEffects.swift.
Remove .carbs, .insulin, and .retrospection, but keep .momentum, so the edited line should read:

static let all: PredictionInputEffect = [.momentum]

Then, as you are already planning to do, keep a wide-open correction range to, say, 60-300. Loop’s prediction will then remain essentially equal to the current BG value, except for a small effect of the momentum, which should result in curtailing the basal if you are heading down towards 60 a little bit ahead of actually dropping below 60. In this arrangement, As long as your BG remains between 60 and 300 (or whatever values you choose), Loop won’t be doing anything. If your BG exceeds 300 (or whatever upper limit of the correction range you choose), Loop will start adding insulin, but that’s probably what you’d want it to do anyway. This approach is cleaner than shortening the insulin absorption time to 15 min. Once you have removed .insulin, .carbs, and .retrospection from the prediction, you do not need to change the insulin absorption time at all - you can keep it at some reasonable value so that Loop can still give you a good estimate of the actual IOB based on whatever insulin you delivered manually.

2 Likes

Okay, so that is what I was wondering.

This was last night. I still had my Riley link, so Loop could still connect to it, but the Dex blanked out for a few hours. I wasn’t sure if that was the same as far as Loop was concerned.

I expected that it would be, but just wanted to make sure!

In general, I am not leery of insulin except when someone or something else is in charge of it. :grinning:

2 Likes

Wow, thanks a lot @dm61! That sounds much better!

I will rebuild it and give that a try next. I greatly appreciate it! :+1:

2 Likes

@dm61,
Another question.

If it is only looking at momentum, and not insulin, and it takes a while for the Dex to reflect a change, what stops Loop from continually injecting insulin trying to correct me?

Like it would normally look at insulin, and say, “Okay, hold up, he’s got a unit of IOB now, let’s wait before we do anything else…”

But if insulin is removed from it’s calculation, what prevents it from continually bolusing me?

1 Like

Basically, just your current BG, which should ultimately start dropping below 300 in response to added insulin. You may want to have conservative limits for maximum bolus and maximum allowed basal rate to limit any corrections delivered. Overall, even though this is not strictly safe (and I’d definitely not recommend it to inexperienced people), I’d personally feel ok with it since coming back from 300 there would be plenty of time available to see what’s going on and prevent any lows.

2 Likes

Thinking some more about this, probably the best strategy would be to run Loop with just temp basals (no auto bolusing), and put a very conservative limit for the maximum temp basal, say just above the maximum basal rate you are using. Then, if above 300, Loop will just clamp to that basal limit, but the chances of any automatic overcorrection would be very low. Once you get to see what’s going on, you would have a good indication of the IOB and could then resume with manual corrections on your own.

2 Likes

Ya, I think what worries me is Loop continually spitting out a bolus every 5 minutes because the Dex hasn’t caught the turn yet.

Would definitely feel safer if it was only basal.

2 Likes