Skip to content

Commit

Permalink
Remove duplicate timestamps, correct pause units, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelbray32 committed Oct 23, 2023
1 parent 2f8b461 commit 7703f0e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/spikegadgets_to_nwb/convert_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def remove_acquisition_timing_pause_non_ptp(
- camera_systime : np.ndarray
Camera system time after removing the pause.
"""
dio_systime = dio_systime[is_valid_camera_time][dio_systime > pause_mid_time]
dio_systime = dio_systime[dio_systime > pause_mid_time]
frame_count = frame_count[is_valid_camera_time][camera_systime > pause_mid_time]
is_valid_camera_time[is_valid_camera_time] = camera_systime > pause_mid_time
camera_systime = camera_systime[camera_systime > pause_mid_time]
Expand Down Expand Up @@ -517,8 +517,11 @@ def get_position_timestamps(
return video_timestamps
else:
try:
pause_mid_time = find_acquisition_timing_pause(
dio_camera_timestamps * NANOSECONDS_PER_SECOND
pause_mid_time = (

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
find_acquisition_timing_pause(
dio_camera_timestamps * NANOSECONDS_PER_SECOND
)
/ NANOSECONDS_PER_SECOND
)
frame_rate_from_dio = get_framerate(

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
dio_camera_timestamps[dio_camera_timestamps > pause_mid_time]
Expand All @@ -535,7 +538,7 @@ def get_position_timestamps(
is_valid_camera_time = np.isin(video_timestamps.index, sample_count)

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

View check run for this annotation

Codecov / codecov/patch

src/spikegadgets_to_nwb/convert_position.py#L538

Added line #L538 was not covered by tests

camera_systime = rec_dci_timestamps[

Check warning on line 540 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

Added line #L540 was not covered by tests
np.isin(sample_count, video_timestamps.index[is_valid_camera_time])
np.digitize(video_timestamps.index[is_valid_camera_time], sample_count)
]
if pause_mid_time is not None:
(

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

View check run for this annotation

Codecov / codecov/patch

src/spikegadgets_to_nwb/convert_position.py#L543-L544

Added lines #L543 - L544 were not covered by tests
Expand Down Expand Up @@ -564,8 +567,6 @@ def get_position_timestamps(
corrected_camera_systime = []
for id in non_repeat_timestamp_labels_id:
is_chunk = video_timestamps.non_repeat_timestamp_labels == id
camera_systime[is_chunk]
frame_count[is_chunk]
corrected_camera_systime.append(
correct_timestamps_for_camera_to_mcu_lag(
frame_count[is_chunk],
Expand All @@ -575,9 +576,12 @@ def get_position_timestamps(
)
corrected_camera_systime = np.concatenate(corrected_camera_systime)

return video_timestamps.set_index(
video_timestamps = video_timestamps.set_index(

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

View check run for this annotation

Codecov / codecov/patch

src/spikegadgets_to_nwb/convert_position.py#L579

Added line #L579 was not covered by tests
pd.Index(corrected_camera_systime, name="time")
)
return video_timestamps.groupby(

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

View check run for this annotation

Codecov / codecov/patch

src/spikegadgets_to_nwb/convert_position.py#L582

Added line #L582 was not covered by tests
video_timestamps.index
).first() # TODO: Figure out why duplicate timesteps make it to this point and why this line is necessary


def add_position(
Expand Down

0 comments on commit 7703f0e

Please sign in to comment.