hdmf.build.builders module

class hdmf.build.builders.Builder(name, parent=None, source=None)

Bases: dict

Parameters
  • name (str) – the name of the group

  • parent (Builder) – the parent builder of this Builder

  • source (str) – the source of the data in this builder e.g. file name

property path

The path of this builder.

property name

The name of this builder.

property source

The source of this builder.

property parent

The parent builder of this builder.

class hdmf.build.builders.BaseBuilder(name, attributes={}, parent=None, source=None)

Bases: Builder

Parameters
  • name (str) – The name of the builder.

  • attributes (dict) – A dictionary of attributes to create in this builder.

  • parent (GroupBuilder) – The parent builder of this builder.

  • source (str) – The source of the data represented in this builder

property location

The location of this Builder in its source.

property attributes

The attributes stored in this Builder object.

set_attribute(name, value)

Set an attribute for this group.

Parameters
  • name (str) – The name of the attribute.

  • value (None) – The attribute value.

class hdmf.build.builders.GroupBuilder(name, groups={}, datasets={}, attributes={}, links={}, parent=None, source=None)

Bases: BaseBuilder

Create a builder object for a group.

Parameters
  • name (str) – The name of the group.

  • groups (dict or list) – A dictionary or list of subgroups to add to this group. If a dict is provided, only the values are used.

  • datasets (dict or list) – A dictionary or list of datasets to add to this group. If a dict is provided, only the values are used.

  • attributes (dict) – A dictionary of attributes to create in this group.

  • links (dict or list) – A dictionary or list of links to add to this group. If a dict is provided, only the values are used.

  • parent (GroupBuilder) – The parent builder of this builder.

  • source (str) – The source of the data represented in this builder.

property source

The source of this Builder

property groups

The subgroups contained in this group.

property datasets

The datasets contained in this group.

The links contained in this group.

set_attribute(name, value)

Set an attribute for this group.

Parameters
  • name (str) – The name of the attribute.

  • value (None) – The attribute value.

set_group(builder)

Add a subgroup to this group.

Parameters

builder (GroupBuilder) – The GroupBuilder to add to this group.

set_dataset(builder)

Add a dataset to this group.

Parameters

builder (DatasetBuilder) – The DatasetBuilder to add to this group.

Add a link to this group.

Parameters

builder (LinkBuilder) – The LinkBuilder to add to this group.

is_empty()

Returns true if there are no datasets, links, attributes, and non-empty subgroups. False otherwise.

__getitem__(key)

Like dict.__getitem__, but looks in groups, datasets, attributes, and links sub-dictionaries. Key can be a posix path to a sub-builder.

get(key, default=None)

Like dict.get, but looks in groups, datasets, attributes, and links sub-dictionaries. Key can be a posix path to a sub-builder.

items()

Like dict.items, but iterates over items in groups, datasets, attributes, and links sub-dictionaries.

keys()

Like dict.keys, but iterates over keys in groups, datasets, attributes, and links sub-dictionaries.

values()

Like dict.values, but iterates over values in groups, datasets, attributes, and links sub-dictionaries.

class hdmf.build.builders.DatasetBuilder(name, data=None, dtype=None, attributes={}, maxshape=None, chunks=False, parent=None, source=None)

Bases: BaseBuilder

Create a Builder object for a dataset

Parameters
OBJECT_REF_TYPE = 'object'
REGION_REF_TYPE = 'region'
property data

The data stored in the dataset represented by this builder.

property chunks

Whether or not this dataset is chunked.

property maxshape

The max shape of this dataset.

property dtype

The data type of this dataset.

class hdmf.build.builders.LinkBuilder(builder, name=None, parent=None, source=None)

Bases: Builder

Create a builder object for a link.

Parameters
  • builder (DatasetBuilder or GroupBuilder) – The target group or dataset of this link.

  • name (str) – The name of the link

  • parent (GroupBuilder) – The parent builder of this builder

  • source (str) – The source of the data in this builder

property builder

The target builder object.

class hdmf.build.builders.ReferenceBuilder(builder)

Bases: dict

Create a builder object for a reference.

Parameters

builder (DatasetBuilder or GroupBuilder) – The group or dataset this reference applies to.

property builder

The target builder object.

class hdmf.build.builders.RegionBuilder(region, builder)

Bases: ReferenceBuilder

Create a builder object for a region reference.

Parameters
  • region (slice or tuple or list or RegionReference) – The region, i.e. slice or indices, into the target dataset.

  • builder (DatasetBuilder) – The dataset this region reference applies to.

property region

The selected region of the target dataset.