Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Widefield last frame indexing #20

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -91,15 +91,21 @@ def get_video(
end_frame = end_frame or self.get_num_frames()

# Ensure the end_frame does not exceed the available frames
start_frame = min(start_frame, self.get_num_frames() - 1)
end_frame = min(end_frame, self.get_num_frames() - 1)
last_batch = False
if end_frame >= self.get_num_frames():
end_frame = self.get_num_frames() - 1
last_batch = True

original_video_start_frame = self.frame_indices[start_frame]
original_video_end_frame = self.frame_indices[end_frame]
CodyCBakerPhD marked this conversation as resolved.
Show resolved Hide resolved
video = super().get_video(
start_frame=original_video_start_frame, end_frame=original_video_end_frame, channel=channel
start_frame=original_video_start_frame,
end_frame=original_video_end_frame + int(last_batch),
channel=channel,
)

filtered_indices = self.frame_indices[start_frame:end_frame] - self.frame_indices[start_frame]
filtered_indices = (
self.frame_indices[start_frame : end_frame + int(last_batch)] - self.frame_indices[start_frame]
)

return video[filtered_indices]
Original file line number Diff line number Diff line change
@@ -107,19 +107,23 @@ def get_video(
end_frame = end_frame or self.get_num_frames()

# Ensure the end_frame does not exceed the available frames
start_frame = min(start_frame, self.get_num_frames() - 1)
end_frame = min(end_frame, self.get_num_frames() - 1)
last_batch = False
if end_frame >= self.get_num_frames():
end_frame = self.get_num_frames() - 1
last_batch = True

original_video_start_frame = self.frame_indices[start_frame]
original_video_end_frame = self.frame_indices[end_frame]

video = (
self._video.lazy_slice[original_video_start_frame:original_video_end_frame, ...]
self._video.lazy_slice[original_video_start_frame : original_video_end_frame + int(last_batch), ...]
.lazy_transpose(axis_order=(0, 2, 1))
.dsetread()
.astype(dtype=self.convert_video_dtype_to)
)

filtered_indices = self.frame_indices[start_frame:end_frame] - self.frame_indices[start_frame]
filtered_indices = (
self.frame_indices[start_frame : end_frame + int(last_batch)] - self.frame_indices[start_frame]
)

return video[filtered_indices]