Skip to content

Valid unit periods extension#4299

Merged
alejoe91 merged 118 commits intoSpikeInterface:mainfrom
m-beau:goodtimes
Jan 29, 2026
Merged

Valid unit periods extension#4299
alejoe91 merged 118 commits intoSpikeInterface:mainfrom
m-beau:goodtimes

Conversation

@m-beau
Copy link
Contributor

@m-beau m-beau commented Jan 6, 2026

Implements #4294

  • Add widget

@alejoe91 alejoe91 changed the title good times extension Good times extension Jan 6, 2026
@alejoe91 alejoe91 added the postprocessing Related to postprocessing module label Jan 6, 2026
@alejoe91
Copy link
Member

alejoe91 commented Jan 7, 2026

Depends on #4302


def _merge_extension_data(
self, merge_unit_groups, new_unit_ids, new_sorting_analyzer, censor_ms=None, verbose=False, **job_kwargs
):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add here a comment for the strategy of merging period so that the code will be easier to read.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment in the user defined section. I think it's ok since no-one will ever check the docstring for this

job_name = f"computing false positives and negatives"

# parallel
with ProcessPoolExecutor(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be carrfull with th use of ProcessPoolExecutor.
on window this imply spawn and so datta duplication here this will be sorting + amplitudes duplicated
in case of a spwan

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then we should make a base executor. We have the same issue in other extensions...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's do it in a separate PR

@alejoe91
Copy link
Member

Revised, @samuelgarcia @chrishalcrow can you take a final look?

We can discuss on the merge strategy with user defined periods, but I think union is a good choice (see my comment)

)
)

user_defined_periods = cast_periods_to_unit_period_dtype(user_defined_periods)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

niiiice

@samuelgarcia
Copy link
Member

Impressive and complicated PR!
Congratulations.
This is OK on my side.

I push some test for the remapping low level code.

@alejoe91 alejoe91 merged commit 6f0ed09 into SpikeInterface:main Jan 29, 2026
15 checks passed
spike waveform. In case of spatio-temporal collisions, a multi-linear fit is performed using the templates of all units
involved in the collision.

**NOTE:** computing amplitude scalings is highly recommended before calculating amplitude-based quality metrics, such as
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this so?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because they are much more robust. Spike amplitudes only sample the voltage value on the max channel, amplitude scalings use sparse templates and fit them spike-by-spike, also handling collisions. Downside is it's slower to compute

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alejoe91 Thanks for the explanation.

Currently, the documentation is unclear. Both spike_amplitudes and amplitude_scalings have the same note but users won't know whether they need to compute both or only one of them, which one is the recommended one (if any) or what happens if you compute both.
Screenshot from 2026-02-27 21-54-33

Currently, spike_amplitudes is the default everywhere: amplitude_cutoff, noise cutoff will use spike_amplitudes by default even if amplitude_scalings is available; ampitude_cv receives the extension as argument (default is spike_amplitudes) and amplitude median does not even consider amplitude_scalings.

Maybe the note should just say, one of the two is required or just recommend one of them. I particularly prefer spike_amplitudes, even if noisier, it is more understandable and a lot less margin for error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

postprocessing Related to postprocessing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants