Auerbach-Lab/Behavior-autoanalysis

Max_weight calculation

Opened this issue · 3 comments

weight warnings when deleting and re-entering old data produce a max weight loss warning since max weight is calculated off of total weight.

Reproduce:
Remove Teal4's trial on 3/20/23.
Load using the import_deleted_entries
get warning:
Warning in Check_Weight() : ACTION REQUIRED: Rat has lost more than 15% of maximum body weight. (380 -> 304).

tofof commented

Isn't that correct to do?
What do you mean 'total weight'?

So the data including weight is for 3/20/23. Their max weight at that time was not giving warnings. They have since put on weight as they aged and so now are using their new higher max weight causes a warning.

I am not sure if this is a problem, but it was unexpected.

tofof commented

Ah. Observations

  • The reason this is potentially problematic is that it pollutes the warnings list for historical data with a warning that never actually appeared at the time - and makes our standard problem-solving strategy (remove + reenter data) produce results that aren't 100% identical to the originally-entered data.
  • We never did decide on a completely sane strategy for assigning max_weight. The actually robust part of weight checks is my approach to noticing a decline to warn about, but that assumes that max_weight is appropriate.

Here are some strategies we may use:

  1. Update max_weight any time the new weight exceeds the prior max_weight (current implementation). The downsides of this approach are that it produces warnings for old data being re-added, as discussed above, and produces false positive warnings if e.g. an obese rat returns to a healthy weight.
  2. Do not store max_weight, and instead check against every prior-to-data-date weight during mat file processing. While this appears inefficient on its face, in practice this would probably make little (<100ms) difference on import speed, since the number of weights to check will always be relatively small (under 1000 i.e. 3 years). This would solve the issue of adding old data and producing a new warning about some future max_weight, and would produce identical behavior of false positives/negatives as the current implementation.
  3. Update max_weight only until some age cutoff that is considered canonical adult weight. This would mitigate the issue of old data / new warning but not completely solve it, as it would still be possible for the max_weight to have increased during the window between the data being re-entered and the cutoff. This could introduce a new class of false negative, if e.g. a rat was particularly underweight at the time of this cutoff, and only reached a healthy adult weight afterward -- the system would fail to warn of a return to a similarly-underweight status.
  4. Manually specify a value for max_weight in the rat archive. The advantage of this approach is that it allows compensating for obese rats so that a return to a healthy weight does not produce errors. This would also allow warning that a rate is overweight or obese, so that corrective action can be taken, if that would be of any utility. The downsides of this approach are that it relies on user judgement, and requires manual action, making it particularly unsuitable for still-growing rats who would in theory need to be repeatedly updated.
  5. Replace max_weight with appropriate_weight, using an idealized mathematical formula to compute ideal body weight for a given age, sex, and breed. Formulas like this exist for cats and dogs and are how I managed our dog's caloric needs while she was a puppy. A formula for rats might be able to be found, or would otherwise be straightforward to derive from the lab's existing weight data. This would allow warning for overweight/obese rats and would not falsely warn on an overweight rat's return to a healthy weight, but it could produce different (not necessarily better or worse) false positives and false negatives than the current approach, e.g. with a runt rat or simply a naturally-3-stddev-out rat constantly producing warnings. This might be the best approach aside from the difficulty of obtaining the requisite mathematical function.