Query the number of mice at different timepoints of the pipeline @author: Anne Urai, Guido Meijer, Miles Wells, 16 Jan 2020 Updated 22 April 2020, Anne Urai """ from paper_behavior_functions import query_subjects, CUTOFF_DATE from ibl_pipeline import subject, acquisition, reference from ibl_pipeline.analyses import behavior as behavior_analysis # ========================= # 1. Query all mice on brainwide map project which began training before the paper's cutoff date # ========================= all_mice = (subject.Subject * subject.SubjectLab * reference.Lab * subject.SubjectProject() & 'subject_project = "ibl_neuropixel_brainwide_01"').aggr( acquisition.Session, first_session='min(date(session_start_time))') # Filter mice that started training after the paper's cutoff date all_mice = all_mice.aggr(acquisition.Session, first_session='min(date(session_start_time))') all_mice = (all_mice & 'first_session < "%s"' % CUTOFF_DATE) print('1. Total # of mice in brainwide project: %d' % len(all_mice)) # ================================================== # Exclude mice that are still in training at the date of cut-off, meaning they have not yet # reached any learned criteria # ==================================================
import seaborn as sns from ibl_pipeline import subject, reference, acquisition from paper_behavior_functions import (seaborn_style, institution_map, group_colors, figpath, CUTOFF_DATE, FIGURE_HEIGHT, FIGURE_WIDTH, QUERY) from ibl_pipeline.analyses import behavior as behavior_analysis from lifelines import KaplanMeierFitter # Settings fig_path = figpath() seaborn_style() if QUERY is True: # Query all mice all_mice = (subject.Subject * subject.SubjectLab * reference.Lab * subject.SubjectProject() & 'subject_project = "ibl_neuropixel_brainwide_01"') mice_started_training = (all_mice & (acquisition.Session() & 'task_protocol LIKE "%training%"')) still_training = all_mice.aggr(behavior_analysis.SessionTrainingStatus, session_start_time='max(session_start_time)') \ * behavior_analysis.SessionTrainingStatus - subject.Death \ & 'training_status = "in_training"' \ & 'session_start_time > "%s"' % CUTOFF_DATE use_subjects = mice_started_training - still_training # Get training status and training time in number of sessions and trials ses = (use_subjects * behavior_analysis.SessionTrainingStatus * behavior_analysis.PsychResults).proj( 'subject_nickname', 'training_status', 'n_trials_stim', 'institution_short').fetch( format='frame').reset_index() ses['n_trials'] = [sum(i) for i in ses['n_trials_stim']]