Skip to content
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

Add correct_inter_session_displacementfunction #3126

Draft
wants to merge 87 commits into
base: main
Choose a base branch
from

Conversation

JoeZiminski
Copy link
Collaborator

@JoeZiminski JoeZiminski commented Jul 2, 2024

This PR requires #3231 , on which it is rebased.

This draft PR starts to play around with a rough implementation of 'inter-session displacement' estimation / correction, as discussed #2626.

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 to motion_info object) will be output. This could be used to correct peaks directly and optionally later, correct templates (see #2626).

At first I'll just do a very straightforward, rough implementation, then work on improving it. The steps are:

  1. Accept a list of recordings and optionally a list of associated motion_info dicts (output from intra-session motion correction). If motion_info is not passed, peaks and peak locations will be estimated. (to improve: here just use the entire reocrding, but in future can use subsets of the recording, in a way that maximises the accuracy of the estimation).
  2. With the peaks and peak locations, generate 2d or 3d activity histogram for the session (again, the entire session is used here, can be improved).
  3. Run an optimisation to estimate displacement and correction between sessions from the histograms. This should limit the amount of data lost at the border as well as move each session a similar amount (so interpolation artefacts are comparable same across sessions)
  4. If motion_info is provided, update the drift estimates with the inter-session drift and return. Otherwise, make the recordings InterpolateMotionRecording and return. Optionally return the displacement_info which copies motion_info.

This is currently very-rough draft PR but of course welcome feedback!

TODO:

  • TODO: DREDGE on concatenated data is working very well.
  • option to restrict 'interpolation' to channel multiple (i.e. no actual interpolation, just shifting channels)
  • do a simple argmax over non-rigid with say 2-20 probe segments and see what works best (smoothing too)
  • interpolate templates

FUTURE:

  • more features as Nick Watters mentioned, possibly discuss adding this to machinery time permitting

@JoeZiminski JoeZiminski force-pushed the inter_session_displacement branch from bf9a84c to 58a6962 Compare July 15, 2024 22:24
@JoeZiminski JoeZiminski force-pushed the inter_session_displacement branch 2 times, most recently from 99431b5 to 8e6e77b Compare July 29, 2024 15:55
@JoeZiminski JoeZiminski changed the title Add 'correct_inter_session_displacement' function Add correct_inter_session_displacementfunction Jul 30, 2024
@JoeZiminski JoeZiminski force-pushed the inter_session_displacement branch 2 times, most recently from 9c8f81a to 1d3d8db Compare July 30, 2024 16:27
@JoeZiminski JoeZiminski force-pushed the inter_session_displacement branch 2 times, most recently from e7c22dc to 8ec328c Compare August 28, 2024 18:32
@alejoe91 alejoe91 added the preprocessing Related to preprocessing module label Nov 4, 2024
"bin_um" : number of spatial histogram bins. As the estimated peak
locations are continuous (i.e. real numbers) this is not constrained
by the number of channels.
"method" : may be "chunked_mean", "chunked_median", "chunked_supremum",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

missing "entire_session"

motion_info_list : list[dict]
A list of `motion_info` objects, as output from `correct_motion`.
Each entry should correspond to a recording in `recording_list`.
rigid: bool
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

delete this

an InterpolateMotionRecording` recording, the corrected
output recording will be a copy of the input recording with
the additional displacement correction added.
`motion_objects_list : list[Motion]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is wrong now

@JoeZiminski JoeZiminski force-pushed the inter_session_displacement branch from 2c1ebca to 74d6c45 Compare December 17, 2024 11:41
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.

2 participants