Skip to content

High level function for drift : correct_motion()#1300

Merged
alejoe91 merged 38 commits intoSpikeInterface:mainfrom
samuelgarcia:motion
Jul 6, 2023
Merged

High level function for drift : correct_motion()#1300
alejoe91 merged 38 commits intoSpikeInterface:mainfrom
samuelgarcia:motion

Conversation

@samuelgarcia
Copy link
Member

@samuelgarcia samuelgarcia commented Feb 9, 2023

This implement a high level function to estimate and interpolate dirft.

  • correct_motion()
  • test
  • documentation

@yger
Copy link
Collaborator

yger commented Feb 9, 2023

There is a typo in the function name. Plus, I think it would make sense to have a default peak number selected, as we discussed, that would depend on the duration of the recording. Do you really want the default params for select peaks to be None?

@samuelgarcia
Copy link
Member Author

Salut Pierre.
oui oui bien sûr. C'est juste un premier jet.

I am also thinkink of having some "preset" option.
the preset would choose default dict that make for the user a combinaison of parameters to mimic KS2.5 or the paninski pipeline.

@alejoe91 alejoe91 added sortingcomponents Related to sortingcomponents module preprocessing Related to preprocessing module labels Feb 10, 2023
@yger yger changed the title Start esimate_and_correct_motion() utils function. Start estimate_and_correct_motion() utils function. Feb 13, 2023
@samuelgarcia samuelgarcia changed the base branch from master to main April 5, 2023 16:00
@alejoe91 alejoe91 added this to the 0.98.0 milestone Jun 6, 2023
@samuelgarcia samuelgarcia changed the title Start estimate_and_correct_motion() utils function. High level function for drift : correct_motion() Jun 28, 2023

from spikeinterface.core import get_noise_levels, fix_job_kwargs
from spikeinterface.core.core_tools import SIJsonEncoder

Copy link
Member Author

Choose a reason for hiding this comment

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

@cwindolf @yger
I have started some preset of parameters for the a high level function.
Could you have look and make some feedback ?

margin_um=0.0,
win_shape="gaussian",
win_step_um=50.0,
win_sigma_um=150.0,
Copy link
Collaborator

@cwindolf cwindolf Jun 29, 2023

Choose a reason for hiding this comment

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

this seems like a lot of very narrow windows, I would expect very noisy results in real data. I usually use more like win_step_um=400.0, win_sigma_um=200.0 (I think that the window sigma should be divided by 2 in the gaussian case, since gaussian kernels really extend out to 2 or 3 std devs, so this would match the behavior of rect windows more closely -- in that case, we could set win_sigma_um=400 which "looks nicer". might also be worth changing sigma->width since sigma comes from the gaussian kernel, and this wouldn't be sigma anymore in that case)

Copy link
Collaborator

Choose a reason for hiding this comment

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

^ what I have written would currently lead to an error because window sigma cannot be < window step, but I think these params are the way to go and that that restriction should be removed -- been meaning to make a PR about that

Copy link
Member Author

Choose a reason for hiding this comment

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

For win_step_um should not change the results lead to some kind of coninuum in space that avoid linear interpolation. I can be win_sigma_um=200 but you are suggesting to put 100 no ?
I am not sure to follow you.

Copy link
Collaborator

Choose a reason for hiding this comment

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

sorry, I was confusing!

yeah, I usually use win_sigma_um=200 or 250 in real data

and then the other thing I was saying, which is a separate issue, is that I think it could be nice to reparameterize the gaussian window size by a parameter which is 2 * win_sigma_um, which would make the width of the windows match the rect windows more closely

peak_locations,
times,
motion,
temporal_bins,
Copy link
Collaborator

Choose a reason for hiding this comment

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

it would be useful to clarify whether these are bin edges or bin centers

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it would be nice if estimate_motion returned an object so that this function could take fewer arguments, and to avoid replicating the logic about temporal bins and motion interpolation in several places (here in peaks and in traces and anywhere else a user may want to get displacement at a particular depth and time)

maybe a class like this one? https://github.com/evarol/dredge/blob/main/dredge-python/dredge/motion_util.py#L22

Copy link
Member Author

Choose a reason for hiding this comment

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

This is bin center this is in the docstring no ?
I am agree for the object but this will be in the next round of modification that we will to togoether no ?

@alejoe91 alejoe91 merged commit 7b60549 into SpikeInterface:main Jul 6, 2023
@samuelgarcia samuelgarcia deleted the motion branch October 24, 2023 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preprocessing Related to preprocessing module sortingcomponents Related to sortingcomponents module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants