allensdk.internal.brain_observatory.time_sync module

class allensdk.internal.brain_observatory.time_sync.OphysTimeAligner(sync_file, scanner=None, dff_file=None, stimulus_pkl=None, eye_video=None, behavior_video=None, long_stim_threshold=0.2)[source]

Bases: object

behavior_video_timestamps
corrected_behavior_video_timestamps
corrected_eye_video_timestamps
corrected_ophys_timestamps
corrected_stim_timestamps
dataset
eye_video_timestamps
ophys_timestamps

Get the timestamps for the ophys data.

stim_timestamps
allensdk.internal.brain_observatory.time_sync.corrected_video_timestamps(video_name, timestamps, data_length)[source]
allensdk.internal.brain_observatory.time_sync.get_alignment_array(ref, other, int_method=<ufunc 'floor'>)[source]

Generate an alignment array

allensdk.internal.brain_observatory.time_sync.get_keys(sync_dset: allensdk.brain_observatory.sync_dataset.Dataset) → dict[source]

Gets the correct keys for the sync file by searching the sync file line labels. Removes key from the dictionary if it is not in the sync dataset line labels. Args:

sync_dset: The sync dataset to search for keys within
Returns:
key_dict: dictionary of key value pairs for finding data in the
sync file
allensdk.internal.brain_observatory.time_sync.get_ophys_data_length(filename)[source]
allensdk.internal.brain_observatory.time_sync.get_photodiode_events(sync_dset, photodiode_key)[source]

Returns the photodiode events with the start/stop indicators and the window init flash stripped off. These transitions occur roughly ~1.0s apart, since the sync square changes state every N frames (where N = 60, and frame rate is 60 Hz). Because there are no markers for when the first transition of this type started, we estimate based on the event intervals. For the first valid event, find the first two events that both meet the following criteria:

The next event occurs ~1.0s later

First the last valid event, find the first two events that both meet the following criteria:

The last valid event occured ~1.0s before
allensdk.internal.brain_observatory.time_sync.get_real_photodiode_events(sync_dset, photodiode_key, anomaly_threshold=0.5)[source]

Gets the photodiode events with the anomalies removed.

allensdk.internal.brain_observatory.time_sync.get_stim_data_length(filename: str) → int[source]

Get stimulus data length from .pkl file.

Parameters:
filename : str

Path of stimulus data .pkl file.

Returns:
int

Stimulus data length.

allensdk.internal.brain_observatory.time_sync.get_video_length(filename)[source]
allensdk.internal.brain_observatory.time_sync.monitor_delay(sync_dset, stim_times, photodiode_key, transition_frame_interval=60, max_monitor_delay=0.07)[source]

Calculate monitor delay.