|
2 | 2 | Handle motion/drift with spikeinterface NEW
|
3 | 3 | ===========================================
|
4 | 4 |
|
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. |
12 | 42 | 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. |
15 | 50 |
|
16 | 51 | Internally this function runs the following steps:
|
17 | 52 |
|
|
20 | 55 | | **3.** ``estimate_motion()``
|
21 | 56 | | **4.** ``interpolate_motion()``
|
22 | 57 |
|
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 | +
|
25 | 70 | """
|
26 | 71 |
|
| 72 | + |
| 73 | + |
27 | 74 | # %%
|
28 |
| -# FIRST WE IMPORT AND # We will use GENERATE RECORDINGS |
| 75 | +#.. seealso:: |
| 76 | +# hello world |
29 | 77 |
|
30 | 78 | from pathlib import Path
|
31 | 79 | import matplotlib.pyplot as plt
|
|
0 commit comments