The contacts position on my probe are defined in 3d (which I assume is the issue below). I am running the following code and looks unit_location metric has issue with the 3d coordinates. In my case the contacts are relatively far from each other (>125um). I can compromise by adding arbitrary contact locations in 2D, but I suppose for someone else it can be more critical. Let me know if I should provide more info.
import spikeinterface.full as si
...
my_protocol = {
'preprocessing': {
# 'bandpass_filter': {'freq_min': 300, 'freq_max': 6000},
'detect_and_remove_bad_channels': {'method': 'coherence+psd'},
'common_reference': {'reference': 'global', 'operator': 'median'},
},
'sorting': {
'sorter_name': 'tridesclous2',
'apply_preprocessing': False,
'remove_existing_folder': True,
'verbose': True,
}
}
...
recording = load(spikesorting_path/f'{array}_data')
recording = si.apply_preprocessing_pipeline(recording, my_protocol['preprocessing'])
sorting_folder = spikesorting_path/f'{array}_{my_protocol['sorting']['sorter_name']}_sorting'
sorting = si.run_sorter(
recording=recording,
folder=sorting_folder,
**my_protocol['sorting']
noise_level (workers: 20 processes fork): 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 20/20 [00:00<00:00, 45.71it/s]
detect peaks (locally_exclusive) (workers: 24 processes fork): 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 848/848 [01:05<00:00, 12.90it/s]
detect_peaks(): 1288470 peaks found
select_peaks(): 160000 peaks kept for clustering
Fit peaks svd (workers: 24 processes fork): 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 848/848 [00:04<00:00, 198.15it/s]
Transform peaks svd (workers: 24 processes fork): 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 848/848 [00:09<00:00, 86.61it/s]
split_clusters with local_feature_clustering: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 63/63 [00:30<00:00, 2.06it/s]
/home/vivanov/anaconda3/envs/spikesorting/lib/python3.12/site-packages/spikeinterface/postprocessing/template_similarity.py:345: NumbaTypeSafetyWarning: unsafe cast from uint64 to int64. Precision may be lost.
overlapping_ids = overlapping_j_list[i]
find_clusters_from_peaks(): 49 cluster found
estimate_templates_with_accumulator (workers: 24 processes fork): 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 848/848 [00:08<00:00, 97.48it/s]
find spikes (tdc-peeler) (workers: 24 processes fork): 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 848/848 [00:49<00:00, 17.28it/s]
Error running tridesclous2
Traceback (most recent call last):
File "/home/vivanov/Workspace/spikesorting/4_spikesorting.py", line 85, in <module>
sorting = si.run_sorter(
^^^^^^^^^^^^^^
File "/home/vivanov/anaconda3/envs/spikesorting/lib/python3.12/site-packages/spikeinterface/sorters/runsorter.py", line 206, in run_sorter
return run_sorter_local(**common_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vivanov/anaconda3/envs/spikesorting/lib/python3.12/site-packages/spikeinterface/sorters/runsorter.py", line 298, in run_sorter_local
SorterClass.run_from_folder(folder, raise_error, verbose)
File "/home/vivanov/anaconda3/envs/spikesorting/lib/python3.12/site-packages/spikeinterface/sorters/basesorter.py", line 306, in run_from_folder
raise SpikeSortingError(
spikeinterface.sorters.utils.misc.SpikeSortingError: Spike sorting error trace:
Traceback (most recent call last):
File "/home/vivanov/anaconda3/envs/spikesorting/lib/python3.12/site-packages/spikeinterface/sorters/basesorter.py", line 266, in run_from_folder
SorterClass._run_from_folder(sorter_output_folder, sorter_params, verbose)
File "/home/vivanov/anaconda3/envs/spikesorting/lib/python3.12/site-packages/spikeinterface/sorters/internal/tridesclous2.py", line 356, in _run_from_folder
analyzer_final = final_cleaning_circus(
^^^^^^^^^^^^^^^^^^^^^^
File "/home/vivanov/anaconda3/envs/spikesorting/lib/python3.12/site-packages/spikeinterface/sorters/internal/spyking_circus2.py", line 521, in final_cleaning_circus
analyzer.compute("unit_locations", method="center_of_mass", **job_kwargs)
File "/home/vivanov/anaconda3/envs/spikesorting/lib/python3.12/site-packages/spikeinterface/core/sortinganalyzer.py", line 1644, in compute
return self.compute_one_extension(extension_name=input, save=save, verbose=verbose, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vivanov/anaconda3/envs/spikesorting/lib/python3.12/site-packages/spikeinterface/core/sortinganalyzer.py", line 1733, in compute_one_extension
extension_instance.run(save=save, verbose=verbose)
File "/home/vivanov/anaconda3/envs/spikesorting/lib/python3.12/site-packages/spikeinterface/core/sortinganalyzer.py", line 2642, in run
self._run(**kwargs)
File "/home/vivanov/anaconda3/envs/spikesorting/lib/python3.12/site-packages/spikeinterface/postprocessing/unit_locations.py", line 116, in _run
self.data["unit_locations"] = func(self.sorting_analyzer, **method_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vivanov/anaconda3/envs/spikesorting/lib/python3.12/site-packages/spikeinterface/postprocessing/localization_tools.py", line 200, in compute_center_of_mass
unit_location[i, :] = com
~~~~~~~~~~~~~^^^^^^
ValueError: could not broadcast input array from shape (3,) into shape (2,)
Hi,
The contacts position on my probe are defined in 3d (which I assume is the issue below). I am running the following code and looks
unit_locationmetric has issue with the 3d coordinates. In my case the contacts are relatively far from each other (>125um). I can compromise by adding arbitrary contact locations in 2D, but I suppose for someone else it can be more critical. Let me know if I should provide more info.Best,
Vladyslav