Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about spike detection threshold #59

Closed
Dario55 opened this issue May 6, 2019 · 5 comments · Fixed by #595
Closed

Question about spike detection threshold #59

Dario55 opened this issue May 6, 2019 · 5 comments · Fixed by #595

Comments

@Dario55
Copy link

Dario55 commented May 6, 2019

Hello,

I am following up here a discussion which started during the recent Neuropixel 2019 course. In the course it have been explained that, to set spike detection threshold, we should use the parameter ops.Th = [10 4]. However, I have seen in the config file that there is also another parameter called ops.spkTh = -6, which I thought defines the spike detection threshold in unit of std.

Could you please explain what each of this is doing, how they interact and with which ones we should play, for example, if we want to detect small amplitude spikes?

Thank you,
Best,
Dario

@nsteinme
Copy link
Collaborator

nsteinme commented May 7, 2019

Hi Dario - see this page (https://github.com/MouseLand/Kilosort2/wiki/2.-How-it-all-works) at the bottom under 'threshold detection' for a more detailed description of ops.Th. The other parameter ops.spkTh is used in initialization, I believe, and shouldn't make a big difference to results.

@Sepidak
Copy link

Sepidak commented May 8, 2019

Hi Nick, does this mean that for detecting smaller spikes we should only lower "4" in the default ops.Th = [10 4]?

@Dario55
Copy link
Author

Dario55 commented May 8, 2019

Hi Nick, thank you for your reply.
Sorry but I am a bit confused now. In the wiki is stated:
A)1) Data preprocessing and channel selection.
First we determine which channels contain significant numbers of negative threshold crossings (default 0.1Hz).

Is the threshold used here ops.Th(1) or ops.spkTh?

B)Threshold detection: finally, we found that some neurons at the noise floor can benefit from adaptive setting of the threshold for each neuron. We start this procedure with ops.Th(1), and independently for each neuron lower the threshold in 0.5 decrements, as long as the number of refractory violations in the autocorrelogram does not increase beyond the acceptable quality threshold (of 20% estimated contamination). For this step to work well, ops.Th(2) used in the final pass should be relatively small, so that all potential spikes are collected.

Here the wiki says that ops.Th(1) and (2) are applied to each neuron, not channel, meaning that you have already perform the spike sorting I guess. In order to do that however, you'd need to have already detected the spikes to run the clustering and identify the neurons. So what threshold was use initially?

Could you please clarify the two points above?

Thank you

Dario

@marius10p
Copy link
Contributor

@Sepidak, if you don't detect a template in the detection phase, it won't help to lower the threshold for the final extraction phase. So I would try reducing ops.Th(1) first. If you find that your clusters are getting cut off on the low side, then further lower ops.Th(2), but be weary of hitting the noise floor and suddenly getting a lot of contamination.

@Dario55 A) that is ops.spkTh, which as Nick points out is used in a few of the preprocessing steps.
B) First, the wiki excerpt you quote is for the very final adaptive threshold step. That gets set adaptively per neuron indeed and is meant to reject contamination from below, from the noise floor or other neurons. At this stage, all the spikes have already been extracted and clustered. I do want to point out that Kilosort (1 or 2) does not work by pre-detecting spikes as threshold crossings and then clustering. The two steps are done together as one integrated algorithm (see https://www.biorxiv.org/content/10.1101/061481v1) .

@marius10p
Copy link
Contributor

Closed from inactivity,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants