Remove oref0 sensitivity

This commit is contained in:
Tim Gunn 2020-04-05 22:02:37 +12:00
parent 1509fe2dea
commit f707c72634
No known key found for this signature in database
GPG key ID: C9BC1E9D0D0AED8C
4 changed files with 21 additions and 211 deletions

View file

@ -84,7 +84,6 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
@Inject lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin @Inject lateinit var openAPSSMBPlugin: OpenAPSSMBPlugin
@Inject lateinit var safetyPlugin: SafetyPlugin @Inject lateinit var safetyPlugin: SafetyPlugin
@Inject lateinit var sensitivityAAPSPlugin: SensitivityAAPSPlugin @Inject lateinit var sensitivityAAPSPlugin: SensitivityAAPSPlugin
@Inject lateinit var sensitivityOref0Plugin: SensitivityOref1Plugin
@Inject lateinit var sensitivityOref1Plugin: SensitivityOref1Plugin @Inject lateinit var sensitivityOref1Plugin: SensitivityOref1Plugin
@Inject lateinit var sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin @Inject lateinit var sensitivityWeightedAveragePlugin: SensitivityWeightedAveragePlugin
@Inject lateinit var dexcomPlugin: DexcomPlugin @Inject lateinit var dexcomPlugin: DexcomPlugin
@ -167,7 +166,6 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
addPreferencesFromResourceIfEnabled(openAPSSMBPlugin, rootKey, Config.APS) addPreferencesFromResourceIfEnabled(openAPSSMBPlugin, rootKey, Config.APS)
addPreferencesFromResourceIfEnabled(sensitivityAAPSPlugin, rootKey) addPreferencesFromResourceIfEnabled(sensitivityAAPSPlugin, rootKey)
addPreferencesFromResourceIfEnabled(sensitivityWeightedAveragePlugin, rootKey) addPreferencesFromResourceIfEnabled(sensitivityWeightedAveragePlugin, rootKey)
addPreferencesFromResourceIfEnabled(sensitivityOref0Plugin, rootKey)
addPreferencesFromResourceIfEnabled(sensitivityOref1Plugin, rootKey) addPreferencesFromResourceIfEnabled(sensitivityOref1Plugin, rootKey)
addPreferencesFromResourceIfEnabled(danaRPlugin, rootKey, Config.PUMPDRIVERS) addPreferencesFromResourceIfEnabled(danaRPlugin, rootKey, Config.PUMPDRIVERS)
addPreferencesFromResourceIfEnabled(danaRKoreanPlugin, rootKey, Config.PUMPDRIVERS) addPreferencesFromResourceIfEnabled(danaRKoreanPlugin, rootKey, Config.PUMPDRIVERS)

View file

@ -48,7 +48,6 @@ import info.nightscout.androidaps.plugins.pump.mdi.MDIPlugin
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin
import info.nightscout.androidaps.plugins.source.* import info.nightscout.androidaps.plugins.source.*
@ -98,126 +97,120 @@ abstract class PluginsModule {
@AllConfigs @AllConfigs
@IntoMap @IntoMap
@IntKey(60) @IntKey(60)
abstract fun bindSensitivityOref0Plugin(plugin: SensitivityOref0Plugin): PluginBase
@Binds
@AllConfigs
@IntoMap
@IntKey(70)
abstract fun bindSensitivityAAPSPlugin(plugin: SensitivityAAPSPlugin): PluginBase abstract fun bindSensitivityAAPSPlugin(plugin: SensitivityAAPSPlugin): PluginBase
@Binds @Binds
@AllConfigs @AllConfigs
@IntoMap @IntoMap
@IntKey(80) @IntKey(70)
abstract fun bindSensitivityWeightedAveragePlugin(plugin: SensitivityWeightedAveragePlugin): PluginBase abstract fun bindSensitivityWeightedAveragePlugin(plugin: SensitivityWeightedAveragePlugin): PluginBase
@Binds @Binds
@AllConfigs @AllConfigs
@IntoMap @IntoMap
@IntKey(90) @IntKey(80)
abstract fun bindSensitivityOref1Plugin(plugin: SensitivityOref1Plugin): PluginBase abstract fun bindSensitivityOref1Plugin(plugin: SensitivityOref1Plugin): PluginBase
@Binds @Binds
@PumpDriver @PumpDriver
@IntoMap @IntoMap
@IntKey(100) @IntKey(90)
abstract fun bindDanaRPlugin(plugin: DanaRPlugin): PluginBase abstract fun bindDanaRPlugin(plugin: DanaRPlugin): PluginBase
@Binds @Binds
@PumpDriver @PumpDriver
@IntoMap @IntoMap
@IntKey(110) @IntKey(100)
abstract fun bindDanaRKoreanPlugin(plugin: DanaRKoreanPlugin): PluginBase abstract fun bindDanaRKoreanPlugin(plugin: DanaRKoreanPlugin): PluginBase
@Binds @Binds
@PumpDriver @PumpDriver
@IntoMap @IntoMap
@IntKey(120) @IntKey(110)
abstract fun bindDanaRv2Plugin(plugin: DanaRv2Plugin): PluginBase abstract fun bindDanaRv2Plugin(plugin: DanaRv2Plugin): PluginBase
@Binds @Binds
@PumpDriver @PumpDriver
@IntoMap @IntoMap
@IntKey(130) @IntKey(120)
abstract fun bindDanaRSPlugin(plugin: DanaRSPlugin): PluginBase abstract fun bindDanaRSPlugin(plugin: DanaRSPlugin): PluginBase
@Binds @Binds
@PumpDriver @PumpDriver
@IntoMap @IntoMap
@IntKey(140) @IntKey(130)
abstract fun bindLocalInsightPlugin(plugin: LocalInsightPlugin): PluginBase abstract fun bindLocalInsightPlugin(plugin: LocalInsightPlugin): PluginBase
@Binds @Binds
@PumpDriver @PumpDriver
@IntoMap @IntoMap
@IntKey(150) @IntKey(140)
abstract fun bindComboPlugin(plugin: ComboPlugin): PluginBase abstract fun bindComboPlugin(plugin: ComboPlugin): PluginBase
@Binds @Binds
@PumpDriver @PumpDriver
@IntoMap @IntoMap
@IntKey(160) @IntKey(150)
abstract fun bindMedtronicPumpPlugin(plugin: MedtronicPumpPlugin): PluginBase abstract fun bindMedtronicPumpPlugin(plugin: MedtronicPumpPlugin): PluginBase
@Binds @Binds
@NotNSClient @NotNSClient
@IntoMap @IntoMap
@IntKey(170) @IntKey(160)
abstract fun bindMDIPlugin(plugin: MDIPlugin): PluginBase abstract fun bindMDIPlugin(plugin: MDIPlugin): PluginBase
@Binds @Binds
@AllConfigs @AllConfigs
@IntoMap @IntoMap
@IntKey(180) @IntKey(170)
abstract fun bindVirtualPumpPlugin(plugin: VirtualPumpPlugin): PluginBase abstract fun bindVirtualPumpPlugin(plugin: VirtualPumpPlugin): PluginBase
@Binds @Binds
@NotNSClient @NotNSClient
@IntoMap @IntoMap
@IntKey(190) @IntKey(180)
abstract fun bindCareportalPlugin(plugin: CareportalPlugin): PluginBase abstract fun bindCareportalPlugin(plugin: CareportalPlugin): PluginBase
@Binds @Binds
@APS @APS
@IntoMap @IntoMap
@IntKey(200) @IntKey(190)
abstract fun bindLoopPlugin(plugin: LoopPlugin): PluginBase abstract fun bindLoopPlugin(plugin: LoopPlugin): PluginBase
@Binds @Binds
@APS @APS
@IntoMap @IntoMap
@IntKey(210) @IntKey(200)
abstract fun bindOpenAPSMAPlugin(plugin: OpenAPSMAPlugin): PluginBase abstract fun bindOpenAPSMAPlugin(plugin: OpenAPSMAPlugin): PluginBase
@Binds @Binds
@APS @APS
@IntoMap @IntoMap
@IntKey(220) @IntKey(210)
abstract fun bindOpenAPSAMAPlugin(plugin: OpenAPSAMAPlugin): PluginBase abstract fun bindOpenAPSAMAPlugin(plugin: OpenAPSAMAPlugin): PluginBase
@Binds @Binds
@APS @APS
@IntoMap @IntoMap
@IntKey(230) @IntKey(220)
abstract fun bindOpenAPSSMBPlugin(plugin: OpenAPSSMBPlugin): PluginBase abstract fun bindOpenAPSSMBPlugin(plugin: OpenAPSSMBPlugin): PluginBase
@Binds @Binds
@AllConfigs @AllConfigs
@IntoMap @IntoMap
@IntKey(240) @IntKey(230)
abstract fun bindNSProfilePlugin(plugin: NSProfilePlugin): PluginBase abstract fun bindNSProfilePlugin(plugin: NSProfilePlugin): PluginBase
@Binds @Binds
@NotNSClient @NotNSClient
@IntoMap @IntoMap
@IntKey(250) @IntKey(240)
abstract fun bindLocalProfilePlugin(plugin: LocalProfilePlugin): PluginBase abstract fun bindLocalProfilePlugin(plugin: LocalProfilePlugin): PluginBase
@Binds @Binds
@AllConfigs @AllConfigs
@IntoMap @IntoMap
@IntKey(255) @IntKey(250)
abstract fun bindAutomationPlugin(plugin: AutomationPlugin): PluginBase abstract fun bindAutomationPlugin(plugin: AutomationPlugin): PluginBase
@Binds @Binds

View file

@ -1,182 +0,0 @@
package info.nightscout.androidaps.plugins.sensitivity;
import androidx.annotation.NonNull;
import androidx.collection.LongSparseArray;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.ProfileSwitch;
import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction;
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.utils.DateUtil;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP;
/**
* Created by mike on 24.06.2017.
*/
@Singleton
public class SensitivityOref0Plugin extends AbstractSensitivityPlugin {
private ProfileFunction profileFunction;
@Inject
public SensitivityOref0Plugin(
HasAndroidInjector injector,
AAPSLogger aapsLogger,
ResourceHelper resourceHelper,
SP sp,
ProfileFunction profileFunction
) {
super(new PluginDescription()
.mainType(PluginType.SENSITIVITY)
.pluginName(R.string.sensitivityoref0)
.shortName(R.string.sensitivity_shortname)
.preferencesId(R.xml.pref_absorption_oref0)
.description(R.string.description_sensitivity_oref0)
.setDefault(),
injector, aapsLogger, resourceHelper, sp
);
this.profileFunction = profileFunction;
}
@NonNull @Override
public AutosensResult detectSensitivity(IobCobCalculatorPlugin iobCobCalculatorPlugin, long fromTime, long toTime) {
LongSparseArray<AutosensData> autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable();
int hoursForDetection = 24;
Profile profile = profileFunction.getProfile();
if (profile == null) {
getAapsLogger().error("No profile");
return new AutosensResult();
}
if (autosensDataTable == null || autosensDataTable.size() < 4) {
getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. lastDataTime=" + iobCobCalculatorPlugin.lastDataTime());
return new AutosensResult();
}
AutosensData current = iobCobCalculatorPlugin.getAutosensData(toTime); // this is running inside lock already
if (current == null) {
getAapsLogger().debug(LTag.AUTOSENS, "No autosens data available. toTime: " + DateUtil.dateAndTimeString(toTime) + " lastDataTime: " + iobCobCalculatorPlugin.lastDataTime());
return new AutosensResult();
}
List<CareportalEvent> siteChanges = MainApp.getDbHelper().getCareportalEventsFromTime(fromTime, CareportalEvent.SITECHANGE, true);
List<ProfileSwitch> profileSwitches = MainApp.getDbHelper().getProfileSwitchEventsFromTime(fromTime, true);
List<Double> deviationsArray = new ArrayList<>();
String pastSensitivity = "";
int index = 0;
while (index < autosensDataTable.size()) {
AutosensData autosensData = autosensDataTable.valueAt(index);
if (autosensData.time < fromTime) {
index++;
continue;
}
if (autosensData.time > toTime) {
index++;
continue;
}
// reset deviations after site change
if (CareportalEvent.isEvent5minBack(siteChanges, autosensData.time)) {
deviationsArray.clear();
pastSensitivity += "(SITECHANGE)";
}
// reset deviations after profile switch
if (ProfileSwitch.isEvent5minBack(getAapsLogger(), profileSwitches, autosensData.time, true)) {
deviationsArray.clear();
pastSensitivity += "(PROFILESWITCH)";
}
double deviation = autosensData.deviation;
//set positive deviations to zero if bg < 80
if (autosensData.bg < 80 && deviation > 0)
deviation = 0;
if (autosensData.validDeviation)
if (autosensData.time > toTime - hoursForDetection * 60 * 60 * 1000L)
deviationsArray.add(deviation);
if (deviationsArray.size() > hoursForDetection * 60 / 5)
deviationsArray.remove(0);
pastSensitivity += autosensData.pastSensitivity;
int secondsFromMidnight = Profile.secondsFromMidnight(autosensData.time);
if (secondsFromMidnight % 3600 < 2.5 * 60 || secondsFromMidnight % 3600 > 57.5 * 60) {
pastSensitivity += "(" + Math.round(secondsFromMidnight / 3600d) + ")";
}
index++;
}
Double[] deviations = new Double[deviationsArray.size()];
deviations = deviationsArray.toArray(deviations);
double sens = profile.getIsfMgdl();
double ratio;
String ratioLimit = "";
String sensResult;
getAapsLogger().debug(LTag.AUTOSENS, "Records: " + index + " " + pastSensitivity);
Arrays.sort(deviations);
for (double i = 0.9; i > 0.1; i = i - 0.02) {
if (IobCobCalculatorPlugin.percentile(deviations, (i + 0.02)) >= 0 && IobCobCalculatorPlugin.percentile(deviations, i) < 0) {
getAapsLogger().debug(LTag.AUTOSENS, Math.round(100 * i) + "% of non-meal deviations negative (target 45%-50%)");
}
}
double pSensitive = IobCobCalculatorPlugin.percentile(deviations, 0.50);
double pResistant = IobCobCalculatorPlugin.percentile(deviations, 0.45);
double basalOff = 0;
if (pSensitive < 0) { // sensitive
basalOff = pSensitive * (60 / 5.0) / sens;
sensResult = "Excess insulin sensitivity detected";
} else if (pResistant > 0) { // resistant
basalOff = pResistant * (60 / 5.0) / sens;
sensResult = "Excess insulin resistance detected";
} else {
sensResult = "Sensitivity normal";
}
getAapsLogger().debug(LTag.AUTOSENS, sensResult);
ratio = 1 + (basalOff / profile.getMaxDailyBasal());
AutosensResult output = fillResult(ratio, current.cob, pastSensitivity, ratioLimit,
sensResult, deviationsArray.size());
getAapsLogger().debug(LTag.AUTOSENS, "Sensitivity to: "
+ DateUtil.dateAndTimeString(toTime) +
" ratio: " + output.ratio
+ " mealCOB: " + current.cob);
return output;
}
}

View file

@ -50,7 +50,8 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
.shortName(R.string.sensitivity_shortname) .shortName(R.string.sensitivity_shortname)
.enableByDefault(true) .enableByDefault(true)
.preferencesId(R.xml.pref_absorption_oref1) .preferencesId(R.xml.pref_absorption_oref1)
.description(R.string.description_sensitivity_oref1), .description(R.string.description_sensitivity_oref1)
.setDefault(),
injector, aapsLogger, resourceHelper, sp injector, aapsLogger, resourceHelper, sp
); );
this.profileFunction = profileFunction; this.profileFunction = profileFunction;