MouseLand / Kilosort

Fast spike sorting with drift correction for up to a thousand channels
https://kilosort.readthedocs.io/en/latest/
GNU General Public License v3.0
469 stars 245 forks source link

Spikes not detected Kilosort 2 and 3 - Tetrode data #505

Closed Zoe0793 closed 8 months ago

Zoe0793 commented 2 years ago

Hi, I am trying to sort tetrode data using Kilosort 3 without drift correction but unfortunately lots of spikes, of average amplitude, are not being detected. I also tried with Kilosort 2 but had the same problem. So far I have tried to alter the sd threshold, however this did not help. With the default -6 threshold I am missing spikes but also having lots of clusters of low amp noise. Finally, at least on phy, the highlighted spikes in trace view do not occupy all four channels in the defined k-coord, I wonder if this reflects that the spike sorting is not using all four channels to make the clusters, or perhaps this is just a visual thing in phy.

In case it helps, my xcoords are [30 30 30 30, 60 60 60 60, ... , 960 960 960] and y coords are all split by 10. This mapping was mainly chosen for viewing purposes in phy.

Any advice on how to improve the spike detection will be greatly appreciated, Thanks, Zoe Atherton

Screen shot displaying KS3 data, bottom right corner of trace view has many missed spikes: Screenshot 2022-06-08 102019

Screen shot displaying same data in KS2 (bottom third of trace view shows multiple missed spikes):

ScreenshotKS2

Zoe0793 commented 2 years ago

The second screenshot there is incorrect, here it is: ScreenshotKS2

DanEgert commented 2 years ago

I have a similar issue when sorting tetrodes in KS3, any clue how to go about this? I tried different geometry settings (each tetrode has the same x or y coordinates, all coordinates close or the dimension coding for different tetrodes is ~1000x larger than the dimension coding for different channels on the same tetrode, eg [1 1000] [2 1000] [3 1000] [4 1000] [1 2000] ...). The same sort config worked fine for high density probes similar to neuropixels.

Is there maybe a problem if the waveform doesn't show across many channels, in that templates consist of a minimum number of channels and the matching score will always be low and close to noise levels?

Zoe0793 commented 2 years ago

Hey Dan, I also tried different channel maps, if I remember correctly I got many more clusters when I had the tetrodes separated by 1000 compared to <100, but still lots of noisy clusters. Have you also tried KS2? I had better results with this. I will try again to alter more parameters and let you know if anything improves. I am not sure whether there is a minimum number of channels for templates or not... templates should stick within the k-coord at least so probably this is governed by user input.

Zoe0793 commented 2 years ago

Hi, I have changed some of the parameters and I am picking up a lot more spikes. I am still working on optimising it and changed multiple factors so not sure what weighted most towards the change in result. I changed ops.sigma mask to 15, as my tetrodes are separated by 30 in the channel map this may prevent detected templates in neighbouring tetrodes changing the residual variance. I also reduced ops.sig to 10 in case this was contributing to some interference between spiking across tetrodes. I reduced the sd to -5, but I have tried changing this alone and it didnt do anything before. ops.Tr I put to [ 9 5 ], but will try [10 4] also which was the default in KS2, where I was getting better results. Finally, I put ops.lam to 0. As ops.Th is a key parameter, this probably made a key difference, I will work on increasing the different thresholds but this set-up picked up lots of missed spikes from before.

marius10p commented 2 years ago

hi both, I would recommend KS2 for tetrodes. KS2.5 and KS3 require a known geometry to do the drift correction, and they will probably alter the data in unpredictable ways. Starting from KS2, you can play around with the parameters (thresholds) to get more/less spikes.

If you know that you don't have drift, i.e. it's a very stable chronic prep, then you can disable drift correction and try KS3.

Zoe0793 commented 2 years ago

Hi Marius, thanks for your reply, I have only implemented KS3 without drift correction so far. Starting with KS2, I have lowered threshold parameters but still it is not detecting clear, high snr spikes on an otherwise quiet tetrode, e.g. below (see chan 106). Further reductions does not pick up these spikes but complicates the clusters more (eg.2 below). Do you have another suggestion? Thank-you for your time.

image

image