Skip to content

Switch to kernel for local CAR#4454

Merged
alejoe91 merged 13 commits intoSpikeInterface:mainfrom
alejoe91:local_car
Mar 19, 2026
Merged

Switch to kernel for local CAR#4454
alejoe91 merged 13 commits intoSpikeInterface:mainfrom
alejoe91:local_car

Conversation

@alejoe91
Copy link
Member

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_traces with a simple dot product, skipping an inefficient channel loop.

This makes the get_traces x10 faster (added a skipped test to test locally):

Local CMR time: 11.6428 seconds
Local CAR time: 1.3863 seconds

@alejoe91 alejoe91 added the preprocessing Related to preprocessing module label Mar 17, 2026
@alejoe91 alejoe91 added this to the 0.104.0 milestone 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!!!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fixed, I was missing a transpose in the code :P

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."
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the second part doesn't make sense. Shoudl I just remove it?

Copy link
Member

@chrishalcrow chrishalcrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 alejoe91 merged commit f632aa7 into SpikeInterface:main Mar 19, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preprocessing Related to preprocessing module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants