Skip to content

Commit

Permalink
Merge branch 'main' into fix-drift-hybrid-serialiibility
Browse files Browse the repository at this point in the history
  • Loading branch information
alejoe91 authored Jul 4, 2024
2 parents 6501252 + 5b458ee commit f851029
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/actions/build-test-environment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ runs:
python -m pip install -U pip # Official recommended way
source ${{ github.workspace }}/test_env/bin/activate
pip install tabulate # This produces summaries at the end
pip install -e .[test,extractors,streaming_extractors,full]
pip install -e .[test,extractors,streaming_extractors,test_extractors,full]
shell: bash
- name: Force installation of latest dev from key-packages when running dev (not release)
run: |
Expand Down
15 changes: 8 additions & 7 deletions src/spikeinterface/sortingcomponents/peak_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,18 @@ def select_peaks(

selected_indices = select_peak_indices(peaks, method=method, seed=seed, **method_kwargs)
selected_peaks = peaks[selected_indices]
num_segments = len(np.unique(selected_peaks["segment_index"]))

if margin is not None:
to_keep = np.zeros(len(selected_peaks), dtype=bool)
offset = 0
for segment_index in range(recording.get_num_segments()):
duration = recording.get_num_frames(segment_index)
for segment_index in range(num_segments):
num_samples_in_segment = recording.get_num_samples(segment_index)
i0, i1 = np.searchsorted(selected_peaks["segment_index"], [segment_index, segment_index + 1])
while selected_peaks["sample_index"][i0] <= margin[0] + offset:
while selected_peaks["sample_index"][i0] <= margin[0]:
i0 += 1
while selected_peaks["sample_index"][i1 - 1] >= (duration - margin[1]) + offset:
while selected_peaks["sample_index"][i1 - 1] >= (num_samples_in_segment - margin[1]):
i1 -= 1
to_keep[i0:i1] = True
offset += duration
selected_indices = selected_indices[to_keep]
selected_peaks = peaks[selected_indices]

Expand Down Expand Up @@ -284,7 +283,9 @@ def select_peak_indices(peaks, method, seed, **method_kwargs):
)

selected_indices = np.concatenate(selected_indices)
selected_indices = selected_indices[np.argsort(peaks[selected_indices]["sample_index"])]
selected_indices = selected_indices[
np.lexsort((peaks[selected_indices]["sample_index"], peaks[selected_indices]["segment_index"]))
]
return selected_indices


Expand Down

0 comments on commit f851029

Please sign in to comment.