AllenInstitute / ecephys_spike_sorting

Modules for processing extracellular electrophysiology data from Neuropixels probes
Other
109 stars 91 forks source link

kilosort post-processing module for KS3 data #59

Closed LaurenzMuessig closed 3 years ago

LaurenzMuessig commented 3 years ago

Hi,

It seems to me at the moment only the quality metric module is compatible with KS3 data. Will there be an update for the kilosort-postprocessing module at some point? Thanks for letting me know.

Cheers

Laurenz

jsiegle commented 3 years ago

Hi Laurenz, I've used both the mean_waveforms and quality_metrics modules with Kilosort3. The noise_templates module shouldn't be necessary, as KS3 finds very few (if any) noise units. And I'd like to do more characterization of the KS3 outputs before applying the kilosort_postprocessing module, since I'm not sure if double-counted spikes are still an issue with the new algorithm.

Can you describe the bugs you've encountered? They should be straightforward to fix, since the KS3 outputs are quite similar to KS2 (with the exception of missing PCs, at least for now).

LaurenzMuessig commented 3 years ago

Hi Josh,

Thanks for quick response. You are right that getting the ks_postprocessing to run seems mainly putting in a few 'try..except..' to deal with the lack of the pc_features in KS3. I was just curious (and lazy) and wondered why you guys hadn't pushed that in the latest update. I'll make the edits myself and let you know if there is some bigger issue. PS: I am def seeing the issue with double counted spikes quite a lot in my data and as far I understand the spike detection bits haven't changed much between KS2.5 and 3, but mainly the clustering algorithm (but I might be wrong).

Update: Getting it to run was indeed mostly just taking care of the lack of pc_features. There was however one thing that took me ages to figure out as I am a Matlab guy. In _remove_double_countedspikes you also need change _'spikes_toremove = np.zeros((0,)' to something like _'spikes_toremove = np.zeros((0,dtype='i8')' in lines 69 and 92 to make sure the index doesn't become a float. This looks like the same issue described in #57

jsiegle commented 3 years ago

Ok, those changes are now implemented in the master branch. Thanks for pointing this out!