AllenInstitute / ecephys_spike_sorting

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

Postprocessing #71

Closed DaniMagyar closed 2 years ago

DaniMagyar commented 2 years ago

Hi. I would like to use the Postprocessing module to remove double detected spikes. I run Kilosort3 from Matlab, then try to run the module in cmd but I get this error message:

ecephys spike sorting: kilosort postprocessing module Loading data... Removing within-unit overlapping spikes... Traceback (most recent call last): File "C:\Users\dmagyar\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\dmagyar\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\dmagyar\Documents\Matlab_toolboxes_DM\ecephys_spike_sorting\ecephys_spike_sorting\modules\kilosort_postprocessing__main__.py", line 94, in main() File "C:\Users\dmagyar\Documents\Matlab_toolboxes_DM\ecephys_spike_sorting\ecephys_spike_sorting\modules\kilosort_postprocessing__main.py", line 84, in main output = run_postprocessing(mod.args) File "C:\Users\dmagyar\Documents\Matlab_toolboxes_DM\ecephys_spike_sorting\ecephys_spike_sorting\modules\kilosort_postprocessing\main__.py", line 44, in run_postprocessing remove_double_counted_spikes(spike_times, File "C:\Users\dmagyar\Documents\Matlab_toolboxes_DM\ecephys_spike_sorting\ecephys_spike_sorting\modules\kilosort_postprocessing\postprocessing.py", line 73, in remove_double_counted_spikes for idx1, unit_id1 in enumerate(unit_list[order]): IndexError: index 175 is out of bounds for axis 0 with size 175

For me it seems like unit_list is 1 number smaller than it should be. If I change line 58 in postprocessing.py from "unit_list = np.arange(np.max(spike_clusters)+1)" to "unit_list = np.arange(np.max(spike_clusters)+2)" the module works.

I dont really understand this problem, I'm pretty new to programming.

Thank you for your help.

jsiegle commented 2 years ago

Have you done any manual curation of this dataset? It's possible that's creating a discrepancy between the cluster IDs and the templates files (which the order is computed from).

DaniMagyar commented 2 years ago

Thank you for your comment. It turned out that Kilosort3 caused the discrepancy between the cluster IDs and the template files, probably because there were no spikes on multiple channels.