Skip to content

minAmplitude not applied when any rawAmplitude is NaN (possible logic bug in quality_matrices.py) #369

@ofirka-wiz

Description

@ofirka-wiz

First, thanks for the great toolbox 🙏. I think I may have found a small logic issue in the amplitude/SNR gating for MUA vs GOOD units.

In quality_matrices.py, the MUA mask adds the raw amplitude and SNR checks only if all units have non-NaN rawAmplitude:

quality_matrices.py

if param["extractRaw"] and np.all(~np.isnan(quality_metrics['rawAmplitude'])):
mua_mask |= np.isnan(unit_type) & (
(quality_metrics["rawAmplitude"] < param["minAmplitude"]) |
(quality_metrics["signalToNoiseRatio"] < param["minSNR"])
)

Because this uses np.all(...), if any one unit has rawAmplitude == NaN, the whole block is skipped for every unit. In my dataset, I had one NaN rawAmplitude, and the amplitude rule wasn’t applied at all, so I ended up with 15 units labeled GOOD even though their rawAmplitude was below my minAmplitude = 20.

Could you please confirm if this is the intended behavior, or if the condition was meant to allow per-unit checks even when some amplitudes are missing?

Thank you for checking this!

System information

Recording probes: [ Neuropixels 2.0 4 -shank]
Recording software: [SpikeGLX]
OS: [Windows]
Python

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions