Skip to content

Map nn_isolation and nn_noise_overlap to nn_advanced when loading old quality metrics - #4975

Merged
alejoe91 merged 1 commit into
SpikeInterface:mainfrom
grahamfindlay:nn-metrics-legacy-names
Dec 2, 2026
Merged

alejoe91 merged 1 commit into
SpikeInterface:mainfrom
grahamfindlay:nn-metrics-legacy-names

Conversation

@grahamfindlay

Copy link
Copy Markdown
Collaborator

This follows from discussion with @chrishalcrow in #4927

SortingAnalyzers and WaveformExtractor folders saved before 0.104 list nn_isolation and nn_noise_overlap as metric names. Nowadays these metrics are merged into nn_advanced (which always computes both isolation and noise overlap, whereas previously it was possible that only 1 had been computed). So converting a WaveformExtractor folder saved before 0.104 raises a ValueError, and merging units on an analyzer saved before 0.104 fails.

This maps the names (nn_isolation and nn_noise_overlap to nn_advanced) on load (as is already done for isolation_distance and l_ratio).

If both legacy metrics were computed, nn_advanced takes nn_isolation's parameters, otherwise it takes the parameters of whichever legacy metric was used.

If both were computed with different parameters, nn_noise_overlap's parameters are lost, and a warning is raised. Unfortunately there is no way around losing one set, because nn_advanced has a single set of parameters for both metrics. The nn_noise_overlap values already stored are unchanged, but the parameters recorded for them are now nn_isolation's, and nn_noise_overlap values recomputed later (e.g. for units created by a merge) use nn_isolation's parameters. This should be rare. The two legacy metrics had the same default parameters in every release that had them, so they will differ only if someone set them separately for each metric, which I think would be rather odd.

quality metrics

Analyzers and WaveformExtractor folders saved before 0.104 list
nn_isolation and nn_noise_overlap as metric names. Nowadays these
metrics are merged into nn_advanced (which always computes both
isolation and noise overlap, whereas previously it was possible that
only 1 had been computed). So converting a WaveformExtractor folder
saved before 0.104 raises a ValueError, and merging units on an analyzer
saved before 0.104 fails.

This maps the names (nn_isolation and nn_noise_overlap to nn_advanced)
on load (as is already done for isolation_distance and l_ratio).

If both legacy metrics were computed, nn_advanced takes nn_isolation's
parameters, otherwise it takes the parameters of whichever legacy metric
was used.

If both were computed with different parameters, nn_noise_overlap's
parameters are lost, and a warning is raised. There is no way around
losing one set: nn_advanced has a single set of parameters for both
metrics. The nn_noise_overlap values already stored are unchanged, but
the parameters recorded for them are now nn_isolation's, and
nn_noise_overlap values recomputed later (e.g. for units created by a
merge) use nn_isolation's parameters.

This should be rare. The two legacy metrics had the same default
parameters in every release that had them, so they differ only if
someone set them separately for each metric.
@grahamfindlay grahamfindlay added bug Something isn't working metrics Related to metrics module labels Dec 2, 2026
@alejoe91
alejoe91 merged commit 2f66196 into SpikeInterface:main Dec 2, 2026
19 checks passed
@chrishalcrow

Copy link
Copy Markdown
Member

Thanks @grahamfindlay !

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.

3 participants