Plot_traces does not work with different sampling rates

Aperta
#4,974 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

Start in src/spikeinterface/widgets/traces.py near line 268, where the issue says sample indices for recordings are derived using the first recording's sampling rate. Trace how plot_traces handles time ranges and sample indices for each recording, then check the relevant widget tests. Done means recordings with different sampling rates display aligned time ranges correctly.

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

Descrizione

bug

Hi guys,

I was playing around with the plot_traces function to compare the effects of LFP preprocessing from the broadband signal.

These are the steps I perform for the preprocessing:

def preprocess_lfp(
    recording,
    lfp_fs=1000,
    lfp_low=1,
    lfp_high=300,
    reference="global",
    operator="median",
):
    """
    Preprocess broadband LFP from a SpikeInterface recording.

    Steps:
    1. Bandpass filter (default 1-300 Hz)
    2. Common median reference (default)
    3. Downsample to LFP sampling rate

    Parameters
    ----------
    recording : BaseRecording
        Input SpikeInterface recording.
    lfp_fs : int, default=1000
        Output sampling rate.
    lfp_low : float, default=1
        Lower cutoff frequency.
    lfp_high : float, default=300
        Upper cutoff frequency.
    reference : str, default='global'
        Reference mode for common_reference().
    operator : str, default='median'
        Reference operator ('median' or 'average').

    Returns
    -------
    lfp : BaseRecording
        Preprocessed broadband LFP recording.
    """

    # Bandpass filter
    lfp = si.bandpass_filter(
        recording,
        freq_min=lfp_low,
        freq_max=lfp_high,
        margin_ms=5000,
        filter_order=2,
        ftype="butter",
        ignore_low_freq_error=True,
    )

    # Common reference
    lfp = si.common_reference(
        recording=lfp,
        reference=reference,
        operator=operator,
    )

    # Downsample
    lfp = si.resample(
        recording=lfp,
        resample_rate=lfp_fs,
        margin_ms=200,
    )

    return lfp

and then I simply try to plot the results:

rec_plot = si.plot_traces(
    {"Broad": HPC_recording, "LFP": HPC_LFP},
    order_channel_by_depth=True,
    backend="ipywidgets",
)
Broadband recording
image
LFP recording
image

It seems that the plot_traces function uses the sampling rate of the first recording and then defines the samples for all subsequent recordings using that same sampling rate.

https://github.com/SpikeInterface/spikeinterface/blob/b4ca1e0cb0b81f0a522baa4208f6be35c5285fbf/src/spikeinterface/widgets/traces.py#L268

I don't know if this is something you might be interested in fixing, but I just wanted to let you know this is a behavior of the function.

Cheers,
Juan

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.