SpikeInterface / SpikeInterface/spikeinterface

Plot_unit_locations error?

Open
#3,563 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

postprocessing
Dominant language
Python
Stars
847
Forks
280
Avg merge
3d 9h
Merged PRs (30d)
29

Description

Hi,

I have a recording on neuropixel 2.0 using openephys and performed sorting on kilosort 4 (outside of spikeinterface). I then loaded both the recording and sorting into spikeinterface to create a sorting_analyzer object. After computing random spikes, templates, spike and unit locations, I tried plot_unit_locations which gave a plot where most of the units seemed to be on the rightmost shank, while there are also many units on the third from left shank, where there aren't even recording channels selected. Finally, some units are plotted in between shanks. These locations do not match the spike locations visualization from kilosort either.

Plot_unit_locations output:
image

I plotted the spike_positions.npy file from kilosort 4:
image

To look at a single unit in detail, here is unit 52 highlighted in red on the second from left shank (for ease of viewing I did not plot all the spikes from other units). The plot_unit_locations widget however highlights unit 52 on the 4th shank, at a different depth as well.

image
image

May I know if I am doing something wrong?

This is my code:

recording = si.read_openephys(recording_file_path)
kilosort_results = si.read_kilosort(kilosort_file_path)
analyzer = si.create_sorting_analyzer(sorting=kilosort_results, recording=recording,format="binary_folder",return_scaled=True, folder='my_save_path')

si.compute_random_spikes(analyzer)
si.compute_templates(analyzer)
si.compute_spike_locations(analyzer)
si.compute_unit_locations(analyzer)

si.plot_unit_locations(analyzer,backend='ipywidgets')

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided read_openephys/read_kilosort workflow and the compute_spike_locations, compute_unit_locations, and plot_unit_locations entry points. Compare their coordinates with Kilosort 4's spike_positions.npy, reproducing the discrepancy for unit 52. Done means the plotted units match the expected shanks and depths, or the coordinate mismatch is clearly identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.