Plot_traces does not work with different sampling rates
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 57/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- data-visualization
Research direction
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.
Written by the indexing model from the issue text.
Description
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
LFP recording
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.
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
- Dominant language
- Python
- Stars
- 883
- Forks
- 291
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 40
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SpikeInterface/spikeinterface
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
SpikeInterface/spikeinterface#5008 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
SpikeInterface/spikeinterface#5007 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
SpikeInterface/spikeinterface#5006 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
SpikeInterface/spikeinterface#5005 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
SpikeInterface/spikeinterface#5004 ·
Maintainers usually reply within 2 days
All issues in SpikeInterface/spikeinterface
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
daniel-ospina/tortoise#15308 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
difficulty:easy prio:low type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NatronGitHub/Natron#2405 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Jstar269/nakagawa-recomp#3746 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day