-
Notifications
You must be signed in to change notification settings - Fork 247
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
optional post-processing step for duplicate spike removal #234
Conversation
1. remove_ks2_duplicate_spikes - removes duplicate spikes resulting from multiple templates explaining variance from a single waveform
This reverts commit c4ed558.
optional (off by default) step for removing double-counted spikes
% OPTIONAL: remove double-counted spikes - solves issue in which individual spikes are assigned to multiple templates. | ||
% See issue 29: https://github.com/MouseLand/Kilosort2/issues/29 | ||
%rez = remove_ks2_duplicate_spikes(rez); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented out by default
@@ -0,0 +1,52 @@ | |||
function rez = remove_spikes(rez,remove_idx,label,varargin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function encapsulates the code for removing spikes from a "rez" structure, so that it can easily be shared by set_cutoff.m and remove_ks2_duplicated_spikes.m. It also adds a field to the rez structure called "removed" which saves the removed spikes and provides a reason why they were removed in postprocessing.
[ccbsort, iorig] = sortBatches2(ccb0); | ||
[ccbsort, iorig, xs] = sortBatches2(rez.ccb); | ||
rez.iorig = gather(iorig); | ||
rez.ccbsort = gather(ccbsort); | ||
|
||
% some mandatory diagnostic plots to understand drift in this dataset |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plot the 1D drift map
…avior was to cause harder to decipher errors down the line).
Great, thanks Adrian! |
optional post-processing step for duplicate spike removal Former-commit-id: d703473
I added a function "remove_ks2_duplicate_spikes" which takes in a "rez" structure during post-processing and removes spikes that are likely double-counted, based on their spatiotemporal overlap with other spikes. Specifically, it two spikes occur within less than X ms and belong to templates with peaks less than Y um apart, the spike belonging to the smaller-amplitude template is removed. X is 0.5ms by default, and Y is 100 um by default. We have implemented this in our kilosort master script for some time and I thought it may be useful for others. Right now, it's commented out so as not to disrupt the default behavior but could be uncommented to enable it (or in future enabled programmatically with a flag of some kind).
One other minor change in this PR is the addition of a 1D drift map to the figure illustrating drift in the recording. I find it a useful visual tool in addition to the distance matrices. It plots batch position on the 1D embedding performed already by ks2.