Skip to content

Commit 3c0dbfa

Browse files
stephprincerly
andauthored
Add documentation for SpikeEventSeries (#1983)
Co-authored-by: Ryan Ly <[email protected]>
1 parent 1bdffe8 commit 3c0dbfa

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## PyNWB 2.8.3 (Upcoming)
44

5+
### Documentation and tutorial enhancements
6+
- Added documentation example for `SpikeEventSeries`. @stephprince [#1983](https://github.com/NeurodataWithoutBorders/pynwb/pull/1983)
7+
58
### Performance
69
- Cache global type map to speed import 3X. @sneakers-the-rat [#1931](https://github.com/NeurodataWithoutBorders/pynwb/pull/1931)
710

docs/gallery/domain/ecephys.py

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from dateutil.tz import tzlocal
3232

3333
from pynwb import NWBHDF5IO, NWBFile
34-
from pynwb.ecephys import LFP, ElectricalSeries
34+
from pynwb.ecephys import LFP, ElectricalSeries, SpikeEventSeries
3535

3636
#######################
3737
# Creating and Writing NWB files
@@ -244,8 +244,8 @@
244244
####################
245245
# .. _units_electrode:
246246
#
247-
# Spike Times
248-
# ^^^^^^^^^^^
247+
# Sorted spike times
248+
# ^^^^^^^^^^^^^^^^^^
249249
#
250250
# Spike times are stored in the :py:class:`~pynwb.misc.Units` table, which is a subclass of
251251
# :py:class:`~hdmf.common.table.DynamicTable`. Adding columns to the :py:class:`~pynwb.misc.Units` table is analogous
@@ -272,6 +272,29 @@
272272

273273
nwbfile.units.to_dataframe()
274274

275+
####################
276+
# Unsorted spike times
277+
# ^^^^^^^^^^^^^^^^^^^^
278+
#
279+
# While the :py:class:`~pynwb.misc.Units` table is used to store spike times and waveform data for
280+
# spike-sorted, single-unit activity, you may also want to store spike times and waveform snippets of
281+
# unsorted spiking activity (e.g., multi-unit activity detected via threshold crossings during data acquisition).
282+
# This information can be stored using :py:class:`~pynwb.ecephys.SpikeEventSeries` objects.
283+
284+
spike_snippets = np.random.rand(20, 3, 40) # 20 events, 3 channels, 40 samples per event
285+
shank0 = nwbfile.create_electrode_table_region(
286+
region=[0, 1, 2],
287+
description="shank0",
288+
)
289+
290+
291+
spike_events = SpikeEventSeries(name='SpikeEvents_Shank0',
292+
description="events detected with 100uV threshold",
293+
data=spike_snippets,
294+
timestamps=np.arange(20),
295+
electrodes=shank0)
296+
nwbfile.add_acquisition(spike_events)
297+
275298
#######################
276299
# Designating electrophysiology data
277300
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -283,17 +306,17 @@
283306
# :py:mod:`API documentation <pynwb.ecephys>` and :ref:`basics` for more details on
284307
# using these objects.
285308
#
286-
# For storing spike data, there are two options. Which one you choose depends on what data you have available.
287-
# If you need to store the complete, continuous raw voltage traces, you should store the traces with
309+
# For storing unsorted spiking data, there are two options. Which one you choose depends on what data you
310+
# have available. If you need to store the complete, continuous raw voltage traces, you should store the traces with
288311
# :py:class:`~pynwb.ecephys.ElectricalSeries` objects as :ref:`acquisition <basic_timeseries>` data, and use
289312
# the :py:class:`~pynwb.ecephys.EventDetection` class for identifying the spike events in your raw traces.
290313
# If you do not want to store the raw voltage traces and only the waveform 'snippets' surrounding spike events,
291-
# you should use the :py:class:`~pynwb.ecephys.EventWaveform` class, which can store one or more
292-
# :py:class:`~pynwb.ecephys.SpikeEventSeries` objects.
314+
# you should use :py:class:`~pynwb.ecephys.SpikeEventSeries` objects.
293315
#
294316
# The results of spike sorting (or clustering) should be stored in the top-level :py:class:`~pynwb.misc.Units` table.
295-
# Note that it is not required to store spike waveforms in order to store spike events or mean waveforms--if you only
296-
# want to store the spike times of clustered units you can use only the Units table.
317+
# The :py:class:`~pynwb.misc.Units` table can contain simply the spike times of sorted units, or you can also include
318+
# individual and mean waveform information in some of the optional, predefined :py:class:`~pynwb.misc.Units` table
319+
# columns: ``waveform_mean``, ``waveform_sd``, or ``waveforms``.
297320
#
298321
# For local field potential data, there are two options. Again, which one you choose depends on what data you
299322
# have available. With both options, you should store your traces with :py:class:`~pynwb.ecephys.ElectricalSeries`

0 commit comments

Comments
 (0)