MouseLand / Kilosort

Fast spike sorting with drift correction for up to a thousand channels
https://kilosort.readthedocs.io/en/latest/
GNU General Public License v3.0
474 stars 247 forks source link

BUG: Kilosort3 Phy output has a wrong map if chanMap is not the default value #762

Closed Jialiang-Lu closed 1 month ago

Jialiang-Lu commented 2 months ago

Describe the issue:

The output of Kilosort3 has a wrong channel_map.npy if the chanMap parameter is not the default 1:NChan.

The issue comes from these two lines: https://github.com/MouseLand/Kilosort/blob/c43f52452e474024a75ffed4152bce1ebede4eed/utils/rezToPhy2.m#L152-L153

I don't know why line 152 got commented. Uncomment this line and comment line 153 fixes the issue.

Reproduce the bug:

For example, for a Neuropixel probe, set

ops.chanMap = 384:-1:1;

Error message:

Open the result in Phy, and you would notice that the waveform view shows the wrong waveform for all units, because the channel map is wrong.

Version information:

Kilosort3 commit c43f524

marius10p commented 2 months ago

Hello, we are not really supporting Kilosort3 any more, can you please try 4? Line 152 being commented is the correct decision I think, since Nchan here refers to the drift-corrected file which should already have the channels subsampled. I don't know why it's not working for you, but it has been working fine for many others.

Jialiang-Lu commented 4 weeks ago

@marius10p Thank you! I understand that the drift-corrected file is the temporary file temp_wh.dat that gets overwritten after every sorting. So I had to change the params.py so that it points to the original binary file. And this is where the discrepancy comes from. Kilosort4 does not create temporary files so it works correctly.