Brody-Lab / jbreda_animal_training

Repository for the ingestion, cleaning and visualization of behavioral experiments
0 stars 0 forks source link

Water target volume (black dashed line) appears to be off for all rats #48

Closed jess-breda closed 2 months ago

jess-breda commented 4 months ago

Noticed the black lines are much larger than the 3% that was indicated in WaterPub3, example from R027.

Image

jess-breda commented 4 months ago

In walking through the code, there isn't an issue with my code, but it is larger because the daily restriction target returned from ratinfo.Water is 20.0 for all animals.

def fetch_day_restriction_target(animal_id, date):
    """
    Function for getting an animals water
    target for a specific date

    params
    ------
    animal_id : str,
        animal name e.g. "R501"
    date : str
        date to query in YYYY-MM-DD format, e.g. "2022-01-04

    returns
    ------
    percent_target : float
        water restriction target in terms of percentage of body weight

    note
    ----
    You can also fetch this code from the registry, but it's not
    specific to the date. See code below.
# fetch from comments section e.g. 'Mouse Water Pub 4'
r500_registry = (ratinfo.Rats & 'ratname = "R501"').fetch1()
comments = r500_registry['comments']
#split after the word pub,only allow one split and
# grab whatever follows the split
target = float(comments.split('Pub',1)[1])
```
"""

Water_keys = {"rat": animal_id, "date": date}

# can't do fetch1 with this because water table
# sometimes has a 0 entry and actual entry so
# I'm taking the max to get around this
percent_target = (ratinfo.Water & Water_keys).fetch("percent_target")

if len(percent_target) == 0:
    # !!NOTE assumption made here will default to 3% for rats and 4% for mice
    # !! in the fetch_daily_water_target() function
    percent_target = 0
elif len(percent_target) > 1:
    percent_target = percent_target.max()

return float(percent_target)