Skip to content

Commit 0d66e88

Browse files
committed
Try to add plots on probe.
1 parent c674c6f commit 0d66e88

17 files changed

+139
-188
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

doc/long_tutorials/handle_drift/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ rst (TODO: fill in filename) that
1515
sphinx-gallery generates.
1616

1717

18+
1819
.. raw:: html
1920

2021
<div class="sphx-glr-thumbnails">
@@ -23,7 +24,7 @@ sphinx-gallery generates.
2324
2425
.. raw:: html
2526

26-
<div class="sphx-glr-thumbcontainer" tooltip="Spikeinterface offers a very flexible framework to handle drift as a preprocessing step. If you...">
27+
<div class="sphx-glr-thumbcontainer" tooltip="When running in vivo electrophysiology recordings, movement of the probe is an inevitability, e...">
2728

2829
.. only:: html
2930

doc/long_tutorials/handle_drift/plot_handle_drift.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"\n# Handle motion/drift with spikeinterface NEW\n\nSpikeinterface offers a very flexible framework to handle drift as a preprocessing step.\nIf you want to know more, please read the\n`motion_correction` section of the documentation.\n\nHere is a short demo on how to handle drift using the high-level function\n:py:func:`~spikeinterface.preprocessing.correct_motion()`.\n\nThis function takes a preprocessed recording as input and then internally runs\nseveral steps (it can be slow!) and returns a lazy\nrecording that interpolates the traces on-the-fly to compensate for the motion.\n\nInternally this function runs the following steps:\n\n| **1.** ``localize_peaks()``\n| **2.** ``select_peaks()`` (optional)\n| **3.** ``estimate_motion()``\n| **4.** ``interpolate_motion()``\n\nAll these sub-steps can be run with different methods and have many parameters.\nThe high-level function suggests 3 pre-difined \"presets\".\n"
7+
"\n# Handle motion/drift with spikeinterface NEW\n\nWhen running *in vivo* electrophysiology recordings, movement of the probe is\nan inevitability, especially when the subjects are not head-fixed. SpikeInterface\nincludes a number of popular methods to compensate for probe motion during the\npreprocessing step.\n\n### What is drift and where does it come from?\n\nMovement of the probe means that the spikes recorded on the probe 'drift' along it.\nTypically, this motion is vertical along the probe (along the 'y' axis) which\nmanifests as the units moving long the probe in space.\n\nAll common motion-correction methods address this vertical drift. Horizontal ('x')\nor forward/backwards ('z') motion, that would appear as the amplitude of a unit\nchanging over time, are much harder to model and not handled in available motion-correction algorithms.\nFortunately, vertical drift is the most common form of motion as the probe is\nmore likely to move along the path it was inserted, rather than in other directions\nwhere it is buffeted against the brain.\n\nVertical drift can come in two forms, 'rigid' and 'non-rigid'. Rigid drift\nis drift caused by movement of the entire probe and the motion is the\nsame for all points along the probe. Non-rigid drift is instead caused by\nlocal movement of parts of the brain along the probe, and can affect\nthe recording at only certain points along the probe.\n\n### How SpikeInterface handles drift\n\nSpikeinterface offers a very flexible framework to handle drift as a\npreprocessing step. In this tutorial we will cover the three main\ndrift-correction algorithms implemented in SpikeInterface with\na focus on running the methods and interpreting the output. For\nmore information on the theory and implementation of these methods,\nsee the `motion_correction` section of the documentation.\n\n### The drift correction steps\n\nThe easiest way to run drift correction in SpikeInterface is with the\nhigh-level :py:func:`~spikeinterface.preprocessing.correct_motion()` function.\nThis function takes a preprocessed recording as input and then internally runs\nseveral steps and returns a lazy recording that interpolates the traces on-the-fly\nto compensate for the motion.\n\nThe\n:py:func:`~spikeinterface.preprocessing.correct_motion()`\nfunction provides a convenient wrapper around a number of sub-functions\nthat together implement the full drift correction algorithm.\n\nInternally this function runs the following steps:\n\n| **1.** ``localize_peaks()``\n| **2.** ``select_peaks()`` (optional)\n| **3.** ``estimate_motion()``\n| **4.** ``interpolate_motion()``\n\nAll these sub-steps have many parameters which dictate the\nspeed and effectiveness of motion correction. As such, `correct_motion`\nprovides three setting 'presets' which configure the motion correct\nto proceed either as:\n\n* `rigid_fast` - a fast, not particularly accurate correction assuming ridigt drift.\n* `kilosort-like` - Mimics what is done in Kilosort (REF)\n* `nonrigid_accurate` - A decentralised drift correction, introduced by the Paninski group (REF)\n\n**Now, let's dive into running motion correction with these three\nmethods on a simulated dataset and interpreting the output.\n"
88
]
99
},
1010
{
1111
"cell_type": "markdown",
1212
"metadata": {},
1313
"source": [
14-
"FIRST WE IMPORT AND # We will use GENERATE RECORDINGS\n\n"
14+
".. seealso::\n hello world\n\n"
1515
]
1616
},
1717
{

doc/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

doc/long_tutorials/handle_drift/plot_handle_drift.py.md5

Lines changed: 0 additions & 1 deletion
This file was deleted.

doc/long_tutorials/handle_drift/plot_handle_drift.rst

Lines changed: 73 additions & 170 deletions
Large diffs are not rendered by default.
Binary file not shown.

doc/long_tutorials/handle_drift/sg_execution_times.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
Computation times
88
=================
9-
**42:27.561** total execution time for 1 file **from long_tutorials/handle_drift**:
9+
**00:00.000** total execution time for 1 file **from long_tutorials\handle_drift**:
1010

1111
.. container::
1212

@@ -33,5 +33,5 @@ Computation times
3333
- Time
3434
- Mem (MB)
3535
* - :ref:`sphx_glr_long_tutorials_handle_drift_plot_handle_drift.py` (``plot_handle_drift.py``)
36-
- 42:27.561
36+
- 00:00.000
3737
- 0.0

0 commit comments

Comments
 (0)