From 17bf2410c9a809b61ace0f146c12f7a28cba826d Mon Sep 17 00:00:00 2001 From: Kat Schelonka Date: Fri, 28 Feb 2020 15:14:22 -0800 Subject: [PATCH] GH #900: Compute display lag Previously the BehaviorOphysLimsApi did not compute monitor delay, but added a default value of 0.351. This updates the default to 0.215, which is the average of monitor delay for a large number of recent datasets. Additionally use the OphysTimeAligner methods to compute the display lag, which is used in the OphysTimeSync job to produce corrected timestamps in the LIMS pipeline. --- allensdk/internal/api/behavior_ophys_api.py | 7 +++++-- allensdk/internal/brain_observatory/time_sync.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/allensdk/internal/api/behavior_ophys_api.py b/allensdk/internal/api/behavior_ophys_api.py index 53bbd5fbd..268073bc9 100644 --- a/allensdk/internal/api/behavior_ophys_api.py +++ b/allensdk/internal/api/behavior_ophys_api.py @@ -10,6 +10,7 @@ from allensdk.internal.api.ophys_lims_api import OphysLimsApi from allensdk.brain_observatory.behavior.sync import ( get_sync_data, get_stimulus_rebase_function, frame_time_offset) +from allensdk.internal.brain_observatory.time_sync import OphysTimeAligner from allensdk.brain_observatory.behavior.stimulus_processing import get_stimulus_presentations, get_stimulus_templates, get_stimulus_metadata from allensdk.brain_observatory.behavior.metadata_processing import get_task_parameters from allensdk.brain_observatory.behavior.running_processing import get_running_df @@ -38,8 +39,10 @@ def get_sync_data(self): @memoize def get_stimulus_timestamps(self): - monitor_delay = .0351 - return self.get_sync_data()['stimulus_times_no_delay'] + monitor_delay + sync_path = self.get_sync_file() + timestamps, _, _ = (OphysTimeAligner(sync_file=sync_path) + .corrected_stim_timestamps) + return timestamps @memoize def get_ophys_timestamps(self): diff --git a/allensdk/internal/brain_observatory/time_sync.py b/allensdk/internal/brain_observatory/time_sync.py index d7aa449b6..3133fb3e8 100644 --- a/allensdk/internal/brain_observatory/time_sync.py +++ b/allensdk/internal/brain_observatory/time_sync.py @@ -15,7 +15,7 @@ REG_PHOTODIODE_MAX = 2.1 # seconds PHOTODIODE_ANOMALY_THRESHOLD = 0.5 # seconds LONG_STIM_THRESHOLD = 0.2 # seconds -ASSUMED_DELAY = 0.0351 # seconds +ASSUMED_DELAY = 0.0215 # seconds MAX_MONITOR_DELAY = 0.07 # seconds VERSION_1_KEYS = {