AllenInstitute / visual_behavior_analysis

Python package for analyzing behavioral data for Brain Observatory: Visual Behavior
Other
21 stars 6 forks source link

Add engagement to trials #736

Closed dougollerenshaw closed 3 years ago

dougollerenshaw commented 3 years ago

Add's columns for engaged (bool) and engagement_state (str, 'engaged' or 'disengaged') to the extended_trials table.

Example use:

from visual_behavior.data_access import loading

oeid = 958527474

dataset = loading.get_ophys_dataset(oeid)

dataset.extended_trials

The value of engaged and engagement_state is taken from the stimulus in extended_stimulus_presentations that most closely aligns with the start_time of each trial.

Given that extended_stimulus_presentations must first be built, this function is slow.

dougollerenshaw commented 3 years ago

Unrelated: Why is extended_stimulus_presentations so slow?

Good question, @alexpiet. Even worse, it's not a cached property, so if you load it multiple times you pay the time penalty each time.