pynwb.spec module

class pynwb.spec.NWBRefSpec(target_type, reftype)[source]

Bases: RefSpec

Parameters:
  • target_type (str) – the target type GroupSpec or DatasetSpec

  • reftype (str) – the type of references this is i.e. region or object

class pynwb.spec.NWBAttributeSpec(name, doc, dtype, shape=None, dims=None, required=True, parent=None, value=None, default_value=None)[source]

Bases: AttributeSpec

Parameters:
  • name (str) – The name of this attribute

  • doc (str) – a description about what this specification represents

  • dtype (str or RefSpec) – The data type of this attribute

  • shape (list or tuple) – the shape of this dataset

  • dims (list or tuple) – the dimensions of this dataset

  • required (bool) – whether or not this attribute is required. ignored when “value” is specified

  • parent (BaseStorageSpec) – the parent of this spec

  • value (None) – a constant value for this attribute

  • default_value (None) – a default value for this attribute

class pynwb.spec.NWBLinkSpec(doc, target_type, quantity=1, name=None)[source]

Bases: LinkSpec

Parameters:
  • doc (str) – a description about what this link represents

  • target_type (str or BaseStorageSpec) – the target type GroupSpec or DatasetSpec

  • quantity (str or int) – the required number of allowed instance

  • name (str) – the name of this link

property neurodata_type_inc

The neurodata type of target specification

class pynwb.spec.BaseStorageOverride[source]

Bases: object

This class is used for the purpose of overriding BaseStorageSpec classmethods, without creating diamond inheritance hierarchies.

classmethod type_key()[source]

Get the key used to store data type on an instance

classmethod inc_key()[source]

Get the key used to define a data_type include.

classmethod def_key()[source]

Get the key used to define a data_type definition.

property neurodata_type_inc
property neurodata_type_def
classmethod build_const_args(spec_dict)[source]

Extend base functionality to remap data_type_def and data_type_inc keys

class pynwb.spec.NWBDtypeSpec(name, doc, dtype)[source]

Bases: DtypeSpec

Parameters:
  • name (str) – the name of this column

  • doc (str) – a description about what this data type is

  • dtype (str or list or RefSpec) – the data type of this column

class pynwb.spec.NWBDatasetSpec(doc, dtype=None, name=None, default_name=None, shape=None, dims=None, attributes=[], linkable=True, quantity=1, default_value=None, value=None, neurodata_type_def=None, neurodata_type_inc=None)[source]

Bases: BaseStorageOverride, DatasetSpec

The Spec class to use for NWB dataset specifications.

Classes will automatically include NWBData if None is specified.

Parameters:
  • doc (str) – a description about what this specification represents

  • dtype (str or list or RefSpec) – The data type of this attribute. Use a list of DtypeSpecs to specify a compound data type.

  • name (str) – The name of this dataset

  • default_name (str) – The default name of this dataset

  • shape (list or tuple) – the shape of this dataset

  • dims (list or tuple) – the dimensions of this dataset

  • attributes (list) – the attributes on this group

  • linkable (bool) – whether or not this group can be linked

  • quantity (str or int) – the required number of allowed instance

  • default_value (None) – a default value for this dataset

  • value (None) – a fixed value for this dataset

  • neurodata_type_def (str) – the NWB data type this spec defines

  • neurodata_type_inc (NWBDatasetSpec or str) – the NWB data type this spec includes

class pynwb.spec.NWBGroupSpec(doc, name=None, default_name=None, groups=[], datasets=[], attributes=[], links=[], linkable=True, quantity=1, neurodata_type_def=None, neurodata_type_inc=None)[source]

Bases: BaseStorageOverride, GroupSpec

The Spec class to use for NWB group specifications.

Classes will automatically include NWBContainer if None is specified.

Parameters:
  • doc (str) – a description about what this specification represents

  • name (str) – the name of the Group that is written to the file. If this argument is omitted, users will be required to enter a name field when creating instances of this data type in the API. Another option is to specify default_name, in which case this name will be used as the name of the Group if no other name is provided.

  • default_name (str) – The default name of this group

  • groups (list) – the subgroups in this group

  • datasets (list) – the datasets in this group

  • attributes (list) – the attributes on this group

  • links (list) – the links in this group

  • linkable (bool) – whether or not this group can be linked

  • quantity (str or int) – the allowable number of instance of this group in a certain location. See table of options here. Note that if youspecify name, quantity cannot be '*', '+', or an integer greater that 1, because you cannot have more than one group of the same name in the same parent group.

  • neurodata_type_def (str) – the NWB data type this spec defines

  • neurodata_type_inc (NWBGroupSpec or str) – the NWB data type this spec includes

