`plot_potential_merges` draws the correlograms of other units when a merge group is not sorted

Aperta Adatta ai principianti
#5,007 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
data

Direzione di ricerca

Inizia da widgets/potential_merges.py ed esamina _update_plot, dove l’issue indica l’ordine di selezione e la gestione del menu a discesa dei gruppi. Controlla i test esistenti per plot_potential_merges e aggiungi test per un gruppo non ordinato e per ID di unità contenenti trattini. Il lavoro è completato quando ogni correlogramma corrisponde al titolo della propria unità e gli ID concatenati funzionano senza ValueError.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I found this while reading widgets/potential_merges.py, not in my own analyses, so this is a "for the sake of improvement" report.

In _update_plot, the correlograms are selected with np.isin(unique_merge_units, plot_unit_ids), which follows the sorted order of unique_merge_units, while the titles follow the order of the merge group. For the group ["3", "1"], the autocorrelogram of unit 1 is drawn under the title of unit 3 and the reverse, without an error. Also, the group is rebuilt with split("-"), so unit ids containing "-", such as those made by merge_units(new_id_strategy="join"), raise a ValueError.

import matplotlib

matplotlib.use("module://ipympl.backend_nbagg")
import numpy as np
from spikeinterface.core import generate_ground_truth_recording, create_sorting_analyzer
from spikeinterface.widgets import plot_potential_merges

recording, sorting = generate_ground_truth_recording(durations=[20.0], num_channels=16, num_units=5, seed=0)
analyzer = create_sorting_analyzer(sorting, recording, sparse=False, format="memory")
analyzer.compute(["random_spikes", "templates", "spike_amplitudes", "correlograms"], progress_bar=False)
ccgs, _ = analyzer.get_extension("correlograms").get_data()
unit_ids = list(analyzer.unit_ids)

w = plot_potential_merges(analyzer, [["3", "1"]], backend="ipywidgets", display=False)
for k in range(2):
    drawn = np.array([bar.get_height() for bar in w.axes_cc[k, k].patches])
    match = [str(u) for i, u in enumerate(unit_ids) if np.array_equal(drawn, ccgs[i, i])]
    print("panel", w.axes_cc[0, k].get_title(), "shows the autocorrelogram of unit", match)
# panel 3 shows the autocorrelogram of unit ['1']  expected ['3']
# panel 1 shows the autocorrelogram of unit ['3']  expected ['1']

merged = analyzer.merge_units([["0", "1"]], new_id_strategy="join")
plot_potential_merges(merged, [["0-1", "2"]], backend="ipywidgets", display=False)
# ValueError: '0' is not in list

Fix: select the correlograms with the index of each unit of the group, in the group order, and keep the groups themselves for the dropdown instead of joined strings.

I can open a PR with a test if you agree.

Lingua principale
Python
Stelle
883
Fork
291
Merge medio
3g 17h
PR unite (30g)
40

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di SpikeInterface/spikeinterface

Tutte le issue di SpikeInterface/spikeinterface

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.