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

Best channel does not have the largest amplitude for its waveform template? #1187

Open surygeng opened 1 year ago

surygeng commented 1 year ago

Hi, I am using phy to curate Kilosort's output. I noticed that the best channel in cluster_info.tsv doesn't always match the channel that has the largest amplitude for its template.

In this example data, the templates.npy has a shape of (214, 82, 955). To my understanding, it is (cluster_id, sample_points, channel_id). When I read out all of the 32 templates for cluster 211 from this numpy file, and find the channel that has the largest amplitude, the result is 434. But, in the cluster_info.tsv, the best channel for cluster 211 is 279.

My way of finding the best channel is using np.argmax(np.ptp(templates[cid], axis=0))to get the channel index that has the max peak to peak value in the templates (cid is the cluster id. I found the amplitudes are 0.26653442 for channel 434 and 0.22730131 for channel 279. Channel 434 has a larger amplitude. Also, the amplitude that has been written into the tsv for channel 279 is 0.23039028. No split or merge to this cluster.

I am doing anything wrong or is this a bug in phy? I need a correct channel location for my experiment data. I've attached screenshots of cluster_info.tsv (figure 1) and the 32 templates in cluster 211 (figure 2). Also attached a csv of the templates. Please let me know if you have any questions or comments.

Thank you!

Screenshot from 2022-12-12 18-12-48 Screenshot from 2022-12-12 18-09-29 cluster211_templates.csv