Skip to content

Count overlapping periods once in compute_total_samples_per_unit - #4941

Open
grahamfindlay wants to merge 1 commit into
SpikeInterface:mainfrom
grahamfindlay:periods-overlap-durations
Open

grahamfindlay wants to merge 1 commit into
SpikeInterface:mainfrom
grahamfindlay:periods-overlap-durations

Conversation

@grahamfindlay

Copy link
Copy Markdown
Collaborator

If a unit's periods overlap, compute_total_samples_per_unit double-counts the overlapping samples.
Incorrect duration estimates obtained this way were being used by firing_rate, presence_ratio, isi_violation, rp_violation, sliding_rp_violation, firing_range and amplitude_cv.

For example, with respect to firing-rate: Even though selecting the unit's spikes using overlapping periods with select_sorting_periods_mask correctly counts each spike once, the duration estimate obtained using those periods is wrong, so the firing rates returned are too low.

Simple fix is to use the union of each unit's periods in each segment, just like selecting its spikes already does.

@grahamfindlay grahamfindlay added bug Something isn't working metrics Related to metrics module labels Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working metrics Related to metrics module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant