Skip to content

Commit

Permalink
Revert "GH-1404: Handle monitor delay errors"
Browse files Browse the repository at this point in the history
This reverts commit fbadaba.
  • Loading branch information
kschelonka committed Mar 10, 2020
1 parent e05e2ab commit 50a2f7d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
20 changes: 4 additions & 16 deletions allensdk/internal/brain_observatory/time_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,11 @@ def monitor_delay(sync_dset, stim_times, photodiode_key,
"""Calculate monitor delay."""
try:
transitions = stim_times[::transition_frame_interval]
photodiode_events = get_real_photodiode_events(sync_dset,
photodiode_key)
if len(transitions) > len(photodiode_events):
logging.warning(
"More stimulus transitions counted than "
f"photodiode events (transitions={len(transitions)}, "
f"events={len(photodiode_events)}). "
"Truncating stimulus transitions to length of "
"photodiode events.")
transitions = transitions[:len(photodiode_events)]

photodiode_events = get_real_photodiode_events(sync_dset, photodiode_key)
transition_events = photodiode_events[0:len(transitions)]
delays = transition_events - transitions
delay = np.mean(delays)
logging.info(f"Calculated monitor delay: {delay}. \n "
f"Max monitor delay: {np.max(delays)}. \n "
f"Min monitor delay: {np.min(delays)}.")

delay = np.mean(transition_events-transitions)
logging.info("Calculated monitor delay: %s", delay)

if delay < 0 or delay > max_monitor_delay:
delay = assumed_delay
Expand Down
16 changes: 0 additions & 16 deletions allensdk/test/internal/brain_observatory/test_time_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,22 +413,6 @@ def test_module(input_json):
equal_nan=True)


@pytest.mark.parametrize(
"photodiode_events,stim_events,expected_delay",
[
(np.array([2, 3, 4, 5]), np.array([1, 2, 3, 4]), ts.ASSUMED_DELAY),
(np.array([2.02, 3.02, 4.02, 5.02]), np.array([2., 3., 4., 5.]), 0.02),
(np.array([2, 3, 4]), np.array([1, 2, 3, 4]), ts.ASSUMED_DELAY),
]
)
def test_monitor_delay_mocked(photodiode_events, stim_events, expected_delay,
monkeypatch):
monkeypatch.setattr(ts, "get_real_photodiode_events", lambda x, y: x)
assert (ts.monitor_delay(photodiode_events, stim_events, "dummy_key",
transition_frame_interval=1)
== pytest.approx(expected_delay, 0.000001))


@pytest.mark.skipif(data_skip, reason="No sync or data")
def test_monitor_delay(scientifica_input):
sync_file = scientifica_input.pop("sync_file")
Expand Down

0 comments on commit 50a2f7d

Please sign in to comment.