Пример #1
0
def get_weights(mousename, labname):

    wei = {}
    wei['date_time'], wei['weight'] = (action.Weighing()
                                       & 'subject_nickname="%s"' % mousename
                                       & 'lab_name="%s"' % labname).fetch(
                                           'weighing_time',
                                           'weight',
                                           order_by='weighing_time')
    wei = pd.DataFrame.from_dict(wei)

    # ensure that the reference weight is also added
    restrictions = pd.DataFrame.from_dict(
        (action.WaterRestriction & 'subject_nickname="%s"' % mousename
         & 'lab_name="%s"' % labname).fetch(as_dict=True))
    restr_summary = restrictions[[
        'restriction_start_time', 'reference_weight'
    ]].copy()
    restr_summary = restr_summary.rename(columns={
        'restriction_start_time': 'date_time',
        'reference_weight': 'weight'
    })

    wei = pd.concat([wei, restr_summary], ignore_index=True)

    if not wei.empty:
        # now organize in a pandas dataframe
        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
def get_weights(mousename):

    wei = {}
    wei['date_time'], wei['weight'] = (
        action.Weighing() & 'subject_nickname="%s"' % mousename).fetch(
            'weighing_time', 'weight', order_by='weighing_time')
    wei = pd.DataFrame.from_dict(wei)

    if not wei.empty:
        # now organize in a pandas dataframe
        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
Пример #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()
Пример #4
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']))
Пример #5
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):