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
path

Get the path of this Builder

name

The name of this Builder

source

The source of this Builder

parent

The parent Builder of this Builder

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

Bases: hdmf.build.builders.Builder

Parameters:
  • name (str) – the name of the group
  • attributes (dict) – a dictionary of attributes to create in this group
  • parent (GroupBuilder) – the parent builder of this Builder
  • source (str) – the source of the data represented in this Builder
location

The location of this Builder in its source

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
deep_update(builder)

Merge attributes from the given BaseBuilder into this builder

Parameters:builder (BaseBuilder) – the BaseBuilder to merge attributes from
class hdmf.build.builders.GroupBuilder(name, groups={}, datasets={}, attributes={}, links={}, parent=None, source=None)

Bases: hdmf.build.builders.BaseBuilder

Create a GroupBuilder object

Parameters:
  • name (str) – the name of the group
  • groups (dict or list) – a dictionary of subgroups to create in this group
  • datasets (dict or list) – a dictionary of datasets to create in this group
  • attributes (dict) – a dictionary of attributes to create in this group
  • links (dict or list) – a dictionary of links to create in this group
  • parent (GroupBuilder) – the parent builder of this Builder
  • source (str) – the source of the data represented in this Builder
source

The source of this Builder

groups

The subgroups contained in this GroupBuilder

datasets

The datasets contained in this GroupBuilder

The datasets contained in this GroupBuilder

set_attribute(name, value)

Set an attribute for this group

Parameters:
  • name (str) – the name of the attribute
  • value (None) – the attribute value
set_builder(builder)

Add an existing builder to this this GroupBuilder

Parameters:builder (Builder) – the Builder to add to this GroupBuilder
add_dataset(name, data=None, dtype=None, attributes={}, maxshape=None, chunks=False)

Create a dataset and add it to this group

Parameters:
Returns:

the DatasetBuilder object for the dataset

Return type:

DatasetBuilder

set_dataset(builder)

Add a dataset to this group

Parameters:builder (DatasetBuilder) – the DatasetBuilder that represents this dataset
add_group(name, groups={}, datasets={}, attributes={}, links={})

Add a subgroup with the given data to this group

Parameters:
  • name (str) – the name of this subgroup
  • groups (dict) – a dictionary of subgroups to create in this subgroup
  • datasets (dict) – a dictionary of datasets to create in this subgroup
  • attributes (dict) – a dictionary of attributes to create in this subgroup
  • links (dict) – a dictionary of links to create in this subgroup
Returns:

the GroupBuilder object for the subgroup

Return type:

GroupBuilder

set_group(builder)

Add a subgroup to this group

Parameters:builder (GroupBuilder) – the GroupBuilder that represents this subgroup

Create a soft link and add it to this group

Parameters:
Returns:

the builder object for the soft link

Return type:

LinkBuilder

Add a link to this group

Parameters:builder (LinkBuilder) – the LinkBuilder that represents this link
deep_update(builder)

Recursively update subgroups in this group

is_empty()

Returns true if there are no datasets, attributes, links or subgroups that contain datasets, attributes or links. False otherwise.

__getitem__(key)

Like dict.__getitem__, but looks in groups, datasets, attributes, and links sub-dictionaries.

get(key, default=None)

Like dict.get, but looks in groups, datasets, attributes, and links sub-dictionaries.

items()

Like dict.items, but iterates over key-value pairs 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: hdmf.build.builders.BaseBuilder

Create a Builder object for a dataset

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

The data stored in the dataset represented by this builder

chunks

Whether or not this dataset is chunked

maxshape

The max shape of this object

dtype

The data type of this object

deep_update(dataset)

Merge data and attributes from given DatasetBuilder into this DatasetBuilder

Parameters:dataset (DatasetBuilder) – the DatasetBuilder to merge into this DatasetBuilder
class hdmf.build.builders.LinkBuilder(builder, name=None, parent=None, source=None)

Bases: hdmf.build.builders.Builder

Parameters:
  • builder (DatasetBuilder or GroupBuilder) – the target of this link
  • name (str) – the name of the dataset
  • parent (GroupBuilder) – the parent builder of this Builder
  • source (str) – the source of the data in this builder
builder

The target builder object

class hdmf.build.builders.ReferenceBuilder(builder)

Bases: dict

Parameters:builder (DatasetBuilder or GroupBuilder) – the Dataset this region applies to
builder

The target builder object

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

Bases: hdmf.build.builders.ReferenceBuilder

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 applies to
region

The target builder object