allensdk.brain_observatory.behavior.data_objects.trials.trials module

class allensdk.brain_observatory.behavior.data_objects.trials.trials.Trials(trials: DataFrame, response_window_start: float)[source]

Bases: DataObject, StimulusFileReadableInterface, NwbReadableInterface, NwbWritableInterface

property aborted: Series
calculate_reward_rate(window=0.75, trial_window=25, initial_trials=10)[source]
property catch_trial_count: int

Number of ‘catch’ trials

property change_time: Series
classmethod columns_to_output() List[str][source]

Return the list of columns to be output in this table

property correct_reject: Series
property correct_reject_trial_count: int

Number of trials with a correct reject behavior response

property data: DataFrame
property false_alarm: Series
property false_alarm_trial_count: int

Number of trials where the mouse had a false alarm behavior response

classmethod from_nwb(nwbfile: NWBFile) Trials[source]

Populate a DataObject from a pyNWB file object.

Parameters:
nwbfile:

The file object (NWBFile) of a pynwb dataset file.

Returns:
DataObject:

An instantiated DataObject which has name and value properties

classmethod from_stimulus_file(stimulus_file: BehaviorStimulusFile, stimulus_timestamps: StimulusTimestamps, licks: Licks, rewards: Rewards, sync_file: SyncFile | None = None) Trials[source]

Populate a DataObject from the stimulus file

Returns:
DataObject:

An instantiated DataObject which has name and value properties

get_engaged_trial_count(engaged_trial_reward_rate_threshold: float = 2.0) int[source]

Gets count of trials considered “engaged”

Parameters:
engaged_trial_reward_rate_threshold:

The number of rewards per minute that needs to be attained before a subject is considered ‘engaged’, by default 2.0

Returns:
count of trials considered “engaged”
property go_trial_count: int

Number of ‘go’ trials

property hit: Series
property hit_trial_count: int

Number of trials with a hit behavior response

property index: Index
property lick_times: Series
property miss: Series
property miss_trial_count: int

Number of trials with a hit behavior response

property rolling_performance: DataFrame

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

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.

property start_time: Series
to_nwb(nwbfile: NWBFile) NWBFile[source]

Given an already populated DataObject, return an pyNWB file object that had had DataObject data added.

Parameters:
nwbfileNWBFile

An NWB file object

Returns:
NWBFile

An NWB file object that has had data from the DataObject added to it.

classmethod trial_class()[source]

Return the class to be used to represent a single Trial

property trial_count: int

Number of trials (including all ‘go’, ‘catch’, and ‘aborted’ trials)