Skip to content

Commit

Permalink
add AnnotationSeries example to docs (#1989)
Browse files Browse the repository at this point in the history
* add AnnotationSeries example to docs

* update CHANGELOG
  • Loading branch information
stephprince authored Nov 13, 2024
1 parent 9de4d4c commit 969c65f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

### Documentation and tutorial enhancements
- Added documentation example for `SpikeEventSeries`. @stephprince [#1983](https://github.com/NeurodataWithoutBorders/pynwb/pull/1983)
- Added documentation example for `AnnotationSeries`. @stephprince [#1989](https://github.com/NeurodataWithoutBorders/pynwb/pull/1989)

### Performance
- Cache global type map to speed import 3X. @sneakers-the-rat [#1931](https://github.com/NeurodataWithoutBorders/pynwb/pull/1931)
Expand Down
22 changes: 22 additions & 0 deletions docs/gallery/general/plot_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
from pynwb import NWBHDF5IO, NWBFile, TimeSeries
from pynwb.behavior import Position, SpatialSeries
from pynwb.file import Subject
from pynwb.misc import AnnotationSeries

####################
# .. _basics_nwbfile:
Expand Down Expand Up @@ -285,6 +286,27 @@
# or using the method :py:meth:`.NWBFile.get_acquisition`:
nwbfile.get_acquisition("test_timeseries")

####################
# Other Types of Time Series
# ^^^^^^^^^^^^^^^^^^^^^^^^^^
#
# As mentioned previously, there are many subtypes of :py:class:`~pynwb.base.TimeSeries` that are used to store
# different kinds of data. One example is :py:class:`~pynwb.misc.AnnotationSeries`, a subclass of
# :py:class:`~pynwb.base.TimeSeries` that stores text-based records about the experiment. Similarly to our
# :py:class:`~pynwb.base.TimeSeries` example above, we can create an :py:class:`~pynwb.misc.AnnotationSeries`
# object with text information about a stimulus and add it to the stimulus group in
# the :py:class:`~pynwb.file.NWBFile`.

annotations = AnnotationSeries(name='airpuffs',
data=['Left Airpuff', 'Right Airpuff', 'Right Airpuff'],
description='Airpuff events delivered to the animal',
timestamps=[1.0, 3.0, 8.0])

nwbfile.add_stimulus(annotations)

####################
# This approach of creating a :py:class:`~pynwb.base.TimeSeries` object and adding it to the appropriate
# :py:class:`~pynwb.file.NWBFile` group can be used for all subtypes of :py:class:`~pynwb.base.TimeSeries` data.

####################
# .. _basic_spatialseries:
Expand Down

0 comments on commit 969c65f

Please sign in to comment.