brainbox.task.trials
Functions
Select trials of interest for raster |
|
Return psth for correct and incorrect trials and raster sorted by correct incorrect |
|
Return psth for left correct, left incorrect, right correct, right incorrect and raster sorted by these trials |
|
Return psth for left and right trials and raster sorted by left right |
|
Wrapper to get out psth and raster for trial choice |
|
Finds trials that match criterion |
|
Get event aligned raster |
|
Compute psth averaged over chosen trials |
- find_trial_ids(trials, side='all', choice='all', order='trial num', sort='idx', contrast=(1, 0.5, 0.25, 0.125, 0.0625, 0), event=None)[source]
Finds trials that match criterion
- Parameters:
trials – trials object. Must contain attributes contrastLeft, contrastRight and
feedbackType :param side: stimulus side, options are ‘all’, ‘left’ or ‘right’ :param choice: trial choice, options are ‘all’, ‘correct’ or ‘incorrect’ :param contrast: contrast of stimulus, pass in list/tuple of all contrasts that want to be considered e.g [1, 0.5] would only look for trials with 100 % and 50 % contrast :param order: how to order the trials, options are ‘trial num’ or ‘reaction time’ :param sort: how to sort the trials, options are ‘side’ (split left right trials), ‘choice’ (split correct incorrect trials), ‘choice and side’ (split left right and correct incorrect) :param event: trial event to align to (in order to remove nan trials for this event) :return: np.array of trial ids, list of dividers to indicate how trials are sorted
- get_event_aligned_raster(times, events, tbin=0.02, values=None, epoch=[-0.4, 1], bin=True)[source]
Get event aligned raster
- Parameters:
times – array of times e.g spike times or dlc points
events – array of events to epoch around
tbin – bin size to over which to count events
values – values to scale counts by
epoch – window around each event
bin – whether to bin times in tbin windows or not
- Returns:
- get_psth(raster, trial_ids=None)[source]
Compute psth averaged over chosen trials
- Parameters:
raster – output from event aligned raster, window of activity around event
trial_ids – the trials from the raster to average over
- Returns:
- filter_by_trial(raster, trial_id)[source]
Select trials of interest for raster
- Parameters:
raster
trial_id
- Returns:
- filter_correct_incorrect_left_right(trials, event_raster, event, contrast, order='trial num')[source]
Return psth for left correct, left incorrect, right correct, right incorrect and raster sorted by these trials
- Parameters:
trials – trials object
event_raster – output from get_event_aligned_activity
event – event to align to e.g ‘goCue_times’, ‘stimOn_times’
contrast – contrast of stimulus, pass in list/tuple of all contrasts that want to be
considered e.g [1, 0.5] would only look for trials with 100 % and 50 % contrast :param order: order to sort trials by either ‘trial num’ or ‘reaction time’ :return:
- filter_correct_incorrect(trials, event_raster, event, contrast, order='trial num')[source]
Return psth for correct and incorrect trials and raster sorted by correct incorrect
- Parameters:
trials – trials object
event_raster – output from get_event_aligned_activity
event – event to align to e.g ‘goCue_times’, ‘stimOn_times’
contrast – contrast of stimulus, pass in list/tuple of all contrasts that want to be
considered e.g [1, 0.5] would only look for trials with 100 % and 50 % contrast :param order: order to sort trials by either ‘trial num’ or ‘reaction time’ :return:
- filter_left_right(trials, event_raster, event, contrast, order='trial num')[source]
Return psth for left and right trials and raster sorted by left right
- Parameters:
trials – trials object
event_raster – output from get_event_aligned_activity
event – event to align to e.g ‘goCue_times’, ‘stimOn_times’
contrast – contrast of stimulus, pass in list/tuple of all contrasts that want to be
considered e.g [1, 0.5] would only look for trials with 100 % and 50 % contrast :param order: order to sort trials by either ‘trial num’ or ‘reaction time’ :return:
- filter_trials(trials, event_raster, event, contrast=(1, 0.5, 0.25, 0.125, 0.0625, 0), order='trial num', sort='choice')[source]
Wrapper to get out psth and raster for trial choice
- Parameters:
trials – trials object
event_raster – output from get_event_aligned_activity
event – event to align to e.g ‘goCue_times’, ‘stimOn_times’
contrast – contrast of stimulus, pass in list/tuple of all contrasts that want to be
considered e.g [1, 0.5] would only look for trials with 100 % and 50 % contrast :param order: order to sort trials by either ‘trial num’ or ‘reaction time’ :param sort: how to divide trials options are ‘choice’ (e.g correct vs incorrect), ‘side’ (e.g left vs right’) and ‘choice and side’ (e.g correct vs incorrect and left vs right) :return: