hdmf.container module

class hdmf.container.AbstractContainer(name)

Bases: object

Parameters:name (str) – the name of this container
classmethod get_fields_conf()

The name of this Container


Traverse parent hierarchy and return first instance of the specified data_type

Parameters:data_type (str) – the data_type to search for

Changes the object ID of this Container and all of its children to a new UUID string.

Parameters:recurse (bool) – whether or not to change the object ID of this container’s children
Parameters:modified (bool) – whether or not this Container has been modified
Parameters:child (Container) – the child Container for this Container
classmethod type_hierarchy()

The source of this Container


The parent Container of this Container

class hdmf.container.Container(name)

Bases: hdmf.container.AbstractContainer

A container that can contain other containers and has special functionality for printing.

Parameters:name (str) – the name of this container
data_type = 'Container'
namespace = 'hdmf-common'
class hdmf.container.Data(name, data)

Bases: hdmf.container.AbstractContainer

A class for representing dataset containers


Get the shape of the data represented by this container :return: Shape tuple :rtype: tuple of ints


Apply DataIO object to the data held by this Data object

Parameters:dataio (DataIO) – the DataIO to apply to the data held by this Data

Transform data from the current underlying state.

This function can be used to permanently load data from disk, or convert to a different representation, such as a torch.Tensor
Parameters:func (function) – a function to transform data
data_type = 'Data'
namespace = 'hdmf-common'
class hdmf.container.DataRegion(name, data)

Bases: hdmf.container.Data


The target data that this region applies to


The region that indexes into data e.g. slice or list of indices

class hdmf.container.MultiContainerInterface(name)

Bases: hdmf.container.Container

Class that dynamically defines methods to support a Container holding multiple Containers of the same type.

To use, extend this class and create a dictionary as a class attribute with any of the following keys: * ‘attr’ to name the attribute that stores the Container instances * ‘type’ to provide the Container object type (type or list/tuple of types, type can be a docval macro) * ‘add’ to name the method for adding Container instances * ‘get’ to name the method for getting Container instances * ‘create’ to name the method for creating Container instances (only if a single type is specified)

If the attribute does not exist in the class, it will be generated. If it does exist, it should behave like a dict.

The keys ‘attr’, ‘type’, and ‘add’ are required.

Parameters:name (str) – the name of this container
class hdmf.container.Row

Bases: object

A class for representing rows from a Table.

The Table class can be indicated with the __table__. Doing so will set constructor arguments for the Row class and ensure that Row.idx is set appropriately when a Row is added to the Table. It will also add functionality to the Table class for getting Row objects.

Note, the Row class is not needed for working with Table objects. This is merely convenience functionality for working with Tables.


The index of this row in its respective Table


The Table this Row comes from

class hdmf.container.RowGetter(table)

Bases: object

A simple class for providing __getitem__ functionality that returns Row objects to a Table.

class hdmf.container.Table(columns, name, data=[])

Bases: hdmf.container.Data

Subclasses should specify the class attribute __columns__.

This should be a list of dictionaries with the following keys:

  • name the column name
  • type the type of data in this column
  • doc a brief description of what gets stored in this column

For reference, this list of dictionaries will be used with docval to autogenerate the add_row method for adding data to this table.

If __columns__ is not specified, no custom add_row method will be added.

The class attribute __defaultname__ can also be set to specify a default name for the table class. If __defaultname__ is not specified, then name will need to be specified when the class is instantiated.

A Table class can be paired with a Row class for conveniently working with rows of a Table. This pairing must be indicated in the Row class implementation. See Row for more details.

Parameters:values (dict) – the values for each column

Query a table


Produce a pandas DataFrame containing this table’s data.

classmethod from_dataframe(df, name=None, extra_ok=False)
Construct an instance of Table (or a subclass) from a pandas DataFrame. The columns of the dataframe
should match the columns defined on the Table subclass.
  • df (DataFrame) – input data
  • name (str) – the name of this container
  • extra_ok (bool) – accept (and ignore) unexpected columns on the input dataframe