Report unevaluable clusters as fully contaminated, not ContamPct 0 - #1045
Open
cindykrafft wants to merge 1 commit into
Open
Report unevaluable clusters as fully contaminated, not ContamPct 0#1045cindykrafft wants to merge 1 commit into
cindykrafft wants to merge 1 commit into
Conversation
CCG.refract initialized est_contam_rate (R12) to zeros and only computed it for clusters with more than 10 spikes and a nonzero time span. Clusters below that floor were therefore exported by io.save_to_phy with ContamPct = 0.0 - the best possible score - indistinguishable from a genuinely clean unit. Any downstream selection of the form 'ContamPct < x' without an additional minimum-spike-count criterion silently admits every such cluster. Initialize R12 to ones instead, so unevaluable clusters export as ContamPct = 100. This restores the Kilosort 2.5/3 convention (set_cutoff.m defaulted est_contam_rate to 1). is_refractory is unchanged (such clusters were already labeled mua). Demonstration on kilosort 4.1.7: a uniform-Poisson unit with 5000 spikes exports ContamPct 93.9 while an 8-spike junk cluster exports 0.0; with this change the junk cluster exports 100.0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012d2sJAD5EUp4GqAStqoBX7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1044
CCG.refractinitializedR12(est_contam_rate) to zeros and only computed it for clusters with more than 10 spikes and a nonzero time span, so such clusters were exported byio.save_to_phywith ContamPct = 0.0 — the best possible score. Downstream selections of the form "ContamPct < x" without a minimum-spike-count criterion silently admit every such cluster.This PR initializes
R12to ones so unevaluable clusters export as ContamPct = 100, matching the Kilosort 2.5/3 convention (set_cutoff.mdefaultedest_contam_rateto 1).is_refractoryis unchanged (these clusters were already labeledmua).Verification on 4.1.7 + this patch: a 5000-spike uniform-Poisson unit exports ContamPct 93.9 (unchanged), an 8-spike junk cluster exports 100.0 (previously 0.0). If you would rather export NaN for "not evaluated", I am happy to change the default — the important part is that it not be 0.
Reproduction script: https://github.com/cindykrafft/research-software-audit/blob/main/audits/kilosort/verify/kl2_contampct.py
🤖 Generated with Claude Code
https://claude.ai/code/session_012d2sJAD5EUp4GqAStqoBX7