API Documentation for Metadata¶
The model for storing metadata is largely equivalent to the odML (open metadata Markup Laguage) model. In brief: the model consists of so called Properties that contain Values much like a key-value pair (plus some additional fields). These Properties can be grouped into Sections which themselves can be nested to built a tree-structure. Sections are defined by a name and a type (e.g. a stimulus-type section will contain information that is related to a stimulus). The basic feature of the odML approach is that it defines the model but not the items that are described or the terms that are used in this. On the other hand where standardization is required each Section can be based on an odML-terminology that standardizes without restricting to the terms defined within the terminology.
Section¶
Metadata stored in a NIX file can be accessed directly from an open file.
Create and delete sub sections¶
1 2 | sub = section.create_section("a name", "type")
del section.sections[sub]
|
Add and remove properties¶
Properties can be created using the create_property method. Existing properties can be accessed and deleted directly from the respective section.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | section.create_property("one", [Value(1)])
section.create_property("two", [Value(2)])
# iterate over properties
for p in section:
print(p)
# access by name
one = section["one"]
# convert properties into a dict
dct = dict(section.items())
# delete properties
del section["one"]
del section["two"]
|
Section API¶
-
class
nixio.pycore.
Section
(nixparent, h5group)¶ -
create_property
(name, values)¶ Add a new property to the section.
Parameters: - name (str) – The name of the property to create.
- values (list of Value) – The values of the property.
Returns: The newly created property.
Return type:
-
create_section
(name, type_)¶ Creates a new subsection that is a child of this section entity.
Parameters: Returns: The newly created section.
Return type:
-
created_at
¶ The creation time of the entity. This is a read-only property. Use force_created_at in order to change the creation time.
Return type: int
-
definition
¶ The definition of the entity. The definition can contain a textual description of the entity. This is an optional read-write property, and can be None if no definition is available.
Type: str
Get all related sections of this section.
The result can be filtered. On each related section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.
Parameters: filtr (function) – A filter function Returns: A list containing the matching related sections. Return type: list of Section
-
find_sections
(filtr=<function SectionMixin.<lambda>>, limit=None)¶ Get all child sections recursively. This method traverses the trees of all sections. The traversal is accomplished via breadth first and can be limited in depth. On each node or section a filter is applied. If the filter returns true the respective section will be added to the result list. By default a filter is used that accepts all sections.
Parameters: - filtr (function) – A filter function
- limit (int) – The maximum depth of traversal
Returns: A list containing the matching sections.
Return type: list of Section
-
force_created_at
(t=None)¶ Sets the creation time created_at to the given time (default: current time).
Parameters: t (int) – The time to set.
-
force_updated_at
(t=None)¶ Sets the update time updated_at to the given time. (default: current time)
Parameters: t (int) – The time to set.
-
get_property_by_name
(name)¶ Get a property by its name.
Parameters: name (str) – The name to check. Returns: The property with the given name. Return type: Property
-
has_property_by_name
(name)¶ Checks whether a section has a property with a certain name.
Parameters: name (str) – The name to check. Returns: True if the section has a property with the given name, False otherwise. Return type: bool
-
id
¶ A property providing the ID of the Entity. The id is generated automatically, therefore the property is read-only.
Return type: str
-
inherited_properties
()¶
-
items
()¶
-
link
¶ Link to another section. If a section is linked to another section, the linking section inherits all properties from the target section. This is an optional read-write property and may be set to None.
Type: Section
-
mapping
¶
-
name
¶ The name of an entity. The name serves as a human readable identifier. This is a read-only property; entities cannot be renamed.
Type: str
-
parent
¶ The parent section. This is a read-only property. For root sections this property is always None.
Accessing this property can be slow when the metadata tree is large.
Type: Section
-
pprint
(max_depth=1, indent=2, max_length=80, current_depth=0)¶
-
props
¶ A property containing all Property entities associated with the section. Properties can be accessed by index of via their id. Properties can be deleted from the list. Adding new properties is done using the create_property method. This is a read-only attribute.
Type: ProxyList of Property
-
referring_blocks
¶
-
referring_data_arrays
¶
-
referring_groups
¶
-
referring_objects
¶
-
referring_sources
¶
-
repository
¶ URL to the terminology repository the section is associated with. This is an optional read-write property and may be set to None.
Type: str
-
sections
¶ A property providing all child sections of a section. Child sections can be accessed by index or by their id. Sections can also be deleted: if a section is deleted, all its properties and child sections are removed from the file too. Adding new sections is achieved using the create_section method. This is a read-only attribute.
Type: ProxyList of Section
-
Property¶
-
class
nixio.pycore.
Property
(nixparent, h5dataset)¶ -
created_at
¶ The creation time of the entity. This is a read-only property. Use force_created_at in order to change the creation time.
Return type: int
-
data_type
¶
-
definition
¶
-
delete_values
()¶
-
force_created_at
(t=None)¶ Sets the creation time created_at to the given time (default: current time).
Parameters: t (int) – The time to set.
-
force_updated_at
(t=None)¶ Sets the update time updated_at to the given time. (default: current time)
Parameters: t (int) – The time to set.
-
id
¶ A property providing the ID of the Entity. The id is generated automatically, therefore the property is read-only.
Return type: str
-
mapping
¶
-
name
¶
-
pprint
(indent=2, max_length=80, current_depth=-1)¶
-
unit
¶
-
updated_at
¶ The time of the last update of the entity. This is a read-only property. Use force_updated_at in order to change the update time.
Return type: int
-
values
¶
-