Coincidence detection/ artifact removal for tetrode data
Hi, I am trying to use KS4 to sort ~2h long recordings from a 16-tetrode drive (64 channels) from freely behaving animals. Since I’m only getting started, can someone check if the changes from the default settings make sense/ are not completely off? I only changed what was recommended for tetrodes, and I know to tweak I should attach Phy screenshots – this is only to make sure that I don’t start with fundamentally wrong settings. In short: Data is sampled at 32 kHz, I use 6s batches, no motion correction, CAR and sign inversion (that much I know about my data). Each tetrode has its own kcoords, I assumed 25um between contacts, and they are arranged horizontally (bonus-question: does the horizontal vs. vertical layout of the tetrodes make a difference for sorting? I mean beyond the non-determinism of KS…). I’ll attach the kilosort.log for my settings.
My main question is about artifact removal/ coincidence detection: I know that the data contains motion artifacts usually detected on multiple tetrodes. So far, when pre-processing data for manual sorting, I’d run a coincidence detection of threshold crossing events (/spikes), and if any are detected on more than let’s say 6 tetrodes at the same time (+- a few samples), these events are zeroed out.
Can something similar be achieved by KS4? I’ve read that using the artifact_threshold will zero out the entire batch, which is not what I’m looking for as I expect real spikes close to the motion artifacts. If not by KS4, would you recommended to do the coincidence detection before KS (zero out in the raw data) in order to possibly get better detection results? Or afterwards based on the spike_times.npy? In which case I wonder which other KS-output files need adjusting, and if the labels for Phy can be re-computed after artifacts removed? If any of this has been asked in another thread, a pointer would be much appreciated – I did not find anything similar.
Thanks a lot in advance!
It's possible some settings could be tweaked, but it's hard to say without some Phy screenshots and a screenshot of the data view in the KS4 GUI. Most likely you will need to remove the artifacts yourself prior to sorting, but if you'd like more input please upload some screenshots.
Hi Jacob, thanks for getting back at me, and sorry for the delay in my response. I think the coincidence-detected artifacts are not such a big deal after all -- I increased thresholds and now these artifacts make up between 1-2% of all detected spikes. See my question below regarding clear artifacts.
However, I am now a bit unsure if the thresholds I chose make sense for my data: since I have already manually sorted a few sessions, I have something to compare to. So from a few sessions I chose manually sorted units I trust and compared KS4 output with different thresholds to these trusted units and just evaluated how well it did find them. Across 3 sessions (and 35 units), the threshold pair that gave me the "best match" (i.e., closest to my manual sorting in terms of number of spikes, and least possible contamination) was Th_universal at 17 and Th_learned at 20. Do they make sense? I only found one issue of someone else using KS on tetrodes, where you suggested thresholds at 15 & 12.5, respectively; which is much lower than mine and also universal threshold seems to be always chosen higher than learned threshold... Any other parameters from my kilosort4.log that you would try tweaking?
I am attaching this time a few screenshots from phy together with a few specific comments/questions (already sorry if this is a bit chaotic)
-
The units in below screenshot look fine to me, however, they all contain some big artifacts (particularly the red one). Any way I can filter these out? I think that most if not all units will have these kinds of big amplitude artifacts.
-
I get a LOT of units with less than say 50 spikes: does this indicate something about the thresholds (/parameters) not chosen right, or should I not worry and just discard them. I should say that none of them look like proper units waveform-wise...
-
This and the next point is nothing general, but I am wondering again whether it's connected to my settings: in below screenshot I found that a cluster that shouldn't necessarily have been split (see Amplitude View and CCGs)
-
and here's one that I would have split (or did in manually sorting) to two -- maybe 3 -- clusters, see Amplitude and Feature View. Is this and above something I need to deal with case-by-case in phy, or are there some settings that can help?
-
I compared (by matching my trusted units) a horizontal vs. vertical probe layout, meaning that the tetrodes are all "at the same depth" and spaced apart horizontally on the x-coordinate, or different tetrodes all lie in one column and are spaced apart vertically along the y-coordinate. In principle, it should not matter since only the local geometry of the 4 channels of a tetrode changes between these two layouts, correct? (In both layouts the 4 channels of a tetrode are organized in a square with 25 um distance between them) Or does KS treat the x- and y-coordinates/ -distances between channels differently? In below screenshot you can see that most of the units are matching between the KS on the two "probes", but some are found differently.
5.5) Does the distance between channels, in my case 25um, matter a lot, or is it more about the geometry with other channels? As in, would anything significantly change if I went to 20um instead of 25um?
I thought this reply might also help anyone else using tetrodes, even though the focus is not on coincidence detection or artifact removal anymore. If you want me to close the issue and/or open a new one, let me know. And again, thanks a lot !! Cheers, Max
- There isn't a way to filter out artifacts like that through KS4. You will need to do something to clean up the data prior to sorting if you don't want those to show up. Those kinds of high-amplitude artifacts can also interfere with clustering if not removed.
- If they don't look like neurons, just ignore them. They're likely artifacts that are getting clustered together.
- Hard to say if those are the same unit or not. It's possible there was some drift, which KS4 can't really correct for with tetrode data. Regardless, there aren't any settings I would tweak based on that. An occasional incorrect merge/split is going to happen.
- Same as 3, I would handle those on a case-by-case basis unless it's happening for a large proportion of units.
- Does not matter. There will always be some noise in the result, which is probably what you're seeing. 5.5) Yes, the spacing matters and should generally be set to match the physical spacing between contacts (or left as the default value). That will control the number of templates used for spike detection. You can see the effect by checking the "True Aspect Ratio" and "Universal Templates" under the probe view in the KS4 GUI.
Thanks a lot for your help. I'll close the issue then.