pynwb.io.device module
- class pynwb.io.device.DeviceModelMapper(spec)[source]
Bases:
NWBContainerMapperCustom mapper that guards against writing a DeviceModel with an invalid name.
A DeviceModel remapped from a legacy
Device.modelstring (seeDeviceMapper) keeps the original string as its name, which can contain/or:. Those characters are interpreted as HDF5 path separators on write, silently splitting the model into nested groups and corrupting the file. Building such a DeviceModel raises an actionable error instead.Create a map from AbstractContainer attributes to specifications
- Parameters:
spec (
DatasetSpecorGroupSpec) – The specification for mapping objects to builders
- build(container, manager, parent=None, source=None, builder=None, matched_spec=None)[source]
Convert an AbstractContainer to a Builder representation.
References are not added but are queued to be added in the BuildManager.
- Parameters:
container (
AbstractContainer) – the container to convert to a Buildermanager (
BuildManager) – the BuildManager to use for managing this buildparent (
GroupBuilder) – the parent of the resulting Buildersource (
str) – the source of container being built i.e. file pathbuilder (
BaseBuilder) – the Builder to build onmatched_spec (
BaseStorageSpec) – the position-resolved subspec for this container in its parent’s spec tree, used to compute dtype/shape for the new dataset builder before it exists. Stored on the resulting builder as builder.matched_spec so post-creation consumers can read it without re-deriving the match.
- Returns:
the Builder representing the given AbstractContainer
- Return type:
- constructor_args = {'name': <function ObjectMapper.get_container_name>}
- obj_attrs = {}
- class pynwb.io.device.DeviceMapper(spec)[source]
Bases:
NWBContainerMapperCustom mapper for Device objects to handle known schema conflicts between core schema and extensions.
This mapper detects when extensions define Device.model as a string attribute instead of a link to DeviceModel, or when extensions define their own DeviceModel type.
Create a map from AbstractContainer attributes to specifications
- Parameters:
spec (
DatasetSpecorGroupSpec) – The specification for mapping objects to builders
- model_carg(builder, manager)[source]
Handle different model mapping strategies based on detected schema conflicts.
- Parameters:
builder – The GroupBuilder for the Device
manager – The BuildManager
- Returns:
The appropriate model object or value based on the mapping strategy
- constructor_args = {'model': <function DeviceMapper.model_carg>, 'name': <function ObjectMapper.get_container_name>}
- obj_attrs = {}