@@ -2,9 +2,9 @@ How to perform inter-session alignment
2
2
======================================
3
3
4
4
In this how-to, we will assess and correct changes in probe position across multiple experimental sessions
5
- using ' inter-session alignment' .
5
+ using ` inter-session alignment ` .
6
6
7
- This is often valuable chronic-recording experiments, where the goal is to track units across sessions
7
+ This is often valuable for chronic-recording experiments, where the goal is to track units across sessions
8
8
9
9
A full tutorial, including details on the many settings for this procedure, can be found `here <TODO: ADD LINK (INTERNAL) >`_.
10
10
@@ -14,25 +14,23 @@ Running inter-session alignment
14
14
In SpikeInterface, it is recommended to perform inter-session alignment
15
15
following within-session motion correction (if used) and before whitening.
16
16
17
- Preprocessed recordings should be stored in a list before being passed
18
- to the `session_alignment ` functions:
17
+ Preprocessed recordings should first be stored in a list:
19
18
20
19
.. code :: python
21
20
22
21
recordings_list = [prepro_session_1, prepro_session_2, ... ]
23
22
24
23
Here, we will simulate such an experiment by generating a pair of sessions in
25
- which the probe is displaced 200 micrometers (um ) along its y-axis (depth).
24
+ which the probe is displaced 200 micrometers (μm ) along its y-axis (depth).
26
25
27
- The first step involves running all required imports :
26
+ First, we will import all required packages and functions :
28
27
29
28
.. code :: python
30
29
31
- from spikeinterface.generation.session_displacement_generator import generate_session_displacement_recordings
30
+ # TODO : should add all of the below to spikeinterface.full? (CHECK)
32
31
import spikeinterface.full as si
33
- from spikeinterface.preprocessing.inter_session_alignment import ( # TODO : should add all of the below to spikeinterface.full? (CHECK)
34
- session_alignment,
35
- )
32
+ from spikeinterface.generation.session_displacement_generator import generate_session_displacement_recordings
33
+ from spikeinterface.preprocessing.inter_session_alignment import session_alignment
36
34
from spikeinterface.widgets import plot_session_alignment, plot_activity_histogram_2d
37
35
import matplotlib.pyplot as plt
38
36
@@ -50,14 +48,14 @@ and then generating the test recordings:
50
48
We won't explicitly preprocess these recordings in this how-to, but you can imagine
51
49
preprocessing steps have already been run (e.g. filtering, common reference etc.).
52
50
53
- To run inter-session alignment, we need to detect peaks and compute the peak locations,
54
- as the location of firing neurons are used as anchors to align the sessions.
51
+ To run inter-session alignment, peaks must be detected and localised
52
+ as the locations of firing neurons are used to anchor the sessions alignment .
55
53
56
54
If you are **running inter-session alignment following motion correction **, the peaks will
57
- already be detected and localised. In this case, please jump to the
58
- :ref: `alignment guide < _with_motion_correction >`.
55
+ already be detected and localised. In this case, please jump to
56
+ :ref: `inter-session alignment after motion correction < with_motion_correction >`.
59
57
60
- In this section we will imagine motion correction was not run, so we need to compute the peaks:
58
+ In this section we will assume motion correction was not run, so we need to compute the peaks:
61
59
62
60
.. code :: python
63
61
@@ -81,7 +79,7 @@ The peak locations (before correction) can be visualised with the plotting funct
81
79
82
80
Now, we are ready to perform inter-session alignment. There are many options associated
83
81
with this method—the simplest way to edit these is to fetch the default options
84
- using the getter function as below :
82
+ with the getter function and make select changes as required :
85
83
86
84
.. code :: python
87
85
@@ -95,7 +93,7 @@ using the getter function as below:
95
93
estimate_histogram_kwargs = estimate_histogram_kwargs
96
94
)
97
95
98
- To assess the performance of inter-session alignment, `plot_session_alignment() `
96
+ To assess the performance of inter-session alignment, `` plot_session_alignment() ` `
99
97
will plot both the original and corrected recordings:
100
98
101
99
.. code :: python
@@ -120,10 +118,10 @@ Inter-session alignment after motion correction
120
118
121
119
If motion correction has already been performed, it is possible to reuse the
122
120
previously computed peaks and peak locations, avoiding the need for re-computation.
123
- We will use the special function `align_sessions_after_motion_correction() ` for this case.
121
+ We will use the special function` `align_sessions_after_motion_correction()` ` for this case.
124
122
125
- Critically, the last preprocessing step prior to inter-session alignment should be motion correction,
126
- so the correction for inter-session displacement will be **added directly to the motion correction **.
123
+ Critically, the last preprocessing step prior to inter-session alignment should be motion correction.
124
+ This ensures the correction for inter-session alignment will be **added directly to the motion correction **.
127
125
This is beneficial as it avoids interpolating the data (i.e. shifting the traces) more than once.
128
126
129
127
.. admonition :: Warning
@@ -144,9 +142,9 @@ This is beneficial as it avoids interpolating the data (i.e. shifting the traces
144
142
assert isinstance (recording, InterpolateMotionRecording) # error if not true
145
143
146
144
``align_sessions_after_motion_correction() `` will raise an error if the passed recordings
147
- are not all `InterpolateMotionRecordings `.
145
+ are not all `` InterpolateMotionRecordings ` `.
148
146
149
- Again, let's create some test data. We can create a recording with motion errors,
147
+ Let's first create some test data. We can create a recording with motion errors,
150
148
then split it in two to simulate two separate sessions:
151
149
152
150
.. code :: python
@@ -176,10 +174,9 @@ Next, motion correction is performed, storing the results in a list:
176
174
motion_info_list.append(motion_info)
177
175
178
176
Now, we are ready to use ``align_sessions_after_motion_correction() ``
179
- to align the motion-corrected sessions.
180
-
181
- This function should always be used for aligning motion-corrected sessions,
182
- as it ensures the alignment parameters are properly matched.
177
+ to align the motion-corrected sessions. This function should always be used
178
+ for aligning motion-corrected sessions, as it ensures the alignment
179
+ parameters are properly matched.
183
180
184
181
We can pass any arguments directly to ``align_sessions `` using the ``align_sessions_kwargs `` argument:
185
182
0 commit comments