allensdk.brain_observatory.behavior.sync package

Module contents

Created on Sunday July 15 2018

@author: marinag

allensdk.brain_observatory.behavior.sync.frame_time_offset(data: Dict[str, Any]) → float[source]

Contained in the behavior “pickle” file is a series of time between consecutive vsync frames (intervalsms). This information required to get the timestamp (via frame number) for events that occured outside of a trial(e.g. licks). However, we don’t have the value in the trial log time stream when the first vsync frame actually occured – so we estimate it with a linear regression (frame number x time). All trials in the trial_log have events for trial_start and trial_end, so these are used to fit the regression. A linear regression is used rather than just subtracting the time from the first trial, since there can be some jitter given the 60Hz refresh rate.

Parameters:
data: dict

behavior pickle well-known file data

Returns:
float

Time offset to add to the vsync stream to sync it with the trial_log time stream. The “zero-th” frame time.

allensdk.brain_observatory.behavior.sync.get_behavior_monitoring(dataset: allensdk.brain_observatory.sync_dataset.Dataset, permissive: bool = False) → Union[numpy.ndarray, NoneType][source]

Report the timestamps of each frame of the behavior monitoring video

Parameters:
dataset : describes experiment timing
permissive : If True, None will be returned if timestamps are not found. If

False, a KeyError will be raised

Returns:
array of timestamps (floating point; seconds; relative to experiment start)

or None. If None, no behavior monitoring timestamps were found in this sync dataset.

allensdk.brain_observatory.behavior.sync.get_eye_tracking(dataset: allensdk.brain_observatory.sync_dataset.Dataset, permissive: bool = False) → Union[numpy.ndarray, NoneType][source]

Report the timestamps of each frame of the eye tracking video

Parameters:
dataset : describes experiment timing
permissive : If True, None will be returned if timestamps are not found. If

False, a KeyError will be raised

Returns:
array of timestamps (floating point; seconds; relative to experiment start)

or None. If None, no eye tracking timestamps were found in this sync dataset.

allensdk.brain_observatory.behavior.sync.get_lick_times(dataset: allensdk.brain_observatory.sync_dataset.Dataset, permissive: bool = False) → Union[numpy.ndarray, NoneType][source]

Report the timestamps of each detected lick

Parameters:
dataset : describes experiment timing
permissive : If True, None will be returned if timestamps are not found. If

False, a KeyError will be raised

Returns:
array of timestamps (floating point; seconds; relative to experiment start)

or None. If None, no lick timestamps were found in this sync dataset.

allensdk.brain_observatory.behavior.sync.get_ophys_frames(dataset: allensdk.brain_observatory.sync_dataset.Dataset, permissive: bool = False) → numpy.ndarray[source]

Report the timestamps of each optical physiology video frame

Parameters:
dataset : describes experiment timing
Returns:
array of timestamps (floating point; seconds; relative to experiment start).
permissive : If True, None will be returned if timestamps are not found. If

False, a KeyError will be raised

Notes

use rising edge for Scientifica, falling edge for Nikon http://confluence.corp.alleninstitute.org/display/IT/Ophys+Time+Sync This function uses rising edges

allensdk.brain_observatory.behavior.sync.get_raw_stimulus_frames(dataset: allensdk.brain_observatory.sync_dataset.Dataset, permissive: bool = False) → numpy.ndarray[source]

Report the raw timestamps of each stimulus frame. This corresponds to the time at which the psychopy window’s flip method returned, but not necessarily to the time at which the stimulus frame was displayed.

Parameters:
dataset : describes experiment timing
permissive : If True, None will be returned if timestamps are not found. If

False, a KeyError will be raised

Returns:
array of timestamps (floating point; seconds; relative to experiment start).
allensdk.brain_observatory.behavior.sync.get_stim_photodiode(dataset: allensdk.brain_observatory.sync_dataset.Dataset, permissive: bool = False) → Union[List[float], NoneType][source]

Report the timestamps of each detected sync square transition (both black -> white and white -> black) in this experiment.

Parameters:
dataset : describes experiment timing
permissive : If True, None will be returned if timestamps are not found. If

False, a KeyError will be raised

Returns:
array of timestamps (floating point; seconds; relative to experiment start)

or None. If None, no photodiode timestamps were found in this sync dataset.

allensdk.brain_observatory.behavior.sync.get_stimulus_rebase_function(data, stimulus_timestamps_no_monitor_delay)[source]

Create a rebase function to align times for licks and stimulus timestamps in the “pickle” log with the same events in the event “sync” log.

allensdk.brain_observatory.behavior.sync.get_sync_data(sync_path: str, permissive: bool = False) → Dict[str, Union[List, numpy.ndarray, NoneType]][source]

Convenience function for extracting several timestamp arrays from a sync file.

Parameters:
sync_path : The hdf5 file here ought to be a Visual Behavior sync output

file. See allensdk.brain_observatory.sync_dataset for more details of this format.

permissive : If True, None will be returned if timestamps are not found. If

False, a KeyError will be raised

Returns:
A dictionary with the following keys. All timestamps in seconds:

ophys_frames : timestamps of each optical physiology frame lick_times : timestamps of each detected lick ophys_trigger : The time at which ophys acquisition was started eye_tracking : timestamps of each eye tracking video frame behavior_monitoring : timestamps of behavior monitoring video frame stim_photodiode : timestamps of each photodiode transition stimulus_times_no_delay : raw stimulus frame timestamps

Some values may be None. This indicates that the corresponding timestamps
were not located in this sync file.
allensdk.brain_observatory.behavior.sync.get_trigger(dataset: allensdk.brain_observatory.sync_dataset.Dataset, permissive: bool = False) → Union[numpy.ndarray, NoneType][source]
Returns (as a 1-element array) the time at which optical physiology
acquisition was started.
Parameters:
dataset : describes experiment timing
permissive : If True, None will be returned if timestamps are not found. If

False, a KeyError will be raised

Returns:
timestamps (floating point; seconds; relative to experiment start)

or None. If None, no timestamps were found in this sync dataset.

Notes

Ophys frame timestamps can be recorded before acquisition start when
experimenters are setting up the recording session. These do not correspond to acquired ophys frames.