Skip to content

Commit

Permalink
Use dio_camera_timestamps directly instead of inferring from mcu time…
Browse files Browse the repository at this point in the history
…stamps
  • Loading branch information
edeno committed Oct 20, 2023
1 parent 67a1a80 commit 2f8b461
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/spikegadgets_to_nwb/convert_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,15 +516,12 @@ def get_position_timestamps(
)
return video_timestamps
else:
dio_systime = rec_dci_timestamps[
np.searchsorted(rec_dci_timestamps, dio_camera_timestamps)
]
try:
pause_mid_time = find_acquisition_timing_pause(

Check warning on line 520 in src/spikegadgets_to_nwb/convert_position.py

View check run for this annotation

Codecov / codecov/patch

src/spikegadgets_to_nwb/convert_position.py#L519-L520

Added lines #L519 - L520 were not covered by tests
dio_systime * NANOSECONDS_PER_SECOND
dio_camera_timestamps * NANOSECONDS_PER_SECOND
)
frame_rate_from_dio = get_framerate(

Check warning on line 523 in src/spikegadgets_to_nwb/convert_position.py

View check run for this annotation

Codecov / codecov/patch

src/spikegadgets_to_nwb/convert_position.py#L523

Added line #L523 was not covered by tests
dio_systime[dio_systime > pause_mid_time]
dio_camera_timestamps[dio_camera_timestamps > pause_mid_time]
)
logger.info(

Check warning on line 526 in src/spikegadgets_to_nwb/convert_position.py

View check run for this annotation

Codecov / codecov/patch

src/spikegadgets_to_nwb/convert_position.py#L526

Added line #L526 was not covered by tests
"Camera frame rate estimated from DIO camera ticks:"
Expand All @@ -542,25 +539,27 @@ def get_position_timestamps(
]
if pause_mid_time is not None:
(

Check warning on line 541 in src/spikegadgets_to_nwb/convert_position.py

View check run for this annotation

Codecov / codecov/patch

src/spikegadgets_to_nwb/convert_position.py#L540-L541

Added lines #L540 - L541 were not covered by tests
dio_systime,
dio_camera_timestamps,
frame_count,
is_valid_camera_time,
camera_systime,
) = remove_acquisition_timing_pause_non_ptp(
dio_systime,
dio_camera_timestamps,
frame_count,
camera_systime,
is_valid_camera_time,
pause_mid_time,
)
else:
frame_count = frame_count[is_valid_camera_time]
print(frame_count.shape, camera_systime.shape)
original_video_timestamps = video_timestamps.copy()
video_timestamps = video_timestamps.iloc[is_valid_camera_time]

Check warning on line 555 in src/spikegadgets_to_nwb/convert_position.py

View check run for this annotation

Codecov / codecov/patch

src/spikegadgets_to_nwb/convert_position.py#L554-L555

Added lines #L554 - L555 were not covered by tests
frame_rate_from_camera_systime = get_framerate(camera_systime)
logger.info(
"Camera frame rate estimated from camera sys time:"
f" {frame_rate_from_camera_systime:0.1f} frames/s"
)
camera_to_mcu_lag = estimate_camera_to_mcu_lag(
camera_systime, dio_systime, len(non_repeat_timestamp_labels_id)
camera_systime, dio_camera_timestamps, len(non_repeat_timestamp_labels_id)
)
corrected_camera_systime = []
for id in non_repeat_timestamp_labels_id:
Expand Down

0 comments on commit 2f8b461

Please sign in to comment.