-
Notifications
You must be signed in to change notification settings - Fork 218
Add correct_inter_session_displacement
function
#3126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
JoeZiminski
wants to merge
114
commits into
SpikeInterface:main
Choose a base branch
from
JoeZiminski:inter_session_displacement
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add correct_inter_session_displacement
function
#3126
JoeZiminski
wants to merge
114
commits into
SpikeInterface:main
from
JoeZiminski:inter_session_displacement
Conversation
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
bf9a84c
to
58a6962
Compare
99431b5
to
8e6e77b
Compare
correct_inter_session_displacement
function
9c8f81a
to
1d3d8db
Compare
e7c22dc
to
8ec328c
Compare
JoeZiminski
commented
Nov 21, 2024
JoeZiminski
commented
Nov 21, 2024
JoeZiminski
commented
Nov 21, 2024
2c1ebca
to
74d6c45
Compare
98682ea
to
01adece
Compare
1faafaa
to
abe27c1
Compare
for more information, see https://pre-commit.ci
73edb81
to
140a8c7
Compare
JoeZiminski
commented
Mar 14, 2025
@@ -168,6 +168,18 @@ def get_spatial_bin_edges(recording, direction, hist_margin_um, bin_um): | |||
return spatial_bins | |||
|
|||
|
|||
def get_spatial_bins(recording, direction, hist_margin_um, bin_um): | |||
# TODO: could this be merged with the above function? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess where get_spatial_bin_edges
is used this could be used instead
JoeZiminski
commented
Mar 14, 2025
@@ -203,6 +203,7 @@ def __init__( | |||
peak_amplitudes = peak_amplitudes[peak_mask] | |||
|
|||
from matplotlib.pyplot import colormaps | |||
from matplotlib.colors import Normalize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small fixes in this module
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.
This PR requires #3231 , on which it is rebased. Currently this PR contains commits from that PR so it makes sense for that to be merged before reviewing this in depth as the diff will be confusing.
The problem to be solved is inter-session movement ('displacement') of the probe. This is very similar problem to the inter-session motion correction, and can use many of the same tools. The idea is accept as input a list of recording objects (and, optionally, a list of intra-session motion correction outputs). For each session, an activity histogram will be generated, and then the inter-session drift and necessary correction estimated. The correction is then applied to the recording object, but a
displacement_info
object (similar tomotion_info
object) will be output. This could be used to correct peaks directly and optionally later, correct templates (see #2626).Under the hood it essentially using the kilosort drift correction approach (cross correlation for linear alignment, and rigid alignment within multiple segments along the probe y-axis for non-rigid alignment). To generate the histogram for each session, the session is first split into segments and a histogram calculated for each segment, and then either the mean or median taken. The idea is to downweight periods of a session that may have noise. I tried a few different approaches (e.g. maximum value, first eigenvalue) but decided it was overkill and just kept the mean / median for now).
This PR makes a few changes to existing code to refactor anything I needed so it can be shared across modules, for the most part though the changes are contained within new modules.
Tests are added and a new tutorial is added in the documentation.
Question
__init__
I get a circular import issue because I am calling somesortingcomponents.motion
modules. Please see the comment mode in thepreprocessing/__init__.py
and uncomment to reproduce. I think this can be solved by moving some of the motion code into core? For now, the functions are not in the API docs for this reason.Example Script