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

BUG: filtered signal and prediction not aligned properly in v3.0.1 GUI #623

Closed
teristam opened this issue Mar 19, 2024 · 8 comments
Closed
Assignees

Comments

@teristam
Copy link

Describe the issue:

After upgrading to v3.0.1, the filtered signal and prediction are not aligned to each other in time. The problem goes away when downgraded back to v3.0

image

Reproduce the bug:

No response

Error message:

No response

Version information:

kilosort: v3.0
Matlab: R2021a

Context for the issue:

No response

Experiment information:

Neuropixel 1.0

@marius10p marius10p self-assigned this Mar 19, 2024
@marius10p
Copy link
Contributor

I'll take a look when I have time. 3.0.1 fixes the spike holes bug. Hopefully it did not introduce a time alignment bug.

Could you please double check if this is also a problem for release 2.5.1? The same modification was made there.

@teristam
Copy link
Author

Hi,

I think I can also observe a similar thing in v2.5.1:

image

@teristam
Copy link
Author

Just some more updates on the investigation. I am using the first 100s of a recording for testing. The first 2s of data seem to look fine, but the alignment problem starts to appear after the 2.3s point.

@marius10p
Copy link
Contributor

Yeah, there is a difference in how the first batch is treated for the buffer offsets. What I have to determine is if the spike times are correct (and the GUI is wrong) or viceversa. In practical terms it should be a difference of 2-3ms.

@zm711
Copy link

zm711 commented Mar 20, 2024

@alejoe91, it looks like this our issue too. I'm just going to copy your message below (from #594) so we can work off this thread instead

@marius10p

zm711 and I noticed that the bug fix branches (at least for KS2.5) is fixing the spike holes, but there seem to be a misalignment with the spike times, so that the extracted waveforms don't look right. See this example: the auto/cross correlograms (bottom right) look correct, but the waveforms are just noise.

Any idea where the misalignment could take place?

@alejoe91
Copy link

I think that the spike times are wrong since the waveforms extracted externally are also wrong. So I suppose that rules out this being a GUI problem

@marius10p
Copy link
Contributor

I have fixed both bugs that were causing the spike holes problem. I think the spike times are correct now, can you please check it in version 3.0.2 (new release)?

@teristam
Copy link
Author

teristam commented Apr 16, 2024

I have fixed both bugs that were causing the spike holes problem. I think the spike times are correct now, can you please check it in version 3.0.2 (new release)?

Hello, I haven't tested the new changes in kilosort3 yet because I am trying to get kilosort4 to work. However, I noticed even in the latest version of kilosort4 (4.0.4), the spike time does not seem to align with the index from the BinaryFiltered file (bfile). I assume the index in the bfile corresponds to the actual data index in the original data?

I used the following code to extract spikes directly from the bfile

clu_id = 3
s = []

chan_best = (templates**2).sum(axis=1).argmax(axis=-1)
chan_best = chan_map[chan_best]

cb = chan_best[clu_id]

spk_t = st[clu==clu_id]

for i in range(300):
    t = spk_t[i] 
    s.append(bfile[(t-bfile.nt//2):(t+bfile.nt//2+1),:])
s = np.stack(s)

I noticed the extracted waveforms are mixed:

image

but when I subtract bfile.nt from the spike time, it works:
image

And then spike time from the 2nd batch onward don't seem to need this time shift:

image

Since the spike time is extremely important for analysis, may be more rigorous tests should be implemented?

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

No branches or pull requests

5 participants