allensdk.brain_observatory.behavior.data_objects.timestamps.stimulus_timestamps.stimulus_timestamps module

class allensdk.brain_observatory.behavior.data_objects.timestamps.stimulus_timestamps.stimulus_timestamps.StimulusTimestamps(timestamps: ndarray, monitor_delay: float, stimulus_file: BehaviorStimulusFile | None = None, sync_file: SyncFile | None = None)[source]

Bases: DataObject, StimulusFileReadableInterface, SyncFileReadableInterface, NwbReadableInterface, LimsReadableInterface, NwbWritableInterface, JsonReadableInterface

A DataObject which contains properties and methods to load, process, and represent visual behavior stimulus timestamp data.

Stimulus timestamp data is represented as:

Numpy array whose length is equal to the number of timestamps collected and whose values are timestamps (in seconds)

classmethod from_json(dict_repr: dict, monitor_delay=0.0) StimulusTimestamps[source]

Reads timestamps from stimulus file or sync file. Note that from_multiple_stimulus_blocks method of constructing timestamps is not supported using from_json

Parameters:
dict_repr
monitor_delay: Monitor delay to apply to the timestamps
Returns:
StimulusTimestamps
from_lims(db: PostgresQueryMixin, monitor_delay: float, behavior_session_id: int, ophys_experiment_id: int | None = None) StimulusTimestamps[source]

Populate a DataObject from an internal database (likely LIMS)

Returns:
DataObject:

An instantiated DataObject which has name and value properties

classmethod from_multiple_stimulus_blocks(sync_file: SyncFile, list_of_stims: List[BehaviorStimulusFile | MappingStimulusFile | ReplayStimulusFile], stims_of_interest: List[int] | None = None, monitor_delay: float = 0.0, frame_time_lines: str | List[str] = 'vsync_stim', frame_time_line_direction: str = 'rising', frame_count_tolerance: float = 0.0) StimulusTimestamps[source]

Construct a StimulusTimestamps instance by registering multiple stimulus blocks to one sync file and concatenating the results

Parameters:
sync_file: SyncFile
list_of_stims: List[Union[BehaviorStimulusFile,

MappingStimulusFile, ReplayStimulusFile]]

The list of StimulusFiles to be registered to the SyncFile in the order that they were presented to the mouse

stims_of_interest: Optional[List[int]]

The indexes in list_of_stims of the timestamps to be concatenated into this one StimulusTimestamps object. If None (default), the timestamps from all stimulus files are concatenated

monitor_delay: float

in seconds

frame_time_lines: Union[str, List[str]]

The line to be used to find raw frame times (usually ‘vsync_stim’). If a list, the code will scan the list in order until a line that is present in the sync file is found. That line will be used.

frame_time_line_direction: str

Either ‘rising’ or ‘falling’ indicating which edge to use in finding the raw frame times

frame_count_tolerance: float

The tolerance to within two blocks of frame counts are considered equal

classmethod from_nwb(nwbfile: NWBFile) StimulusTimestamps[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, monitor_delay: float) StimulusTimestamps[source]

Populate a DataObject from the stimulus file

Returns:
DataObject:

An instantiated DataObject which has name and value properties

classmethod from_sync_file(sync_file: SyncFile, monitor_delay: float) StimulusTimestamps[source]

Populate a DataObject from the sync file

Returns:
DataObject:

An instantiated DataObject which has name and value properties

property monitor_delay: float
subtract_monitor_delay() StimulusTimestamps[source]

Return a version of this StimulusTimestamps object with monitor_delay = 0 by subtracting self.monitor_delay from self.value

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.

update_timestamps(timestamps: ndarray) StimulusTimestamps[source]

Returns newly instantiated StimulusTimestamps with timestamps

Parameters:
timestamps
Returns:
StimulusTimestamps with timestamps