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 HDF5 and NWB get_frames behavior #174

Merged
merged 19 commits into from
Feb 1, 2024
Merged
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
Expand Up @@ -90,21 +90,16 @@ def __init__(
def __del__(self):
self._file.close()

def get_frames(self, frame_idxs: ArrayType, channel: Optional[int] = 0):
def get_video(
self, start_frame: Optional[int] = None, end_frame: Optional[int] = None, channel: int = 0
) -> np.ndarray:
return self._video[start_frame:end_frame, :, :, channel]

# Fancy indexing is non performant for h5.py with long frame lists
if frame_idxs is not None:
slice_start = np.min(frame_idxs)
slice_stop = min(np.max(frame_idxs) + 1, self.get_num_frames())
else:
slice_start = 0
slice_stop = self.get_num_frames()

frames = self._video.lazy_slice[slice_start:slice_stop, :, :, channel].dsetread()
return frames
def get_frames(self, frame_idxs: ArrayType, channel: int = 0) -> np.ndarray:
return self._video[frame_idxs, :, :, channel]

def get_image_size(self) -> Tuple[int, int]:
return (self._num_rows, self._num_cols)
return self._num_rows, self._num_cols

def get_num_frames(self):
return self._num_frames
Expand Down