form.backends.hdf5.h5tools module

class form.backends.hdf5.h5tools.HDF5IO(path, manager=None, mode=a)

Bases: form.backends.io.FORMIO

Open an HDF5 file for IO

For mode, see Write an NWBFile
Parameters:
  • path (str) – the path to the HDF5 file to write to
  • manager (BuildManager) – the BuildManager to use for I/O
  • mode (str) – the mode to open the HDF5 file with, one of (“w”, “r”, “r+”, “a”, “w-”)
close()
open()
read_builder()
Returns:a GroupBuilder representing the NWB Dataset
Return type:GroupBuilder
write_builder(builder)
Parameters:builder (GroupBuilder) – the GroupBuilder object representing the NWBFile
form.backends.hdf5.h5tools.get_type(data)
form.backends.hdf5.h5tools.isinstance_inmemory_array(data)

Check if an object is a common in-memory data structure

form.backends.hdf5.h5tools.set_attributes(obj, attributes)
Parameters:
  • obj (Group or Dataset) – the HDF5 object to add attributes to
  • attributes (dict) – a dict containing the attributes on the Group, indexed by attribute name
form.backends.hdf5.h5tools.write_dataset(parent, name, data, attributes, dtype=None)

Write a dataset to HDF5

The function uses other dataset-dependent write functions, e.g, __scalar_fill__, __list_fill__ and __chunked_iter_fill__ to write the data.
Parameters:
  • parent (Group) – the parent HDF5 object
  • name (str) – the name of the Dataset to write
  • data (str or DataChunkIterator or float or int or Iterable) – the data object to be written
  • attributes (dict) – a dict containing the attributes on the Dataset, indexed by attribute name
  • dtype (type or str or list) – the default dtype to use, if it cannot be inferred
Returns:

the Dataset that was created

Return type:

Dataset

form.backends.hdf5.h5tools.write_group(parent, name, subgroups, datasets, attributes, links)
Parameters:
  • parent (Group) – the parent HDF5 object
  • name (str) – the name of the Dataset to write
  • subgroups (dict) – a dict containing GroupBuilders for subgroups in this group, indexed by group name
  • datasets (dict) – a dict containing DatasetBuilders for datasets in this group, indexed by dataset name
  • attributes (dict) – a dict containing the attributes on the Group, indexed by attribute name
  • links (dict) – a dict containing LinkBuilders for links in this group, indexed by link name
Returns:

the Group that was created

Return type:

Group

Parameters:
  • parent (Group) – the parent HDF5 object
  • name (str) – the name of the Link to write
  • target_builder (DatasetBuilder or GroupBuilder) – the Builder representing the target
Returns:

the Link that was created

Return type:

Link