Skip to content

Commit

Permalink
Merge pull request #3318 from alejoe91/lazy-load-zarr-times
Browse files Browse the repository at this point in the history
Lazy loading of zarr timestamps
  • Loading branch information
alejoe91 authored Aug 21, 2024
2 parents 77d9eaf + 2af1f46 commit a2f157c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions src/spikeinterface/core/baserecording.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def get_time_info(self, segment_index=None) -> dict:

return time_kwargs

def get_times(self, segment_index=None):
def get_times(self, segment_index=None) -> np.ndarray:
"""Get time vector for a recording segment.
If the segment has a time_vector, then it is returned. Otherwise
Expand Down Expand Up @@ -809,12 +809,10 @@ def __init__(self, sampling_frequency=None, t_start=None, time_vector=None):

BaseSegment.__init__(self)

def get_times(self):
def get_times(self) -> np.ndarray:
if self.time_vector is not None:
if isinstance(self.time_vector, np.ndarray):
return self.time_vector
else:
return np.array(self.time_vector)
self.time_vector = np.asarray(self.time_vector)
return self.time_vector
else:
time_vector = np.arange(self.get_num_samples(), dtype="float64")
time_vector /= self.sampling_frequency
Expand Down
2 changes: 1 addition & 1 deletion src/spikeinterface/core/zarrextractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, folder_path: Path | str, storage_options: dict | None = None)
time_kwargs = {}
time_vector = self._root.get(f"times_seg{segment_index}", None)
if time_vector is not None:
time_kwargs["time_vector"] = time_vector[:]
time_kwargs["time_vector"] = time_vector
else:
if t_starts is None:
t_start = None
Expand Down

0 comments on commit a2f157c

Please sign in to comment.