classmethod dataset_spec_cls()[source]

The class to use when constructing DatasetSpec objects

Override this if extending to use a class other than DatasetSpec to build dataset specifications

get_neurodata_type(neurodata_type)[source]

Get a specification by “neurodata_type”

Parameters:

neurodata_type (str) – the neurodata_type to retrieve

add_group(doc, name=None, default_name=None, groups=[], datasets=[], attributes=[], links=[], linkable=True, quantity=1, neurodata_type_def=None, neurodata_type_inc=None)[source]

Add a new specification for a subgroup to this group specification

Parameters:
  • doc (str) – a description about what this specification represents

  • name (str) – the name of the Group that is written to the file. If this argument is omitted, users will be required to enter a name field when creating instances of this data type in the API. Another option is to specify default_name, in which case this name will be used as the name of the Group if no other name is provided.

  • default_name (str) – The default name of this group

  • groups (list) – the subgroups in this group

  • datasets (list) – the datasets in this group

  • attributes (list) – the attributes on this group

  • links (list) – the links in this group

  • linkable (bool) – whether or not this group can be linked

  • quantity (str or int) –

    the allowable number of instance of this group in a certain location. See table of options here. Note that if youspecify name, quantity cannot be '*', '+', or an integer greater that 1, because you cannot have more than one group of the same name in the same parent group.

  • neurodata_type_def (str) – the NWB data type this spec defines

  • neurodata_type_inc (NWBGroupSpec or str) – the NWB data type this spec includes

add_dataset(doc, dtype=None, name=None, default_name=None, shape=None, dims=None, attributes=[], linkable=True, quantity=1, default_value=None, value=None, neurodata_type_def=None, neurodata_type_inc=None)[source]

Add a new specification for a subgroup to this group specification

Parameters:
  • doc (str) – a description about what this specification represents

  • dtype (str or list or RefSpec) – The data type of this attribute. Use a list of DtypeSpecs to specify a compound data type.

  • name (str) – The name of this dataset

  • default_name (str) – The default name of this dataset

  • shape (list or tuple) – the shape of this dataset

  • dims (list or tuple) – the dimensions of this dataset

  • attributes (list) – the attributes on this group

  • linkable (bool) – whether or not this group can be linked

  • quantity (str or int) – the required number of allowed instance

  • default_value (None) – a default value for this dataset

  • value (None) – a fixed value for this dataset

  • neurodata_type_def (str) – the NWB data type this spec defines

  • neurodata_type_inc (NWBDatasetSpec or str) – the NWB data type this spec includes

class pynwb.spec.NWBNamespace(doc, name, schema, full_name=None, version=None, date=None, author=None, contact=None, catalog=None)[source]

Bases: SpecNamespace

A Namespace class for NWB

Parameters:
  • doc (str) – a description about what this namespace represents

  • name (str) – the name of this namespace

  • schema (list) – location of schema specification files or other Namespaces

  • full_name (str) – extended full name of this namespace

  • version (str or tuple or list) – Version number of the namespace

  • date (datetime or str) – Date last modified or released. Formatting is %Y-%m-%d %H:%M:%S, e.g, 2017-04-25 17:14:13

  • author (str or list) – Author or list of authors.

  • contact (str or list) – List of emails. Ordering should be the same as for author

  • catalog (SpecCatalog) – The SpecCatalog object for this SpecNamespace

classmethod types_key()[source]

Get the key used for specifying types to include from a file or namespace

Override this method to use a different name for ‘data_types’

class pynwb.spec.NWBNamespaceBuilder(doc, name, full_name=None, version=None, author=None, contact=None)[source]

Bases: NamespaceBuilder

A class for writing namespace and spec files for extensions of types in the NWB core namespace

Create a NWBNamespaceBuilder

Parameters:
  • doc (str) – a description about what this namespace represents

  • name (str) – the name of this namespace

  • full_name (str) – extended full name of this namespace

  • version (str or tuple or list) – Version number of the namespace

  • author (str or list) – Author or list of authors.

  • contact (str or list) – List of emails. Ordering should be the same as for author