WIP: Allow Dredge AP to use online motion resolution method - #4746
Open
chrishalcrow wants to merge 7 commits into
Open
WIP: Allow Dredge AP to use online motion resolution method#4746chrishalcrow wants to merge 7 commits into
chrishalcrow wants to merge 7 commits into
Conversation
Collaborator
|
This is amazing! I'll take a look at the code. |
cwindolf
reviewed
Sep 2, 2026
cwindolf
left a comment
Collaborator
There was a problem hiding this comment.
Can't see any issues here, this is great!
| **xcorr_kw, | ||
| ) | ||
|
|
||
| if resolution_mode == "simultaneous": |
Collaborator
There was a problem hiding this comment.
I'd call this "batch" or "offline"? (Just because those are more standard terms in optimization literature for this kind of thing)
Member
Author
There was a problem hiding this comment.
Do you think "resolution_mode" is the right terminology. I struggled with this language.
| bin_s=1 / lfp_recording.sampling_frequency, # only relevant for time_horizon_s | ||
| ) | ||
|
|
||
| P_online = compute_displacement_online( |
| if isinstance(lfp_recording, BaseRecording): | ||
| traces0 = lfp_recording.get_traces(start_frame=t0, end_frame=t1) | ||
| else: | ||
| traces0 = lfp_recording[:, t0:t1].T |
chrishalcrow
commented
Sep 3, 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.
The motion correction algorithms in SpikeInterface have two steps. You first compute many histograms-in-depth (using e.g. peak detection or LFP) over time. Second, you compare the histograms at different times to extract a time vector.
In the current implementation, if you use peak detection the comparison part of the algorithm compares ALL histograms against all others. This is fine if you have a standard recording, but fills up RAM quickly if you get towards one day long recordings. If you use LFP there is an "online" method to compare the histograms. This only compares histograms which are nearby in time, meaning that you don't need to load them all into memory. Hence, this can be used for very long recordings.
This PR refactors the "all at once" and "online" methods to extract motion vectors from histograms, allowing either method to be used regardless of histogram-construction method. Most of the pain is in how parameters are dealt with - they were packaged a bit differently for the two algorithms. We attempt to unify the arguments in the two methods as much as possible, and abstract some language.
Docs, tests, etc incoming.
I spent a while understanding the parameters and all the kwarg dicts. Here's a summary:
Parameters
User can give
dredge_apanddredge_online_lpfthe following dicts:thomas_kw: passed to
thomas_solvexcorr_kw: passed to
xcorr_windowsInside the functions, we set the following kwarg dicts:
full_xcorr_kw
weights_kw (passed to
weight_correlation_matrixin AP, just used to getmincorrin LFP)threshold_kw (passed to
threshold_correlation_matrix). We set: