Skip to content

Commit c674c6f

Browse files
committed
Rewrite introduction.
1 parent 250ef4a commit c674c6f

File tree

1 file changed

+60
-12
lines changed

1 file changed

+60
-12
lines changed

examples/long_tutorials/handle_drift/plot_handle_drift.py

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,51 @@
22
Handle motion/drift with spikeinterface NEW
33
===========================================
44
5-
Spikeinterface offers a very flexible framework to handle drift as a preprocessing step.
6-
If you want to know more, please read the
7-
:ref:`motion_correction` section of the documentation.
8-
9-
Here is a short demo on how to handle drift using the high-level function
10-
:py:func:`~spikeinterface.preprocessing.correct_motion()`.
11-
5+
When running *in vivo* electrophysiology recordings, movement of the probe is
6+
an inevitability, especially when the subjects are not head-fixed. SpikeInterface
7+
includes a number of popular methods to compensate for probe motion during the
8+
preprocessing step.
9+
10+
### What is drift and where does it come from?
11+
12+
Movement of the probe means that the spikes recorded on the probe 'drift' along it.
13+
Typically, this motion is vertical along the probe (along the 'y' axis) which
14+
manifests as the units moving long the probe in space.
15+
16+
All common motion-correction methods address this vertical drift. Horizontal ('x')
17+
or forward/backwards ('z') motion, that would appear as the amplitude of a unit
18+
changing over time, are much harder to model and not handled in available motion-correction algorithms.
19+
Fortunately, vertical drift is the most common form of motion as the probe is
20+
more likely to move along the path it was inserted, rather than in other directions
21+
where it is buffeted against the brain.
22+
23+
Vertical drift can come in two forms, 'rigid' and 'non-rigid'. Rigid drift
24+
is drift caused by movement of the entire probe and the motion is the
25+
same for all points along the probe. Non-rigid drift is instead caused by
26+
local movement of parts of the brain along the probe, and can affect
27+
the recording at only certain points along the probe.
28+
29+
### How SpikeInterface handles drift
30+
31+
Spikeinterface offers a very flexible framework to handle drift as a
32+
preprocessing step. In this tutorial we will cover the three main
33+
drift-correction algorithms implemented in SpikeInterface with
34+
a focus on running the methods and interpreting the output. For
35+
more information on the theory and implementation of these methods,
36+
see the :ref:`motion_correction` section of the documentation.
37+
38+
### The drift correction steps
39+
40+
The easiest way to run drift correction in SpikeInterface is with the
41+
high-level :py:func:`~spikeinterface.preprocessing.correct_motion()` function.
1242
This function takes a preprocessed recording as input and then internally runs
13-
several steps (it can be slow!) and returns a lazy
14-
recording that interpolates the traces on-the-fly to compensate for the motion.
43+
several steps and returns a lazy recording that interpolates the traces on-the-fly
44+
to compensate for the motion.
45+
46+
The
47+
:py:func:`~spikeinterface.preprocessing.correct_motion()`
48+
function provides a convenient wrapper around a number of sub-functions
49+
that together implement the full drift correction algorithm.
1550
1651
Internally this function runs the following steps:
1752
@@ -20,12 +55,25 @@
2055
| **3.** ``estimate_motion()``
2156
| **4.** ``interpolate_motion()``
2257
23-
All these sub-steps can be run with different methods and have many parameters.
24-
The high-level function suggests 3 pre-difined "presets".
58+
All these sub-steps have many parameters which dictate the
59+
speed and effectiveness of motion correction. As such, `correct_motion`
60+
provides three setting 'presets' which configure the motion correct
61+
to proceed either as:
62+
63+
* `rigid_fast` - a fast, not particularly accurate correction assuming ridigt drift.
64+
* `kilosort-like` - Mimics what is done in Kilosort (REF)
65+
* `nonrigid_accurate` - A decentralised drift correction, introduced by the Paninski group (REF)
66+
67+
**Now, let's dive into running motion correction with these three
68+
methods on a simulated dataset and interpreting the output.
69+
2570
"""
2671

72+
73+
2774
# %%
28-
# FIRST WE IMPORT AND # We will use GENERATE RECORDINGS
75+
#.. seealso::
76+
# hello world
2977

3078
from pathlib import Path
3179
import matplotlib.pyplot as plt

0 commit comments

Comments
 (0)