-
Notifications
You must be signed in to change notification settings - Fork 222
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
Batch buffer overlap error causing autocorrelogram peaks & double counted spikes ( ops.ntbuff ) #219
Comments
This is likely related to my problem here: |
hi @czuba, sorry I missed this. Why are you trying to change ntbuff? There is no telling what could happen. It serves as buffer in two different places in fact, and it's a little tricky to make sense of it. |
Hi @marius10p, |
Hey @marius10p, @biomath, I too fell into the head-scratching hole of trying recreate the filtered .dat temp file (both for understanding how it was being sampled, and to weave in a faster memmapped read). More background & examplesTesting a longer Disabling batch reordering & optimizing a few parameters (incl. 10 sec batches) helped reduce the intense stuttering, but this example unit was still getting chopped up into a set of bizarrely interdigitated units: Both of these examples also had really strong CCG peaks, which I suspect is due to buffer segments that are not getting fully trimmed/accounted for during the actual spike detection pass. Since the default After reverting to the standard If the above interpretation of I'll split some of the above into a separate "How I tuned parameters for Uprobe recordings" post. In brief, the key parameter adjustments for Uprobe stereotrode recordings seemed to be:
I still see a handful of nonsensical unit dropouts & splits, but they're far fewer and considerably more manageable than the extreme batch-wise stuttering apparent in my first example (see also #60 & #63 ). Overall, I still don't understand why I'm seeing sooo much of this temporal stuttering artifact...it obviously isn't affecting everyone (at least not to this degree), otherwise it'd be 'issue no.1' across-the-board, but the root of it does seem to crop up in various other issues/forms (e.g. #175 "Sudden change of the template over consecutive batches"). |
Bug in ops.ntbuff implementation
It appears the batch buffer count (
ops.ntbuff
) is getting improperly applied/trimmed somewhere, causing batches to overlap in time (either in fread content, or assignment to st3).Simple test case
Adjust advanced parameters in the gui to increase .ntbuff by a large amount (e.g. ntbuff==64*300), then use Phy to examine autocorrelogram (ACG) peaks in the results to results using the default (ntbuff==64).
The following example code will retrieve a pointer to the GUI, increase the buffer length
.ntbuff
, and adjust the.NT
accordingly (default config states special constraints on increments and value relative to.ntbuff
), then apply updated settings to the ksGUI object:!NOTE:!You'll need to run this on a freshly Reset GUI instance, and be sure these settings have been applied prior to Preprocessing....multiple copies/sources of the
ops
structure exist after either Preprocess or Spikesort stages have been initiated in the GUI, and intermediate-stage changes to ks.ops do not [reliably] to propagate.It seems like there are multiple locations along the processing stream where this hiccup might be occurring, so I don't have a ready-made fix to create a PR.
trackAndSort.m
, line 182 seems like a possible candidate. To my eye, it looks to be applying an.ntbuff
offset to data that was read based on.NT
-spaced samples. But that would seem to be a mismatch on the indexing side of things, rather than an overlapping readout type error (...or I may just be misreading that .ntbuff application all together)Background
I've been working to fix/reduce the occurrence of temporally stuttered clusters in our Kilosort2 outputs using 32 channel linear array recordings (Plexon uProbes: stereo geometry, 16 stereo-pairs, 50 µm within pairs [x], 100 µm between pairs [y]).
Because our recordings have significantly fewer channels/samples (relative to neuropixels) within a given batch, I was hoping that increasing the buffer might help prevent whatever idiosyncrasies Kilosort seemed to be stumbling over between batches.
Buffer adjustments don't seem to have been a magic bullet so far (disabling batch reordering has helped the most, but there's more to be done...), but this bug is something that would affect all Kilosort users' results, so it seems like something worth flagging independent of our particular application issues.
Thanks!
The text was updated successfully, but these errors were encountered: