From 28823687faca023af3b3018a57ddfb35d40bc420 Mon Sep 17 00:00:00 2001 From: k1o0 Date: Thu, 23 May 2024 18:10:53 +0300 Subject: [PATCH] Remove hardcoded threshold; subtract reference implant weight from reference weight pct calculation --- alyx/actions/water_control.py | 11 +++++++++-- alyx/alyx/settings_lab_template.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/alyx/actions/water_control.py b/alyx/actions/water_control.py index cffe70e7..4d7f4f6b 100644 --- a/alyx/actions/water_control.py +++ b/alyx/actions/water_control.py @@ -352,7 +352,11 @@ def expected_weight(self, date=None): return 0 pz = self.zscore_weight_pct / pct_sum pr = self.reference_weight_pct / pct_sum - return pz * self.zscore_weight(date=date) + pr * self.reference_weight(date=date) + ref_weight = self.reference_weight(date=date) + ref_iw = self.reference_implant_weight_at(date) or 0. + iw = self.last_implant_weight_before(date) or 0. + ref_pct = pr * (ref_weight - ref_iw) + iw + return pz * self.zscore_weight(date=date) + ref_pct def percentage_weight(self, date=None): """Percentage of the weight relative to the expected weight. @@ -414,7 +418,10 @@ def expected_water(self, date=None): weight = self.last_weighing_before(date=date) weight = weight[1] if weight else 0. expected_weight = self.expected_weight(date=date) or 0. - return 0.05 * (weight - iw) if weight < 0.8 * expected_weight else 0.04 * (weight - iw) + pct_sum = (self.reference_weight_pct + self.zscore_weight_pct) + # Increase required water by 0.01mL/g if weight below pct reference + pct_weight = (pct_sum * expected_weight) + return 0.05 * (weight - iw) if weight < pct_weight else 0.04 * (weight - iw) def given_water(self, date=None, has_session=None): """Return the amount of water given at a specified date.""" diff --git a/alyx/alyx/settings_lab_template.py b/alyx/alyx/settings_lab_template.py index 29c2e836..9c10fabb 100644 --- a/alyx/alyx/settings_lab_template.py +++ b/alyx/alyx/settings_lab_template.py @@ -3,7 +3,7 @@ # ALYX-SPECIFIC ALLOWED_HOSTS = ['localhost', '127.0.0.1'] LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'Europe/London' +TIME_ZONE = 'Europe/London' # NB: Changing the timezone here requires migrations GLOBUS_CLIENT_ID = '525cc543-8ccb-4d11-8036-af332da5eafd' SUBJECT_REQUEST_EMAIL_FROM = 'alyx@internationalbrainlab.org' DEFAULT_SOURCE = 'IBL'