-
Notifications
You must be signed in to change notification settings - Fork 190
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 session displacement generation #3231
base: main
Are you sure you want to change the base?
Add session displacement generation #3231
Conversation
089cbc0
to
60c8e5e
Compare
72ca7fa
to
33254b9
Compare
33254b9
to
e996dee
Compare
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.
Cool! This seems really nice. I think my only question is whether there can be more logic sharing with the single-session generate_drifting_recording
, since some of the changes you've made seem like they could be helpful there. But, not sure how much sense that makes.
|
||
displacement_vectors = np.concatenate(displacement_vectors, axis=2) | ||
|
||
return displacement_vectors, displacement_unit_factor, displacement_sampling_frequency, displacements_steps | ||
|
||
|
||
def calculate_displacement_unit_factor( |
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.
maybe this could be called something like "simulate_linear_gradient_drift"? i was a bit confused reading it, but it seems to be generating drift which is 0 at the top of the probe and something not zero at the bottom?
maybe someone can help explain what exactly
displacement_unit_factor = factors * (1 - f) + f
ends up producing... is it like there is some global drift plus per-unit linear drift?
) | ||
|
||
|
||
def _update_kwargs_for_extended_units( |
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.
this is a cool feature! in the single-session case, i have previously dealt with this by adding extra units that are off the probe to start. i'm wondering how this fits into the single session case... would this function be useful there too?
# units is duplicated for each section, so the new num units | ||
# is 3x the old num units. | ||
num_units, unit_locations, fixed_generate_templates_kwargs, fixed_generate_sorting_kwargs = ( | ||
_update_kwargs_for_extended_units( |
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 it would only need max_displacement padding of units? maybe plus a spread factor of 200um?
also, would it be worth adding this to the single-session generator too?
This PR adds an 'inter-session displacement' ground-truth recording generator. This is to act as test data for inter-session alignment e.g. #2626 #3126. The reason for this is to support inter-session alignment (e.g. #2626, #3126 ). The idea is to create separate recordings with the same templates but shifted unit locations across recordings. There are options to model:
recording_amplitude_scalings
allows scaling the injected template amplitudes to different sizes across recordings.shift_units_outside_probe=True
introduces new neurons into the recording after probe shift.This PR tries to use the existing motion machinery where possible. This is quite a large PR (sorry) but I split into commits to make it easier to review commit-by-commit. The first few commits perform refactoring on existing code that are required. Then, the next few commits introduce the generation and test functions. A debugging script can be used to test manually, it can be found in the section below. Please also see some examples of how the function is used below.
I'm not sure about the name 'session displacement'. Maybe just 'generate_multi_session_recording()` is easier to understand. Also, please let me know if any other variable names are unclear.
Example Use
Example 1:
Set the amplitude of 2 units to zero between sessions, also with a 100 um shift. The units are shifted across sessions, and the top / bottom units are removed (e.g. simulating these neurons disappearing between sessions)_.
Example 2
Set
shift_units_outside_probe
toTrue
which introduces new units into the recording due to shift, alongside a 250 um shift. Note the top unit has been shifted out of the probe, the middle units are shifted up, and 2 new units are introduced at the bottom of the probe.Debugging code