brainbox.behavior.training
Functions
Compute all relevant performance metrics for when subject is on biasedChoiceWorld 

Compute median reaction time on zero contrast trials from trials object 

Compute number of trials in trials object 

Compute performance on all trials at each contrast level from trials object 

Compute performance on easy trials (stimulus >= 50 %) from trials object 

Compute psychometric fit parameters for trials object 

Compute median reaction time for all contrasts 

Compute all relevant performance metrics for when subject is on trainingChoiceWorld 

Concatenate trials from different training sessions 

Returns bool indicating whether criterion for trained_1a is met. 

Returns bool indicating whether criterion for trained_1b is met. 

Returns bool indicating whether criterion for ready4delay is met. 

Returns bool indicating whether criterion for ready4ephysrig or ready4recording is met. 

Display training status of subject to terminal 

Computes the training status of all alive and water restricted subjects in a specified lab 

Download and load in training data for a specfied subject. 

Compute signed contrast from trials object 

Computes the training status of specified subject 

Compute training status of a subject from three consecutive training datasets 

Function to plot pyschometric curve plots a la datajoint webpage 

Function to plot reaction time against contrast a la datajoint webpage (inversed for some reason??) 

Function to plot reaction time with trial number a la datajoint webpage 
 get_lab_training_status(lab, date=None, details=True, one=None)[source]
Computes the training status of all alive and water restricted subjects in a specified lab
 Parameters
lab (string) – lab name (must match the name registered on Alyx)
date – the date from which to compute training status from. If not specified will compute
from the latest date with available data :type date: string of format ‘YYYYMMDD’ :param details: whether to display all information about training status computation e.g performance, number of trials, psychometric fit parameters :type details: bool :param one: instantiation of ONE class
 get_subject_training_status(subj, date=None, details=True, one=None)[source]
Computes the training status of specified subject
 Parameters
subj (string) – subject nickname (must match the name registered on Alyx)
date – the date from which to compute training status from. If not specified will compute
from the latest date with available data :type date: string of format ‘YYYYMMDD’ :param details: whether to display all information about training status computation e.g performance, number of trials, psychometric fit parameters :type details: bool :param one: instantiation of ONE class
 get_sessions(subj, date=None, one=None)[source]
Download and load in training data for a specfied subject. If a date is given it will load data from the three (or as many are available) previous sessions up to the specified date, if not it will load data from the last three training sessions that have data available
 Parameters
subj (string) – subject nickname (must match the name registered on Alyx)
date – the date from which to compute training status from. If not specified will compute
from the latest date with available data :type date: string of format ‘YYYYMMDD’ :param one: instantiation of ONE class :returns:
trials  dict of trials objects where each key is the session date
task_protocol  list of the task protocol used for each of the sessions
 ephys_sess_data  list of dates where training was conducted on ephys rig. Empty list if
all sessions on training rig
 n_delay  number of sessions on ephys rig that had delay prior to starting session
> 15min. Returns 0 is no sessions detected
 get_training_status(trials, task_protocol, ephys_sess_dates, n_delay)[source]
Compute training status of a subject from three consecutive training datasets
 Parameters
trials (Bunch) – dict containing trials objects from three consective training sessions
task_protocol – task protocol used for the three training session, can be ‘training’,
‘biased’ or ‘ephys’ :type task_protocol: list of strings :param ephys_sess_dates: dates of sessions conducted on ephys rig :type ephys_sess_dates: list of strings :param n_delay: number of sessions on ephys rig with delay before start > 15 min :type n_delay: int :returns:
status  training status of subject
 info  Bunch containing performance metrics that decide training status e.g performance
on easy trials, number of trials, psychometric fit parameters, reaction time
 display_status(subj, sess_dates, status, perf_easy=None, n_trials=None, psych=None, psych_20=None, psych_80=None, rt=None)[source]
Display training status of subject to terminal
 Parameters
subj (string) – subject nickname
sess_dates (list of strings) – training session dates used to determine training status
status (string) – training status of subject
perf_easy (np.array) – performance on easy trials for each training sessions
n_trials (np.array) – number of trials for each training sessions
psych (np.array  bias, threshold, lapse high, lapse low) – parameters of psychometric curve fit to data from all training sessions
psych_20 – parameters of psychometric curve fit to data in 20 (probability left) block
from all training sessions :type psych_20: np.array  bias, threshold, lapse high, lapse low :param psych_80: parameters of psychometric curve fit to data in 80 (probability left) block from all training sessions :type psych_80: np.array  bias, threshold, lapse high, lapse low :param rt: median reaction time on zero contrast trials across all training sessions (if nan indicates no zero contrast stimuli in training sessions)
 concatenate_trials(trials)[source]
Concatenate trials from different training sessions
 Parameters
trials – dict containing trials objects from three consecutive training sessions,
keys are session dates :type trials: Bunch :return: trials object with data concatenated over three training sessions :rtype: dict
 compute_training_info(trials, trials_all)[source]
Compute all relevant performance metrics for when subject is on trainingChoiceWorld
 Parameters
trials – dict containing trials objects from three consective training sessions,
keys are session dates :type trials: Bunch :param trials_all: trials object with data concatenated over three training sessions :type trials_all: Bunch :returns:
perf_easy  performance of easy trials for each session
n_trials  number of trials in each session
psych  parameters for psychometric curve fit to all sessions
rt  median reaction time for zero contrast stimuli over all sessions
 compute_bias_info(trials, trials_all)[source]
Compute all relevant performance metrics for when subject is on biasedChoiceWorld
 Parameters
trials – dict containing trials objects from three consective training sessions,
keys are session dates :type trials: Bunch :param trials_all: trials object with data concatenated over three training sessions :type trials_all: Bunch :returns:
perf_easy  performance of easy trials for each session
n_trials  number of trials in each session
psych_20  parameters for psychometric curve fit to trials in 20 block over all sessions
psych_80  parameters for psychometric curve fit to trials in 80 block over all sessions
rt  median reaction time for zero contrast stimuli over all sessions
 get_signed_contrast(trials)[source]
Compute signed contrast from trials object
 Parameters
trials (dict) – trials object that must contain contrastLeft and contrastRight keys
returns: array of signed contrasts in percent, where ve values are on the left
 compute_performance_easy(trials)[source]
Compute performance on easy trials (stimulus >= 50 %) from trials object
 Parameters
trials – trials object that must contain contrastLeft, contrastRight and feedbackType
keys :type trials: dict returns: float containing performance on easy contrast trials
 compute_performance(trials, signed_contrast=None, block=None, prob_right=False)[source]
Compute performance on all trials at each contrast level from trials object
 Parameters
trials – trials object that must contain contrastLeft, contrastRight and feedbackType
keys :type trials: dict returns: float containing performance on easy contrast trials
 compute_n_trials(trials)[source]
Compute number of trials in trials object
 Parameters
trials (dict) – trials object
returns: int containing number of trials in session
 compute_psychometric(trials, signed_contrast=None, block=None)[source]
Compute psychometric fit parameters for trials object
 Parameters
trials (dict) – trials object that must contain contrastLeft, contrastRight and probabilityLeft
signed_contrast (np.array) – array of signed contrasts in percent, where ve values are on the left
block (float) – biased block can be either 0.2 or 0.8
 Returns
array of psychometric fit parameters  bias, threshold, lapse high, lapse low
 compute_median_reaction_time(trials, stim_on_type='stimOn_times', signed_contrast=None)[source]
Compute median reaction time on zero contrast trials from trials object
 Parameters
trials (dict) – trials object that must contain response_times and stimOn_times
stim_on_type – feedback from which to compute the reaction time. Default is stimOn_times
i.e when stimulus is presented :type stim_on_type: string (must be a valid key in trials object) :param signed_contrast: array of signed contrasts in percent, where ve values are on the left :type signed_contrast: np.array :return: float of median reaction time at zero contrast (returns nan if no zero contrast trials in trials object)
 compute_reaction_time(trials, stim_on_type='stimOn_times', signed_contrast=None, block=None)[source]
Compute median reaction time for all contrasts
 Parameters
trials – trials object that must contain response_times and stimOn_times
stim_on_type –
signed_contrast –
block –
 Returns
 criterion_1a(psych, n_trials, perf_easy)[source]
Returns bool indicating whether criterion for trained_1a is met. All criteria documented here (https://figshare.com/articles/preprint/A_standardized_and_reproducible_method_to_measure_ decisionmaking_in_mice_Appendix_2_IBL_protocol_for_mice_training/11634729)
 criterion_1b(psych, n_trials, perf_easy, rt)[source]
Returns bool indicating whether criterion for trained_1b is met.
 criterion_ephys(psych_20, psych_80, n_trials, perf_easy, rt)[source]
Returns bool indicating whether criterion for ready4ephysrig or ready4recording is met.
 criterion_delay(n_trials, perf_easy)[source]
Returns bool indicating whether criterion for ready4delay is met.
 plot_psychometric(trials, ax=None, title=None, **kwargs)[source]
Function to plot pyschometric curve plots a la datajoint webpage
 Parameters
trials –
 Returns