Skip to content

[WIP] IBL raw data quality metrics - #4823

Draft
JoeZiminski wants to merge 7 commits into
SpikeInterface:mainfrom
JoeZiminski:raw-data-quality-metrics
Draft

JoeZiminski wants to merge 7 commits into
SpikeInterface:mainfrom
JoeZiminski:raw-data-quality-metrics

Conversation

@JoeZiminski

@JoeZiminski JoeZiminski commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

This PR implements some (but not all) of the IBL's raw data quality metrics. According to the IBL's white paper (version two) their quality metrics are:

  1. Over 1s chunks every 300 seconds, compute:
  • Power spectral density (Welch) (num_channel x num_freqs(
  • RMS (num_channel x 1)

then take the median RMS across all of the chunks (giving noise estimate per-channel) and the 10-90 quantile across channels (giving spread of noise across channels). They also average all of the Welch PSDs into a single representattive. They do this across AP and LFP, before and after preprocessing.

They also compute a rolling RMS over consecutive 3s chunks for the recording types. I'm not sure rolling is the best word as the chunks don't overlap but I can't think of anything else at the moment.

They also do a quick spike detection using a threshold method. Here I skipped this, as it is not simple AFAICT to have a static threshold across different recordings (rather than the threshold being a multiple of the noise) and it is not easy to find such a threshold across recordings. Instead i would be better for a general-purpose DataQualityMetrics module to compute various metrics after the pipeline has run, using spikes from the sorter.

Their metrics are summarized in:

image

This PR computes the median RMS, 10-90 quantiles and produces plots for the PSD and rolling RMS.

image

This is a draft implementation that does not contain tests nor a proper plotting yet, it mainly serves as a starting point for discussions. Currently if I was a user I would not be sure how to interpret these metrics and so I'll open an issue which discusses some other possible metrics.

Some technical things for discussion:

  • Currently we demean the traces before RMS calculation. There are a few IBL QC implementations (to_ibl.py, ephysqc (which I only just found and need to compare), and [ibl-neuropixels raw_metrics). The first two do not demean before RMS while the third does. Intuitively for comparing raw vs. preprocessed data it makes sense to remove the mean, overwise the raw RMS is dominated by the mean which is removed after filtering the preprocessed data. However need to discuss as I'm not sure.
  • The IBL implementation takes Welch per sample, and averages. This implementation takes windowed periodogram per chunk, then averages across chunks. At first I thought this was a better tradeoff between noise and bin resolution, but am not not so sure, need o look into further.
  • Just a reminder for myself, I think the to_ibl.py implementation has a bug on Welch's, it takes random samples and concatenates then computes welch over with a segment size the size of the randomly sampled chunks,

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.

1 participant