Skip to content

Commit

Permalink
Bringing back right searches
Browse files Browse the repository at this point in the history
  • Loading branch information
yger committed Sep 19, 2023
1 parent e194b94 commit ef0d66e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
8 changes: 3 additions & 5 deletions src/spikeinterface/core/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,11 +1209,9 @@ def get_traces(
else:
traces = np.zeros([end_frame - start_frame, n_channels], dtype=self.dtype)

start, end = np.searchsorted(
self.spike_vector["sample_index"],
[start_frame - self.templates.shape[1], end_frame + self.templates.shape[1] + 1],
side="left",
)
start = np.searchsorted(self.spike_vector["sample_index"], start_frame - self.templates.shape[1], side="left")
end = np.searchsorted(self.spike_vector["sample_index"], end_frame + self.templates.shape[1], side="right")


for i in range(start, end):
spike = self.spike_vector[i]
Expand Down
3 changes: 2 additions & 1 deletion src/spikeinterface/curation/remove_duplicated_spikes.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def get_unit_spike_train(
if end_frame == None:
end_frame = spike_train[-1] if len(spike_train) > 0 else 0

start, end = np.searchsorted(spike_train, [start_frame, end_frame + 1], side="left")
start = np.searchsorted(spike_train, start_frame, side="left")
end = np.searchsorted(spike_train, end_frame, side="right")

return spike_train[start:end]

Expand Down
3 changes: 2 additions & 1 deletion src/spikeinterface/postprocessing/spike_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def get_data(self, outputs="concatenated"):
elif outputs == "by_unit":
locations_by_unit = []
for segment_index in range(self.waveform_extractor.get_num_segments()):
i0, i1 = np.searchsorted(self.spikes["segment_index"], [segment_index, segment_index + 1], side="left")
i0 = np.searchsorted(self.spikes["segment_index"], segment_index, side="left")
i1 = np.searchsorted(self.spikes["segment_index"], segment_index, side="right")
spikes = self.spikes[i0:i1]
locations = self._extension_data["spike_locations"][i0:i1]

Expand Down
5 changes: 3 additions & 2 deletions src/spikeinterface/sortingcomponents/motion_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ def interpolate_motion_on_traces(
**spatial_interpolation_kwargs,
)

i0, i1 = np.searchsorted(bin_inds, [bin_ind, bin_ind + 1], side="left")

i0 = np.searchsorted(bin_inds, bin_ind, side="left")
i1 = np.searchsorted(bin_inds, bin_ind, side="right")

# here we use a simple np.matmul even if dirft_kernel can be super sparse.
# because the speed for a sparse matmul is not so good when we disable multi threaad (due multi processing
# in ChunkRecordingExecutor)
Expand Down

0 comments on commit ef0d66e

Please sign in to comment.