StephenBlackWasAlreadyTaken / xDrip-Experimental

Experimental Branches for Collaboration on DexDrip
GNU General Public License v3.0
25 stars 62 forks source link

overriden calibrations used in slopeOOBHandler ? #378

Open JohanDegraeve opened 8 years ago

JohanDegraeve commented 8 years ago

when overriding a calibration, the latest calibration is changed so that sensor_confidence=0 and slope_confidence=0 (see https://github.com/StephenBlackWasAlreadyTaken/xDrip-Experimental/blob/master/app/src/main/java/com/eveningoutpost/dexdrip/Models/Calibration.java#L664)

Then when a new calibration is created, a call is made to calculate_w_l_s this one makes a call to slopeOOBHandler slopeOOBHandler uses the latest 3 calibrations. For this it calls Calibrations.latest(3) https://github.com/StephenBlackWasAlreadyTaken/xDrip-Experimental/blob/master/app/src/main/java/com/eveningoutpost/dexdrip/Models/Calibration.java#L550

But latest(3) is picking up all calibrations with matching sensor id, the latest 3, that means it also takes the latest one which is actually being overriden.

Is that normal ? I would think that it's better to get Calibration.allForSensorInLastFourDays and then take the latet 3 from that result.

AdrianLxM commented 8 years ago

I's day: forget about that if you want to have the same behaviour as xDrip:

As you have already pointed out here: https://github.com/StephenBlackWasAlreadyTaken/xDrip-Experimental/issues/361 , there is another bug that estimate_bg_at_time_of_calibration is never written. Therefore the only cases where one of the latest calibrations would be used (e.g. https://github.com/StephenBlackWasAlreadyTaken/xDrip-Experimental/blob/master/app/src/main/java/com/eveningoutpost/dexdrip/Models/Calibration.java#L554) can never happen.

Basically what stays it is just a distinction if the initial calibration is done (then we have at least 2 calibrations) or if a third one was entered and then return a default value based on the default parameters and sensor age.

The whole calibration algorithm would need an overhaul.

JohanDegraeve commented 8 years ago

returnvalue would be different depending calibrations.size()

if L544 will never happen as you say, then the value would be

if size = 3 Math.max(((-0.048) * (thisCalibration.sensor_age_at_time_of_estimation / (60000 * 60 * 24))) + 1.1, sParams.getDefaultLowSlopeLow());

if size = 2 Math.max(((-0.048) * (thisCalibration.sensor_age_at_time_of_estimation / (60000 * 60 * 24))) + 1.1, sParams.getDefaultLowSlopeHigh());

The test I'm doing now is doing an override immediately after initial calibration. I'm indeed trying to get exactly the same behaviour as the Android version. Actually I had an error that I was taking the latest3 with sensor confidence != 0 and slope confidence != 0, so I was getting size 2 while the Android version is getting size 3.

But ok I'll align it with the Android version

AdrianLxM commented 8 years ago

Yea, sure. Overriding the initial calibration is an exception.

After the initial calibration, the slope usually is 1.15 and after another one (or overwritten one) 1.08. Freshly started sensors don't have such high slopes anyways for me and I've corrected those values down in my version.

But actually it is both a situation where we don't have much information so setting a default slope close to 1 and adjusting the intercept seems reasonable to me.

The inicial calibration and how it is represented and overwritten also is a bit... well. Actually just one bg entry gets overwritten.

Overall this is just the slopeOOBHandler. Usually linear regression does determine slope and intercept. Just if the slope is too off, reasonable defaults are returned. They are just general estimations and will be off for an individual system/patient anyways. I use individual ones that are much lower - and widened the range where the linear regression result is not overruled and go very well with it.

On 20/08/16 23:26, Johan Degraeve wrote:

returnvalue would be different depending calibrations.size()

if L544 will never happen as you say, then the value would be

if size = 3 Math.max(((-0.048) * (thisCalibration.sensor_age_at_time_of_estimation / (60000 * 60 * 24))) + 1.1, sParams.getDefaultLowSlopeLow());

if size = 2 Math.max(((-0.048) * (thisCalibration.sensor_age_at_time_of_estimation / (60000 * 60 * 24))) + 1.1, sParams.getDefaultLowSlopeHigh());

The test I'm doing now is doing an override immediately after initial calibration. I'm indeed trying to get exactly the same behaviour as the Android version. Actually I had an error that I was taking the latest3 with sensor confidence != 0 and slope confidence != 0, so I was getting size 2 while the Android version is getting size 3.

But ok I'll align it with the Android version

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/StephenBlackWasAlreadyTaken/xDrip-Experimental/issues/378#issuecomment-241224672, or mute the thread https://github.com/notifications/unsubscribe-auth/AJPmwioP336nAbUnQ5NW0CiV0Pwqcnm7ks5qh3EfgaJpZM4JpKQp.