`rp_contamination` and `isi_violations_ratio` should report an upper bound like `sliding_rp_violation` does

Ouverte
#5,011 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
55/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
Active
Stack technique
python
Domaine
data

Piste de recherche

Start with BaseMetricExtension._run, then locate the implementations of rp_violation, isi_violation, and sliding_rp_violation to reuse the latter's confidence-based upper-bound calculation. Add the two upper-bound columns and their confidence parameters, and make metric copying skip or fill absent saved columns with NaN while warning. Done means both metrics return the new columns and analyzers saved by older versions load without a KeyError.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

The rp_violation metric computes two values/columns: rp_contamination and rp_violations.
The isi_violation metric computes isi_violations_ratio and isi_violations_count.

I am finding units with low values of rp_contamination and isi_violations_ratio that shouldn't be passing QC checks, because they don't have enough spikes to actually rule out contamination[^1]. sliding_rp_violation already handles this nicely by reporting the highest contamination (at a given confidence level, 90% by default) that the data can't rule out. An "upper bound" on possible contamination, so to speak. I think that the rp_violation and isi_violation metrics should get this, too.

Specifically, I propose having rp_violation compute a new third value/column rp_contamination_upper_bound, and having isi_violation compute a new third value/column isi_violations_ratio_upper_bound, obtained using the same method as sliding_rp_violation. They would get a new confidence parameter (0.9 by default, to match sliding_rp_violation).

There is only 1 non-trivial implementation detail that I anticipate: Adding a column to an existing metric currently breaks analyzers saved with older versions of SpikeInterface, because when more metrics are computed BaseMetricExtension._run copies the previously computed metrics into the new table column by column, using the columns each metric has now. When an expected column is not in the saved table, you get a KeyError (as in #5009). I suggest that a copy tolerate a missing column. Just copy the columns that are there, fill a missing one with NaN, and warn that the metric was computed by an older version and needs recomputing to fill the missing column. Or you could recompute automatically, but if the extensions it needs have been deleted then you're in a pickle -- so I would avoid that. Small gotcha is that filling with NaN means the column is a float, even if it will in the future (after recompute) be e.g. an integer. I don't see how/why that would be an issue.

So, in summary, I am proposing a PR with two parts (or two PRs, if preferred):

  1. Missing-column handling.
  2. Adding rp_contamination_upper_bound and isi_violations_ratio_upper_bound columns to their respective metrics.

Thoughts?

@alejoe91 @samuelgarcia @chrishalcrow @JoeZiminski @h-mayorquin

[^1]: Violations are rare, so their count varies a lot by chance, and a heavily contaminated unit can easily appear to have no violations.

Langage dominant
Python
Étoiles
883
Forks
291
Merge moyen
3 j 6 h
PR mergées (30 j)
39

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de SpikeInterface/spikeinterface

Toutes les issues de SpikeInterface/spikeinterface

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.