Skip to content

Commit

Permalink
Remove hardcoded threshold; subtract reference implant weight from re…
Browse files Browse the repository at this point in the history
…ference weight pct calculation
  • Loading branch information
k1o0 committed May 23, 2024
1 parent 97eb0fa commit 2882368
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions alyx/actions/water_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion alyx/alyx/settings_lab_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '[email protected]'
DEFAULT_SOURCE = 'IBL'
Expand Down

0 comments on commit 2882368

Please sign in to comment.