Switch to kernel for local CAR#4454
Merged
alejoe91 merged 13 commits intoSpikeInterface:mainfrom Mar 19, 2026
Merged
Conversation
backup reference for local reference when local channels too few; knn can be more robust than local as it ensures the # of reference channels
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
alejoe91
commented
Mar 18, 2026
| assert np.allclose(traces[:, 0], rec_local_cmr.get_traces()[:, 0] + np.median(traces[:, [2, 3]], axis=1), atol=0.01) | ||
| assert np.allclose(traces[:, 1], rec_local_cmr.get_traces()[:, 1] + np.median(traces[:, [3]], axis=1), atol=0.01) | ||
|
|
||
| # TODO: fix this!!! |
Member
Author
There was a problem hiding this comment.
It's fixed, I was missing a transpose in the code :P
alejoe91
commented
Mar 19, 2026
src/spikeinterface/preprocessing/tests/test_common_reference.py
Outdated
Show resolved
Hide resolved
Comment on lines
+121
to
+125
| warnings.warn( | ||
| "Using a local median reference can be very computationally intensive. Consider using a local " | ||
| "average reference instead or pre-computing the local median reference and using the 'single' " | ||
| "reference option." | ||
| ) |
Member
There was a problem hiding this comment.
I find this warning a bit annoying, since you can't turn it off if you use local + median. I also don't understand the second part of the warning. It sounds like I can pre-compute the reference and pass it? Can I??
Member
Author
There was a problem hiding this comment.
Yeah the second part doesn't make sense. Shoudl I just remove it?
chrishalcrow
approved these changes
Mar 19, 2026
Member
chrishalcrow
left a comment
There was a problem hiding this comment.
This looks good to me and is working about x10 faster locally (loading big traces on the GUI). Thanks!
Just mild complaints about warnings ;)
alejoe91
commented
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Following up on #4412
Added a "kernel" mode for local CAR: when computing the common average referencing, we can simply pre-compute a kernel with 1/local_neighbors for each channel and use it in the
get_traceswith a simple dot product, skipping an inefficient channel loop.This makes the
get_tracesx10 faster (added a skipped test to test locally):