def get_water(mousename):

    wei = (action.WaterAdministration()
           & 'subject_nickname="%s"' % mousename).fetch(as_dict=True)
    wei = pd.DataFrame(wei)
    if not wei.empty:
        wei.rename(columns={
            'administration_time': 'date_time',
            'watertype_name': 'water_type'
        },
                   inplace=True)

        wei['date_time'] = pd.to_datetime(wei.date_time)
        wei.sort_values('date_time', inplace=True)
        wei.reset_index(drop=True, inplace=True)
        wei['date'] = wei['date_time'].dt.floor('D')

        wei['days'] = wei.date - wei.date[0]
        wei['days'] = wei.days.dt.days  # convert to number of days from start of the experiment

    return wei
Esempio n. 2
0
from ibl_pipeline import reference, subject, action, acquisition, data, behavior

# loading and plotting functions
from behavior_plots import *
from load_mouse_data_datajoint import * # this has all plotting functions
import psychofit as psy # https://github.com/cortex-lab/psychofit

# folder to save plots, from DataJoint
path = '/Figures_DataJoint_shortcuts/'

# ============================================= #
# START BIG OVERVIEW PLOT
# ============================================= #

allsubjects = pd.DataFrame.from_dict(((subject.Subject() - subject.Death()) & 'sex!="U"'
                                   & action.Weighing() & action.WaterAdministration() & behavior.TrialSet()
                                   ).fetch(as_dict=True, order_by=['lab_name', 'subject_nickname']))
users = allsubjects['lab_name'].unique()
print(users)

# from guido: make sure max 5 mice are plotted on a single figure
sub_batch_size = 5


for lidx, lab in enumerate(users):

	# take mice from this lab only
	subjects = pd.DataFrame.from_dict(((subject.Subject() - subject.Death() & 'sex!="U"' & 'lab_name="%s"'%lab)
                                   & action.Weighing() & action.WaterAdministration() & behavior.TrialSet()
                                   ).fetch(as_dict=True, order_by=['subject_nickname']))
Esempio n. 3
0
# loading and plotting functions
from define_paths import fig_path
from behavior_plots import *
from load_mouse_data_datajoint import *  # this has all plotting functions
import psychofit as psy  # https://github.com/cortex-lab/psychofit

# folder to save plots, from DataJoint
path = '/Snapshot_DataJoint_shortcut/'

# ============================================= #
# START BIG OVERVIEW PLOT
# ============================================= #

subjects = pd.DataFrame.from_dict(
    ((subject.Subject() - subject.Death() & 'sex!="U"')
     & action.Weighing() & action.WaterAdministration()
     & behavior.TrialSet()).fetch(as_dict=True,
                                  order_by=['lab_name', 'subject_nickname']))
users = subjects['lab_name'].unique()
print(users)

for lidx, lab in enumerate(users):

    subjects = pd.DataFrame.from_dict(
        ((subject.Subject() - subject.Death() & 'subject_nickname="IBL_47"'
          & 'sex!="U"' & 'lab_name="%s"' % lab)
         & action.Weighing() & action.WaterAdministration()
         & behavior.TrialSet()).fetch(as_dict=True,
                                      order_by=['subject_nickname']))
    # group by batches: mice that were born on the same day
    batches = subjects.subject_birth_date.unique()
Esempio n. 4
0
from ibl_pipeline.analyses import psychofit as psy  # https://github.com/cortex-lab/psychofit

# loading and plotting functions
from behavior_plots import *
from load_mouse_data_datajoint import *  # this has all plotting functions

# folder to save plots, from DataJoint
path = '/Figures_DataJoint_shortcuts/'

# ============================================= #
# START BIG OVERVIEW PLOT
# ============================================= #

allsubjects = pd.DataFrame.from_dict(
    ((subject.Subject() - subject.Death()) & 'sex!="U"'
     & action.Weighing() & action.WaterAdministration()).fetch(
         as_dict=True, order_by=['lab_name', 'subject_nickname']))
if allsubjects.empty:
    raise ValueError('DataJoint seems to be down, please try again later')

users = allsubjects['lab_name'].unique()
print(users)

# from guido: make sure max 5 mice are plotted on a single figure
sub_batch_size = 5

# keep track of when each mouse is trained
training_review = pd.DataFrame([])

for lidx, lab in enumerate(users):