diff --git a/CHANGELOG.md b/CHANGELOG.md index 303ce8b3e..47eb63ee3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ ### Bug fixes: - Add `environment-ros3.yml` to `MANIFEST.in` for inclusion in source distributions. @rly (#1398) +### Tutorial enhancements: +- Updated the general tutorial to add documentation about the ``Images`` type. @bendichter (#1353) + ## PyNWB 2.0.0 (August 13, 2021) ### Breaking changes: diff --git a/docs/gallery/general/file.py b/docs/gallery/general/file.py index 615898c0e..db8b64fbb 100644 --- a/docs/gallery/general/file.py +++ b/docs/gallery/general/file.py @@ -411,12 +411,6 @@ 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) -#################### -# Now we overwrite the file with all of the data - -with NWBHDF5IO('example_file_path.nwb', 'w') as io: - io.write(nwbfile) - #################### # .. _units_fields_ref: # @@ -424,6 +418,54 @@ # The Units table has some predefined optional columns. Please review the documentation for # :py:meth:`~pynwb.file.NWBFile.add_unit` before adding custom columns. +#################### +# Images +# ------ +# +# You can store static images within the NWB file as well. These can be images of the subject, the environment, stimuli, +# or really anything. +# +# .. note:: +# All basic image types :py:class:`~pynwb.image.RGBAImage`, py:class:`~pynwb.image.RGBImage`, and +# py:class:`~pynwb.image.GrayscaleImage` provide the optional: 1) ``description`` parameter to include a +# text description about the image and 2) ``resolution`` parameter to specify the *pixels / cm* resolution +# of the image. + +from PIL import Image +import numpy as np + +from pynwb.image import RGBAImage, RGBImage, GrayscaleImage +from pynwb.base import Images + +img = Image.open('docs/source/logo.png') # an example image + +# you can store an RGBA image +rgba_logo = RGBAImage(name='RGBA_logo', data=np.array(img)) + +# or RGB +rgb_logo = RGBImage(name='RGB_logo', data=np.array(img.convert('RGB'))) + +# or Grayscale. Here with the optional description and resolution specified. +gs_logo = GrayscaleImage(name='Grayscale_logo', + data=np.array(img.convert('L')), + description='Grayscale version of the NWB logo', + resolution=35.433071) + +# Images is a container that accepts any of these image types +images = Images( + name='logo_images', + images=[rgb_logo, rgba_logo, gs_logo] +) + +# Finally, do not forget to add the images object to the nwb file. +nwbfile.processing['behavior'].add(images) + +#################### +# Now we overwrite the file with all of the data + +with NWBHDF5IO('example_file_path.nwb', 'w') as io: + io.write(nwbfile) + #################### # .. _basic_appending: # diff --git a/docs/source/conf.py b/docs/source/conf.py index 70c2afb4c..8c55edcca 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -157,7 +157,9 @@ # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -# html_theme_options = {} +html_theme_options = { + "style_nav_header_background": "#AFD2E8" +} # Add any paths that contain custom themes here, relative to this directory. # html_theme_path = [] diff --git a/docs/source/logo.png b/docs/source/logo.png index f996571d6..21f1ed189 100644 Binary files a/docs/source/logo.png and b/docs/source/logo.png differ diff --git a/requirements-doc.txt b/requirements-doc.txt index 7ae6261cb..938e94622 100644 --- a/requirements-doc.txt +++ b/requirements-doc.txt @@ -4,3 +4,4 @@ matplotlib sphinx_rtd_theme sphinx-gallery allensdk>=2.11.0 # python 3.8 is not supported in allensdk<2.11 +Pillow