Skip to content

Fix noise level cache invalidation and sampling parameters - #4942

Open
emanueldellipaoli01-a11y wants to merge 2 commits into
SpikeInterface:mainfrom
emanueldellipaoli01-a11y:fix-noise-levels-cache
Open

emanueldellipaoli01-a11y wants to merge 2 commits into
SpikeInterface:mainfrom
emanueldellipaoli01-a11y:fix-noise-levels-cache

Conversation

@emanueldellipaoli01-a11y

@emanueldellipaoli01-a11y emanueldellipaoli01-a11y commented Nov 13, 2026 •

Copy link
Copy Markdown

This PR addresses #4928 by improving how noise levels are cached and reused.

The main idea is to keep track of the sampling parameters used to compute each noise-level estimate, so that cached values are only reused when they are compatible with the current request.

In particular, this PR:

  • Normalizes the sampling parameters before checking the cache, including default values and the conversion of chunk_duration to frames.
  • Stores the effective parameters in recording._noise_levels_params.
  • Reuses cached values when the sampling configuration matches. When seed=None is requested, an existing estimate can be reused regardless of the stored seed, as long as the chunk layout is compatible.
  • Preserves manually assigned noise-level properties and values loaded from saved recordings when the default sampling configuration is used.
  • Keeps the cache metadata consistent when noise-level properties are overwritten or deleted.
  • Invalidates scaled noise-level estimates when calibration properties such as gain_to_uV or offset_to_uV change.
  • Updates highpass_spatial_filter to obtain RMS values through get_noise_levels() instead of accessing the cached property directly.

Regression tests have been added for the caching behavior, parameter compatibility, seed handling, calibration changes, and the high-pass spatial filter integration.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants