`plot_unit_presence` shows bin indices on the `Time (s)` axis when `time_range` is not given

Aperta Adatta ai principianti
#5,006 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
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
matplotlib, python

Direzione di ricerca

Inizia da widgets/unit_presence.py, dove plot_unit_presence calcola i conteggi dei bin e chiama imshow. Usa i due esempi nell’issue per verificare i limiti degli assi quando time_range è omesso e l’IndexError con una frequenza di campionamento di 24414.0625 Hz. Il lavoro è completato quando l’asse mostra i secondi e il conteggio dei bin usa una larghezza di campionamento uniforme senza generare l’errore di indicizzazione.

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

Descrizione

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

Without time_range, no extent is passed to imshow, so the x axis shows bin indices while it is labelled "Time (s)". With the default 0.05 s bins, the times are 20 times too large, without an error. Also, the bin width in samples is truncated with int(bin_duration_s * fs) while the number of bins is computed in seconds, so some sampling frequencies raise an IndexError.

import matplotlib

matplotlib.use("Agg")
from spikeinterface.core import generate_sorting
from spikeinterface.widgets import plot_unit_presence

sorting = generate_sorting(num_units=4, durations=[10.0], sampling_frequency=30000.0, seed=0)
w = plot_unit_presence(sorting)
print(w.ax.get_xlabel(), [float(x) for x in w.ax.get_xlim()])
# Time (s) [-0.5, 198.5]  expected about [0, 10]

sorting = generate_sorting(num_units=4, durations=[60.0], sampling_frequency=24414.0625, seed=0)
plot_unit_presence(sorting)
# IndexError: index 1200 is out of bounds for axis 1 with size 1200

Fix: always pass an extent in seconds to imshow, and compute the number of bins and the bin indices with the same bin width in samples.

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.