cortex-lab / phy

phy: interactive visualization and manual spike sorting of large-scale ephys data
BSD 3-Clause "New" or "Revised" License
314 stars 157 forks source link

How is the 'amp' column in ClusteView calculated? #1269

Closed jacobpennington closed 5 months ago

jacobpennington commented 5 months ago

Hello,

I am trying to adjust Kilosort4's outputs so that the amplitudes in Phy are comparable to past versions. I understand the 'Amplitude' column in ClusterView is exported directly from Kilosort, and that per-spike amplitudes are exported in amplitudes.npy, but I'm having trouble figuring out where the values in the 'amp' column are coming from. I looked at the code referenced in #1248, but it's still unclear and I don't see the get_amplitudes_true method actually invoked anywhere except to re-format things for ALF (not sure what that is).

Would someone be able to point me to somewhere else in the code that this is being computed, or explain which part of get_amplitudes_true is relevant if that's the correct method? As in, given templates.npy and amplitudes.npy, how are those combined to get the values in 'amp'? I also noticed that changing the values in amplitudes.npy (multiplying them by 10, adding 7, or adding on a random array) doesn't change the values in 'amp,' so I guess I'm just confused in general as to how those are used.

Thanks!

jacobpennington commented 5 months ago

I figured this out myself after some more work, posting the answer here incase anyone else has the same question: 'amp' column values are just max - min of the corresponding unwhitened template. https://github.com/cortex-lab/phy/blob/8bf8cf751fcbd44210b3c5bbdba8c34a7b2cb1ce/phy/apps/base.py#L497