Skip to content

Commit 00483f3

Browse files
authored
Merge pull request #797 from NeurodataWithoutBorders/units-clustering-docs-794
Deprecate Clustering/ClusterWaveform (in favor of misc.Units)
2 parents e3b9671 + be527d5 commit 00483f3

File tree

6 files changed

+49
-42
lines changed

6 files changed

+49
-42
lines changed

docs/gallery/domain/ecephys.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@
8686
# Extracellular recordings
8787
# ^^^^^^^^^^^^^^^^^^^^^^^^
8888
#
89-
# The two main classes for storing extracellular recordings are :py:class:`~pynwb.ecephys.ElectricalSeries`
89+
# The main classes for storing extracellular recordings are :py:class:`~pynwb.ecephys.ElectricalSeries`
9090
# and :py:class:`~pynwb.ecephys.SpikeEventSeries`. :py:class:`~pynwb.ecephys.ElectricalSeries` should be used
9191
# for storing raw voltage traces, local-field potential and filtered voltage traces and
92-
# :py:class:`~pynwb.ecephys.SpikeEventSeries` is meant for storing spike waveforms.
92+
# :py:class:`~pynwb.ecephys.SpikeEventSeries` is meant for storing spike waveforms (typically in preparation for
93+
# clustering). The results of spike clustering (e.g. per-unit metadata and spike times) should be stored in the
94+
# top-level :py:class:`~pynwb.misc.Units` table.
9395
#
9496
# In addition to the *data* and *timestamps* fields inherited
9597
# from :py:class:`~pynwb.base.TimeSeries` class, these two classs will require metadata about the elctrodes
@@ -154,13 +156,17 @@
154156
# using these objects.
155157
#
156158
# For storing spike data, there are two options. Which one you choose depends on what data you have available.
157-
# If you need to store the raw voltage traces, you should store your the traces with
159+
# If you need to store the complete, continuous raw voltage traces, you should store your the traces with
158160
# :py:class:`~pynwb.ecephys.ElectricalSeries` objects as :ref:`acquisition <basic_timeseries>` data, and use
159161
# the :py:class:`~pynwb.ecephys.EventDetection` class for identifying the spike events in your raw traces.
160-
# If you do not want to store the raw voltage traces and only the spike events, you should use
161-
# the :py:class:`~pynwb.ecephys.EventWaveform` class, which can store one or more
162+
# If you do not want to store the raw voltage traces and only the waveform 'snippets' surrounding spike events,
163+
# you should use the :py:class:`~pynwb.ecephys.EventWaveform` class, which can store one or more
162164
# :py:class:`~pynwb.ecephys.SpikeEventSeries` objects.
163165
#
166+
# The results of spike sorting (or clustering) should be stored in the top-level :py:class:`~pynwb.misc.Units` table.
167+
# Note that it is not required to store spike waveforms in order to store spike events or waveforms--if you only
168+
# want to store the spike times of clustered units you can use only the Units table.
169+
#
164170
# For local field potential data, there are two options. Again, which one you choose depends on what data you
165171
# have available. With both options, you should store your traces with :py:class:`~pynwb.ecephys.ElectricalSeries`
166172
# objects. If you are storing unfiltered local field potential data, you should store

docs/gallery/general/file.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@
9696
# ------------------
9797
#
9898
# *Processing modules* are used for storing a set of data interfaces that are related to a particular
99-
# processing workflow. For example, if you want to store intermediate and final results of a spike sorting workflow,
100-
# you would create a :py:class:`~pynwb.base.ProcessingModule` that contains data interfaces that represent
101-
# the common steps in spike sorting e.g. :py:class:`~pynwb.ecephys.EventDetection`,
102-
# :py:class:`~pynwb.ecephys.EventWaveform`, :py:class:`~pynwb.ecephys.FeatureExtraction`,
103-
# :py:class:`~pynwb.ecephys.Clustering`, :py:class:`~pynwb.ecephys.ClusterWaveform`.
99+
# processing workflow. For example, if you want to store the intermediate results of a spike sorting workflow,
100+
# you could create a :py:class:`~pynwb.base.ProcessingModule` that contains data interfaces that represent
101+
# the common first steps in spike sorting e.g. :py:class:`~pynwb.ecephys.EventDetection`,
102+
# :py:class:`~pynwb.ecephys.EventWaveform`, :py:class:`~pynwb.ecephys.FeatureExtraction`. The final results of
103+
# the sorting could then be stored in the top-level :py:class:`~pynwb.misc.Units` table (see below).
104104
#
105105
# Processing modules can be created using :py:func:`~pynwb.file.NWBFile.create_processing_module`:
106106

@@ -198,9 +198,12 @@
198198
nwbfile.add_unit_column('location', 'the anatomical location of this unit')
199199
nwbfile.add_unit_column('quality', 'the quality for the inference of this unit')
200200

201-
nwbfile.add_unit(id=1, spike_times=[2.2, 3.0, 4.5], obs_intervals=[[1, 10]], location='CA1', quality=0.95)
202-
nwbfile.add_unit(id=2, spike_times=[2.2, 3.0, 25.0, 26.0], obs_intervals=[[1, 10], [20, 30]], location='CA3', quality=0.85)
203-
nwbfile.add_unit(id=3, spike_times=[1.2, 2.3, 3.3, 4.5], obs_intervals=[[1, 10], [20, 30]], location='CA1', quality=0.90)
201+
nwbfile.add_unit(id=1, spike_times=[2.2, 3.0, 4.5],
202+
obs_intervals=[[1, 10]], location='CA1', quality=0.95)
203+
nwbfile.add_unit(id=2, spike_times=[2.2, 3.0, 25.0, 26.0],
204+
obs_intervals=[[1, 10], [20, 30]], location='CA3', quality=0.85)
205+
nwbfile.add_unit(id=3, spike_times=[1.2, 2.3, 3.3, 4.5],
206+
obs_intervals=[[1, 10], [20, 30]], location='CA1', quality=0.90)
204207

205208
####################
206209
# .. _units_fields_ref:

docs/source/extensions.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ Extend an existing type
123123
attributes=addl_attributes,
124124
datasets=addl_datasets,
125125
groups=addl_groups,
126-
neurodata_type_inc='Clustering',
127-
neurodata_type_def='MyExtendedClustering')
126+
neurodata_type_inc='SpikeEventSeries',
127+
neurodata_type_def='MyExtendedSpikeEventSeries')
128128
129129
Existing types can be instantiated by specifying `neurodata_type_inc` alone.
130130

@@ -139,8 +139,8 @@ Existing types can be instantiated by specifying `neurodata_type_inc` alone.
139139
140140
spec = NWBGroupSpec('An extended NWB type',
141141
groups=addl_groups,
142-
neurodata_type_inc='Clustering',
143-
neurodata_type_def='MyExtendedClustering')
142+
neurodata_type_inc='SpikeEventSeries',
143+
neurodata_type_def='MyExtendedSpikeEventSeries')
144144
145145
146146
Datasets can be extended in the same manner (with regard to `neurodata_type_inc` and `neurodata_type_def`,
@@ -169,19 +169,19 @@ Create a new namespace with extensions
169169
ns_builder = NWBNamespaceBuilder("Extension for use in my laboratory", "mylab", ...)
170170
171171
# create extensions
172-
ext1 = NWBGroupSpec('A custom Clustering interface',
172+
ext1 = NWBGroupSpec('A custom SpikeEventSeries interface',
173173
attributes=[...]
174174
datasets=[...],
175175
groups=[...],
176-
neurodata_type_inc='Clustering',
177-
neurodata_type_def='MyExtendedClustering')
176+
neurodata_type_inc='SpikeEventSeries',
177+
neurodata_type_def='MyExtendedSpikeEventSeries')
178178
179-
ext2 = NWBGroupSpec('A custom ClusterWaveforms interface',
179+
ext2 = NWBGroupSpec('A custom EventDetection interface',
180180
attributes=[...]
181181
datasets=[...],
182182
groups=[...],
183-
neurodata_type_inc='ClusterWaveforms',
184-
neurodata_type_def='MyExtendedClusterWaveforms')
183+
neurodata_type_inc='EventDetection',
184+
neurodata_type_def='MyExtendedEventDetection')
185185
186186
187187
# add the extension

docs/source/overview_nwbfile.rst

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,13 @@ Processing module objects are unique collections of analysis results. To standar
7272
common analyses, NWB provides the concept of an *NWBDataInterface*, where the output of
7373
common analyses are represented as objects that extend the :py:class:`~pynwb.core.NWBDataInterface` class.
7474
In most cases, you will not need to interact with the :py:class:`~pynwb.core.NWBDataInterface` class directly.
75-
More commonly, you will be creating instances of classes that extend this class. For example, a common
76-
analysis step for spike data (represented in NWB as a :py:class:`~pynwb.ecephys.SpikeEventSeries` object)
77-
is spike clustering. In NWB, the result of this kind of analysis will be represented with a
78-
:py:class:`~pynwb.ecephys.Clustering` object.
75+
More commonly, you will be creating instances of classes that extend this class.
7976

8077
The following analysis :py:class:`~pynwb.core.NWBDataInterface` objects are provided by the API and NWB specification:
8178

8279
* :py:class:`~pynwb.behavior.BehavioralEpochs`
8380
* :py:class:`~pynwb.behavior.BehavioralEvents`
8481
* :py:class:`~pynwb.behavior.BehavioralTimeSeries`
85-
* :py:class:`~pynwb.ecephys.ClusterWaveforms`
86-
* :py:class:`~pynwb.ecephys.Clustering`
8782
* :py:class:`~pynwb.behavior.CompassDirection`
8883
* :py:class:`~pynwb.ophys.DfOverF`
8984
* :py:class:`~pynwb.ecephys.EventDetection`

src/pynwb/data/nwb.ecephys.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,18 @@ groups:
9494
- null
9595
- neurodata_type_def: ClusterWaveforms
9696
neurodata_type_inc: NWBDataInterface
97-
doc: 'The mean waveform shape, including standard deviation, of the different clusters.
98-
Ideally, the waveform analysis should be performed on data that is only high-pass
99-
filtered. This is a separate module because it is expected to require updating.
100-
For example, IMEC probes may require different storage requirements to store/display
101-
mean waveforms, requiring a new interface or an extension of this one.'
97+
doc: 'DEPRECATED The mean waveform shape, including standard deviation, of the
98+
different clusters. Ideally, the waveform analysis should be performed on data that
99+
is only high-pass filtered. This is a separate module because it is expected to require
100+
updating. For example, IMEC probes may require different storage requirements to
101+
store/display mean waveforms, requiring a new interface or an extension of this one.'
102102
attributes:
103103
- name: help
104104
dtype: text
105105
doc: Value is 'Mean waveform shape of clusters. Waveforms should be high-pass
106106
filtered (ie, not the same bandpass filter used waveform analysis and clustering)'
107-
value: Mean waveform shape of clusters. Waveforms should be high-pass filtered
108-
(ie, not the same bandpass filter used waveform analysis and clustering)
107+
value: DEPRECATED Mean waveform shape of clusters. Waveforms should be high-pass
108+
filtered (ie, not the same bandpass filter used waveform analysis and clustering)
109109
datasets:
110110
- name: waveform_filtering
111111
dtype: text
@@ -138,15 +138,15 @@ groups:
138138
default_name: ClusterWaveforms
139139
- neurodata_type_def: Clustering
140140
neurodata_type_inc: NWBDataInterface
141-
doc: Clustered spike data, whether from automatic clustering tools (e.g., klustakwik)
142-
or as a result of manual sorting.
141+
doc: DEPRECATED Clustered spike data, whether from automatic clustering tools (e.g.,
142+
klustakwik) or as a result of manual sorting.
143143
attributes:
144144
- name: help
145145
dtype: text
146146
doc: Value is 'Clustered spike data, whether from automatic clustering tools (eg,
147147
klustakwik) or as a result of manual sorting'
148-
value: Clustered spike data, whether from automatic clustering tools (eg, klustakwik)
149-
or as a result of manual sorting
148+
value: DEPRECATED Clustered spike data, whether from automatic clustering tools
149+
(eg, klustakwik) or as a result of manual sorting
150150
datasets:
151151
- name: description
152152
dtype: text

