spikeinterface icon indicating copy to clipboard operation
spikeinterface copied to clipboard

Auto-estimate margins based on freq_min/f0+Q for filters

Open alejoe91 opened this issue 1 month ago • 8 comments

@samuelgarcia let's discuss!

alejoe91 avatar Nov 24 '25 17:11 alejoe91

I think this is a great feature, but I already told @samuelgarcia that maybe we should at very least warn (prevent ?) users that will use very low frequencies for filters, trying to get LFP and/or low pass versions of the data. If the automatic margin starts to be really large (maybe larger than the default chunk size of 1s), then we should warn users that they are doing something clearly suboptimal.

yger avatar Nov 25 '25 10:11 yger

I think this is a great feature, but I already told @samuelgarcia that maybe we should at very least warn (prevent ?) users that will use very low frequencies for filters, trying to get LFP and/or low pass versions of the data. If the automatic margin starts to be really large (maybe larger than the default chunk size of 1s), then we should warn users that they are doing something clearly suboptimal.

Sub-optimal but somehow needed! Maybe we can warn if the margin is greater than the max_margin_s (default 5 s). What do you think?

alejoe91 avatar Nov 25 '25 11:11 alejoe91

Yes, I've read the PR, and indeed, at least a warning that the theoretical margin should be XX, and that it has be clipped to max_margin_s. The thing is that if users really want to do that, then the warning message could also advise them to increase chunk_duration in the default_job_kwargs, to reduce IO overloads

yger avatar Nov 25 '25 15:11 yger

We democratically decided to remove the max_margin kwargs and instead make a mechanism that raise an error if the end-user try to filter in LFP band and then point to a link to a clear and didactic and really exemplar tutorial about chunking and its bad effect on low freqs.

samuelgarcia avatar Dec 04 '25 10:12 samuelgarcia

This is ready for final review. here's a new doc page explaining the issue: https://spikeinterface--4227.org.readthedocs.build/en/4227/how_to/extract_lfps.html

alejoe91 avatar Dec 05 '25 12:12 alejoe91

Hello, amazing!

You could set this doc up as a jupyter notebook that gets run in the CI (e.g. https://github.com/SpikeInterface/spikeinterface/tree/main/examples/tutorials/forhowto)

Then we don't have to do all the .py -> .rst conversion annoying stuff.

chrishalcrow avatar Dec 05 '25 14:12 chrishalcrow

Hello, amazing!

You could set this doc up as a jupyter notebook that gets run in the CI (e.g. https://github.com/SpikeInterface/spikeinterface/tree/main/examples/tutorials/forhowto)

Then we don't have to do all the .py -> .rst conversion annoying stuff.

Done! Also moved the forhowto out of tutorials, so it's a nice separation!

alejoe91 avatar Dec 09 '25 11:12 alejoe91

@chrishalcrow needed some juggling to make it work with RTD RAM (the script used to save everything in memory), but it works now!

Let me know if you have more comments: https://spikeinterface--4227.org.readthedocs.build/en/4227/forhowto/plot_extract_lfps.html

alejoe91 avatar Dec 09 '25 11:12 alejoe91