allensdk.brain_observatory.behavior.trials_processing module

allensdk.brain_observatory.behavior.trials_processing.calculate_response_latency_list(trials: pandas.core.frame.DataFrame, response_window_start: float) → List[source]

per trial, detemines a response latency

Parameters:
trials: pd.DataFrame

contains columns “lick_times” and “change_times”

response_window_start: float

[seconds] relative to the non-display-lag-compensated presentation of the change-image

Returns:
response_latency_list: list

len() = trials.shape[0] value is ‘inf’ if there are no valid licks in the trial

allensdk.brain_observatory.behavior.trials_processing.calculate_reward_rate(response_latency=None, starttime=None, window=0.75, trial_window=25, initial_trials=10)[source]
allensdk.brain_observatory.behavior.trials_processing.calculate_reward_rate_fix_nans(trials: pandas.core.frame.DataFrame, response_window_start: float) → numpy.ndarray[source]

per trial, detemines the reward rate, replacing infs with nans

Parameters:
trials: pd.DataFrame

contains columns “lick_times”, “change_times”, and “start_time”

response_window_start: float

[seconds] relative to the non-display-lag-compensated presentation of the change-image

Returns:
reward_rate: np.ndarray

size = trials.shape[0] value is nan if calculate_reward_rate evaluates to ‘inf’

allensdk.brain_observatory.behavior.trials_processing.construct_rolling_performance_df(trials: pandas.core.frame.DataFrame, response_window_start, session_type) → pandas.core.frame.DataFrame[source]

Return a DataFrame containing trial by trial behavior response performance metrics.

Parameters:
trials: pd.DataFrame

contains columns “lick_times”, “change_times”, and “start_time”

response_window_start: float

[seconds] relative to the non-display-lag-compensated presentation of the change-image

session_type: str

used to check if this was a passive session

Returns:
pd.DataFrame
A pandas DataFrame containing:
trials_id [index]:

Index of the trial. All trials, including aborted trials, are assigned an index starting at 0 for the first trial.

reward_rate:

Rewards earned in the previous 25 trials, normalized by the elapsed time of the same 25 trials. Units are rewards/minute.

hit_rate_raw:

Fraction of go trials where the mouse licked in the response window, calculated over the previous 100 non-aborted trials. Without trial count correction applied.

hit_rate:

Fraction of go trials where the mouse licked in the response window, calculated over the previous 100 non-aborted trials. With trial count correction applied.

false_alarm_rate_raw:

Fraction of catch trials where the mouse licked in the response window, calculated over the previous 100 non-aborted trials. Without trial count correction applied.

false_alarm_rate:

Fraction of catch trials where the mouse licked in the response window, calculated over the previous 100 non-aborted trials. Without trial count correction applied.

rolling_dprime:

d prime calculated using the rolling hit_rate and rolling false_alarm _rate.