src/pynwb/ecephys.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ class EventWaveform(MultiContainerInterface):
204204
@register_class('Clustering', CORE_NAMESPACE)
205205
class Clustering(NWBDataInterface):
206206
"""
207+
DEPRECATED in favor of :py:meth:`~pynwb.misc.Units`.
207208
Specifies cluster event times and cluster metric for maximum ratio of
208209
waveform peak to RMS on any channel in cluster.
209210
"""
@@ -215,7 +216,7 @@ class Clustering(NWBDataInterface):
215216
'times'
216217
)
217218

218-
__help = ("Clustered spike data, whether from automatic clustering "
219+
__help = ("[DEPRECATED] Clustered spike data, whether from automatic clustering "
219220
"tools (eg, klustakwik) or as a result of manual sorting.")
220221

221222
@docval({'name': 'description', 'type': str,
@@ -229,6 +230,8 @@ class Clustering(NWBDataInterface):
229230
'shape': (None,)},
230231
{'name': 'name', 'type': str, 'doc': 'the name of this container', 'default': 'Clustering'})
231232
def __init__(self, **kwargs):
233+
import warnings
234+
warnings.warn("use pynwb.misc.Units or NWBFile.units instead", DeprecationWarning)
232235
description, num, peak_over_rms, times = popargs(
233236
'description', 'num', 'peak_over_rms', 'times', kwargs)
234237
super(Clustering, self).__init__(**kwargs)
@@ -254,7 +257,7 @@ class ClusterWaveforms(NWBDataInterface):
254257
'waveform_mean',
255258
'waveform_sd')
256259

257-
__help = ("Mean waveform shape of clusters. Waveforms should be "
260+
__help = ("[DEPRECATED] Mean waveform shape of clusters. Waveforms should be "
258261
"high-pass filtered (ie, not the same bandpass filter "
259262
"used waveform analysis and clustering)")
260263

0 commit comments

Comments
 (0)