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

Offen Anfängerfreundlich
#5,007 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 2 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
74/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
data

Rechercherichtung

Beginne mit widgets/potential_merges.py und untersuche _update_plot, wo der Issue die Reihenfolge der Auswahl und die Behandlung des Gruppendropdowns nennt. Prüfe die vorhandenen Tests für plot_potential_merges und ergänze Tests für eine unsortierte Gruppe und Unit-IDs mit Bindestrichen. Fertig ist es, wenn jedes Correlogramm zum Titel seiner Unit passt und verbundene IDs ohne ValueError funktionieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Python
Sterne
883
Forks
291
Ø Merge
3 T. 17 Std.
Gemergte PRs (30 T.)
40

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus SpikeInterface/spikeinterface

Alle Issues in SpikeInterface/spikeinterface

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.