From 969c65fa27323e909f6e6d3c959be56dba52755b Mon Sep 17 00:00:00 2001 From: Steph Prince <40640337+stephprince@users.noreply.github.com> Date: Wed, 13 Nov 2024 03:18:46 -0800 Subject: [PATCH] add AnnotationSeries example to docs (#1989) * add AnnotationSeries example to docs * update CHANGELOG --- CHANGELOG.md | 1 + docs/gallery/general/plot_file.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4400300de..23495df7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/docs/gallery/general/plot_file.py b/docs/gallery/general/plot_file.py index b410d4b69..d80db10ac 100644 --- a/docs/gallery/general/plot_file.py +++ b/docs/gallery/general/plot_file.py @@ -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: @@ -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: