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

class allensdk.brain_observatory.behavior.data_objects.trials.trial.Trial(trial: dict, start: float, end: float, behavior_stimulus_file: BehaviorStimulusFile, index: int, stimulus_timestamps: StimulusTimestamps, licks: Licks, rewards: Rewards, stimuli: dict, sync_file: SyncFile | None = None)[source]

Bases: object

add_change_time(trial_dict: dict) Tuple[dict, float][source]

Add change_time to a dict representing a single trial.

This implementation will just take change_frame and select the value of self._stimulus_timestamps corresponding to that frame.

Parameters:
trial_dict:

dict containing all trial parameters except change_time

Returns:
trial_dict:

Same as input, except change_time field has been added

change_time: float

The change time value that was added (this is returned separately so that child classes have the option of naming the column something different than ‘change_time’)

calculate_change_frame(event_dict: dict, go: bool, catch: bool, auto_rewarded: bool) int | float[source]

Calculate the frame index of a stimulus change associated with a specific event.

Parameters:
event_dict: dict

Dictionary of trial events in the well-known pkl file

go: bool

True if “go” trial, False otherwise. Mutually exclusive with catch.

catch: bool

True if “catch” trial, False otherwise. Mutually exclusive with go.

auto_rewarded: bool

True if “auto_rewarded” trial, False otherwise.

Returns:
change_frame: Union[int, float]

Index of the change frame; NaN if there is no change

Notes

This is its own method so that child classes of Trial can implement different logic as needed.

property data