hdmf.container module¶
- class hdmf.container.AbstractContainer(name)¶
Bases:
object- Parameters
name (
str) – the name of this container
- classmethod get_fields_conf()¶
- property name¶
The name of this Container
- get_ancestor(data_type=None)¶
Traverse parent hierarchy and return first instance of the specified data_type
- Parameters
data_type (
str) – the data_type to search for
- property fields¶
- property object_id¶
- generate_new_id(recurse=True)¶
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
- property modified¶
- set_modified(modified=True)¶
- Parameters
modified (
bool) – whether or not this Container has been modified
- property children¶
- classmethod type_hierarchy()¶
- property container_source¶
The source of this Container
- property parent¶
The parent Container of this Container
- reset_parent()¶
Reset the parent of this Container to None and remove the Container from the children of its parent.
Use with caution. This can result in orphaned containers and broken links.
- class hdmf.container.Container(name)¶
Bases:
AbstractContainerA 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:
AbstractContainerA class for representing dataset containers
- Parameters
name (
str) – the name of this containerdata (
strorintorfloatorbytesorboolorndarrayorlistortupleorDatasetorStrDatasetorHDMFDatasetorAbstractDataChunkIteratororDataIO) – the source of the data
- property data¶
- property shape¶
Get the shape of the data represented by this container :return: Shape tuple :rtype: tuple of ints
- set_dataio(dataio)¶
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(func)¶
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
- __getitem__(args)¶
- get(args)¶
- append(arg)¶
- extend(arg)¶
The extend_data method adds all the elements of the iterable arg to the end of the data of this Data container.
- Parameters
arg – The iterable to add to the end of this VectorData
- data_type = 'Data'¶
- namespace = 'hdmf-common'¶
- class hdmf.container.DataRegion(name, data)¶
Bases:
Data- Parameters
name (
str) – the name of this containerdata (
strorintorfloatorbytesorboolorndarrayorlistortupleorDatasetorStrDatasetorHDMFDatasetorAbstractDataChunkIteratororDataIO) – the source of the data
- abstract property data¶
The target data that this region applies to
- abstract property region¶
The region that indexes into data e.g. slice or list of indices
- class hdmf.container.MultiContainerInterface(name)¶
Bases:
ContainerClass 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:
objectA 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.
- property idx¶
The index of this row in its respective Table
- property table¶
The Table this Row comes from
- class hdmf.container.RowGetter(table)¶
Bases:
objectA simple class for providing __getitem__ functionality that returns Row objects to a Table.
- __getitem__(idx)¶
- class hdmf.container.Table(columns, name, data=[])¶
Bases:
DataSubclasses should specify the class attribute __columns__.
This should be a list of dictionaries with the following keys:
namethe column nametypethe type of data in this columndoca brief description of what gets stored in this column
For reference, this list of dictionaries will be used with docval to autogenerate the
add_rowmethod for adding data to this table.If __columns__ is not specified, no custom
add_rowmethod 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
namewill 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
columns (
listortuple) – a list of the columns in this tablename (
str) – the name of this containerdata (
ndarrayorlistortupleorDatasetorStrDatasetorHDMFDatasetorAbstractDataChunkIteratororDataIO) – the source of the data
- property columns¶
- which(**kwargs)¶
Query a table
- __getitem__(args)¶
- to_dataframe()¶
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.