Kilosort icon indicating copy to clipboard operation
Kilosort copied to clipboard

waveform duration, minimum firing rate and high pass filter cutoff

Open dmitriivasilev opened this issue 1 year ago • 4 comments

Feature you'd like to see:

Hi there, how can I modify the three parameters in the heading - waveform duration for unit detection, minimum firing rate and high pass filter cutoff?

Additional Context

We are using custom made probes and record brain stem neurons. These cells sometimes have a slower firing rate (lower than 0.5 ms) and some wider waveforms. Also, there are no clear indication of where to find the high pass filter cut off.

Even though I understand that default values are default from experience, I'd like to be able to modify these settings or at least clearly see them.

dmitriivasilev avatar Jun 24 '24 09:06 dmitriivasilev

Waveform duration is determined by nt. The default value of 61 (number of bins) corresponds to around 2ms for a 30 kHz sampling rate. High pass filter cutoff is currently hard-coded at 300 Hz, but I'll make a note to add it as configurable parameter. I'm not aware of any explicit minimum firing rate, but I'll ask @marius10p how that might be addressed.

jacobpennington avatar Jun 24 '24 17:06 jacobpennington

I confirmed with Marius that there is not an explicit firing rate requirement anywhere in the code. There is however an implicit requirement that "good" units have a minimum number of spikes, which comes from a combination of several variables. The best way to address that for special cases like this would be to do your own post-processing on the sorting results to label cells as good or not and replace KSLabel.npy. I put a tutorial notebook with more explanation for that on the todo list.

jacobpennington avatar Jun 25 '24 23:06 jacobpennington

Hey @jacobpennington , thanks for the replies. I think you've meant 2 ms and not 2 s in your first comment. I have found the 300 high pass in the source code, thankfully that is the value we would like to use ;) For the firing rate, I have done some spike sorting and I see units with very low spike rate as well in the output of ks4, so this seems to work good.

dmitriivasilev avatar Jun 26 '24 08:06 dmitriivasilev

I think to be future proof we should close this suggestion it when the high pass filter is implemented as a configurable parameter.

dmitriivasilev avatar Jun 26 '24 08:06 dmitriivasilev

@jacobpennington Just stumbled upon this discussion and I was wondering if it was fixed. I saw in the codebase get_fwav doing some hardcoded 300Hz highpass filtering but I don't see it being used anywhere. So I'm hoping it was fixed and this is a function to be deleted maybe?

https://github.com/MouseLand/Kilosort/blob/6684aca018b80e6ba8f79cf8fd1084c7defaa8b8/kilosort/preprocessing.py#L72-L94

kushaangupta avatar May 26 '25 23:05 kushaangupta

Yes, this has been fixed. get_fwav is unused, look at get_highpass_filter.

jacobpennington avatar Jun 10 '25 19:06 jacobpennington