Skip to content

Commit

Permalink
fixing up tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
bendichter committed Jan 30, 2024
1 parent 2798be0 commit cff1f6e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions docs/gallery/advanced_io/plot_editing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
common types of edits for HDF5 files. Keep in mind that any edit to an existing NWB file
make it no longer a valid NWB file. We call this "doing surgery" on the NWB file.
We highly recommend making a copy before editing and running a validation check on the
file after editing it.
file after editing it. See :ref:`validating`.
In-place editing with h5py
---------------------------
Expand Down Expand Up @@ -69,19 +69,24 @@
##############################################
# .. warning::
# You can edit values that will bring the file out of compliance with
# the NWB specification. For example:
#
# with h5py.File("test_edit.nwb", "r+") as f:
# f["acquisition"]["synthetic_timeseries"]["neurodata_type"] = "TimeSeries"
# the NWB specification.
#
# Renaming groups and datasets
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Rename groups and datasets in-place using the ``move`` method. For example, to rename
# the ``"synthetic_timeseries"`` group:

with h5py.File("test_edit2.nwb", "r+") as f:
with h5py.File("test_edit.nwb", "r+") as f:
f["acquisition"].move("synthetic_timeseries", "synthetic_timeseries_renamed")

##############################################
# You can use this same technique to move a group or dataset to a different location in
# the file. For example, to move the ``"synthetic_timeseries_renamed"`` group to the
# ``"analysis"`` group:

with h5py.File("test_edit.nwb", "r+") as f:
f["acquisition"].move("synthetic_timeseries_renamed", "/analysis/synthetic_timeseries_renamed")

##############################################
# Changing the shape of dataset
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -91,7 +96,7 @@
# ``maxshape`` argument of the :py:class:`~hdmf.backends.hdf5.h5_utils.H5DataIO` class
# constructor. Using a ``None`` value for ``maxshape`` allows the dataset to be reset
# arbitrarily long in that dimension. Chunking is required for datasets with flexible
# shapes. Setting ``maxshape`` automatically sets chunking to ``True`, if not specified.
# shapes. Setting ``maxshape`` automatically sets chunking to ``True``, if not specified.
#
# First, let's create an NWB file with a dataset with a flexible shape:

Expand Down

0 comments on commit cff1f6e

Please sign in to comment.