7. Library schemas

A HED library schema contains the vocabulary terms needed for annotation in a specialized area. An example of such a library is the HED SCORE schema for annotation of EEG by clinical neurologists. All officially released HED schemas, whether standard or library, are hosted on the hed-standard/hed-schemas GitHub repository and can be viewed using the hed-schema-browser.

7.1. Why library schemas?

The variety and complexity of events in electrophysiological experiments make full documentation challenging. As more experiments move out of controlled laboratory environments and into less controlled virtual and real-world settings, the terminology required to adequately describe events and other experimental metadata has the potential to grow exponentially.

In addition, experiments in any given subfield can create pressures to add overly-specific terms and jargon to the schema hierarchy - for example, adding musical terms to tag events in music-based experiments, video markup terms for experiments involving movie viewing, traffic terms for experiments involving virtual driving, and so forth.

Clinical fields using neuroimaging also have their own specific vocabularies for describing data features of clinical interest (e.g., seizure, sleep stage IV). Including these discipline-specific terms quickly makes the standard HED schema unwieldy and less usable by the broader user community.

Third generation HED addressed the problem of vocabulary bloat by introducing HED library schemas to organize discipline-specific terminology. To use a programming analogy, when programmers write a Python module, the resulting code does not become part of the Python language or core libraries. Instead, the module becomes part of a library used in conjunction with core modules of the programming language.

7.2. Unpartnered library schemas

HED library schemas were originally designed as standalone vocabularies. These unpartnered library schemas were self-contained schemas with all the needed schema attributes and properties. In practice however, these “standalone” schemas almost always required tags from the standard schema, and library schemas either had to duplicate items from the standard schema or use namespaces so that each schema could be used independently in an annotation without conflicts. See 3.1.1. Schema versions and 3.1.2 Version combinations for more detailed explanations of namespaces and merge groups.

Using tags from schemas in different namespaces for annotation proved to be inconvenient, because the tags of each namespace carry its prefix. In the following example score_1.0.0 is in the default namespace and 8.4.0 is in the ts: namespace:

A version specification of the score library version 1.0.0 with standard schema version 8.4.0.

["score_1.0.0", "ts:8.4.0"]

Annotations using this version specification prefix every tag from the standard schema with ts: (e.g., ts:Sensory-event). Partnered library schemas were introduced to avoid the namespace complication for annotators in most practical use cases.

7.3. Partnered library schemas

A partnered library schema is tied to a specific version of the HED standard schema and designed to be used with its partner as a unified vocabulary in a single namespace. A given library schema version is either partnered or unpartnered depending on whether its header has the withStandard="x.y.z" attribute, where x.y.z is the version of its standard schema partner. A new version of a partnered library schema MUST be partnered with the latest released standard schema at the time the library version is released. While it is in development it may be partnered with a prerelease of the standard schema. The versions a partner may have are stated in 3.1.2.1. Partnered vs unpartnered. Unpartnered library schemas do not have a withStandard attribute. The filenames for library schemas are the same regardless of partnership.

7.3.1. Partnered file formats

HED schema files (including library schema files) can be represented in one of 4 equivalent formats: MediaWiki, TSV, XML, and JSON. The hed-python tools read each of these formats into a common object format and can then convert to any other equivalent formats.

MediaWiki format has one line per tag, is relatively easy to read, and clearly displays the hierarchy structure for human readers. Many developers work in this format after the tag vocabulary has been established.

TSV is a multi-file format (13 TSV files) that stores the sections of a schema in separate spreadsheets. Developers often use TSV format in the initial development of a library vocabulary, because they only need to focus on the _Tag.tsv spreadsheet which contains the library tags. Most of the other TSV files will be empty or fixed after the initial setup.

XML is hard to read, so humans almost never use this format directly, but instead, convert XML to MediaWiki or TSV. XML is easily parsed by tools and is the standard format for tools in the HED ecosystem.

JSON is a flattened format that is useful for AI agents, as its tags are in a top-level dictionary.

7.3.2. Schema filenames

The canonical filenames for the standard schemas are HEDx.y.z.mediawiki, HEDx.y.z.xml, and HEDx.y.z.json for the MediaWiki, XML, and JSON formats, respectively. The x.y.z represents the semantic version (e.g., 8.4.0). The filenames for TSV format are of the form HEDx.y.z_www.tsv, where www designates the spreadsheet type (e.g., HED8.4.0_Tag.tsv).

Library schemas have the form HED_libname_x.y.z.mediawiki, HED_libname_x.y.z.xml, and HED_libname_x.y.z.json for the MediaWiki, XML, and JSON formats, respectively. The x.y.z represents the semantic version (e.g., 1.1.0) and libname is the name of the library in lower case (e.g., HED_lang_1.1.0.mediawiki is version 1.1.0 of the language library schema lang). The TSV format for library schemas follows the HED_libname_x.y.z_www.tsv pattern.

Library schema filenames don’t show partnership.

Whether a schema file represents a partnered or unpartnered schema can ONLY be determined by the schema header not by the filename. If the withStandard attribute is present in the schema header, it is partnered. If the withStandard is absent it is unpartnered.

Library schema filenames don’t show merge status.

Whether a schema library file has been stored in merged or unmerged form can ONLY be determined by the schema header:

If the unmerged="true" attribute is present in the schema header, it is unmerged. If the attribute is absent or false, it is merged.

7.3.3. Merged vs unmerged

There are several significant differences between merged and unmerged partnered library schema formats:

  • An unmerged schema has the unmerged="true" attribute in its header line. The merged version does not have an unmerged attribute in its header.

  • An unmerged schema SHOULD have a non-empty prologue and epilogue that explain the purpose of the library schema (the sections themselves are always present, see 3.1.4. Schema layout overview). The contents of these prologue and epilogue sections become the prologue and epilogue, respectively, in the merged schema. The prologue and epilogue of the standard schema are omitted in the merged schema.

  • With the exception of the prologue and epilogue sections, the merged form of library schema xxx has the inLibrary=xxx attribute on every schema element and schema attribute that is in the library and on every row that the library contributes to the extra sections (see 3.1.2.2. Merged vs unmerged). Here xxx is the name of the library. The unmerged form has none (see 3.1.2.2. Merged vs unmerged).

  • The schema properties section of an unmerged library schema MUST always be empty except for its section header. The schema properties section of a merged schema will have only the standard schema properties.

  • An unmerged schema MUST only include content in the auxiliary sections other than the schema properties section, and in the extra sections (Sources, Prefixes, and External annotations), that it explicitly extends. An auxiliary or extra section that it does not extend is written empty (see 3.1.4. Schema layout overview). The merged version will have all of the section values from both the library schema and its partner.

  • In an unmerged schema, nodes with the rooted=XXX schema attribute MUST be top-level tags, and XXX MUST correspond to a node in the standard schema. In the merged schema, nodes with the rooted=XXX schema attribute are placed directly under the standard schema node XXX.

A.2.4. MediaWiki schema section shows a rooted node of the MOUSE library schema in unmerged and in merged form.

7.3.4. Partnered attributes

To support partnered library schema the following items were introduced:

Name

Type

Role

withStandard

Header attribute

  • Indicates that this is a partnered library schema.
  • Its value is the version of its standard schema partner.

unmerged

Header attribute

  • A value of “true” indicates that this schema contains only library information.
  • Its value is either “true” or “false” (case-insensitive).
  • If “false”, the attribute SHOULD be omitted.

inLibrary

Element attribute

  • Indicates that this element, or this row of an extra section, is in the library schema.
  • Its value is the library name in lowercase.
  • Its treatment when schemas are merged is stated in 3.1.2.4. Partnered combinations.

rooted=XXX

Node attribute

  • Indicates that this library schema node is to appear directly under
    standard schema node XXX in the merged schema.
  • Its rules are stated in 7.3.3. Merged vs unmerged.

reserved

Node attribute

7.3.5. Motivation for partners

Partnered library schemas are the strongly preferred format for HED libraries for consistency and elimination of redundancy. This section explains why partnered library schemas are preferred.

7.3.5.1. Auxiliary consistency

An unpartnered library schema MUST duplicate the auxiliary schema sections appearing in standard schemas, introducing the possibility of inconsistency in usage or definition between the library schema and standard schemas. A partnered library schema automatically inherits its standard partner’s auxiliary sections, assuring consistent handling by tools and preventing the introduction of inconsistently handled attributes.

Although unpartnered library schemas may add additional items to the auxiliary sections, HED tools only guarantee support of standard schema auxiliary items requiring special handling. Thus, addition of items in the auxiliary sections of a library schema is discouraged.

7.3.5.2. Reserved tags handling

Several tags in the standard schema have the reserved attribute: each has a specified meaning in the HED ecosystem that individual schemas, library schemas included, cannot redefine. The nine structural reserved tags (Definition, Def, Def-expand, Onset, Offset, Inset, Delay, Duration, and Event-context) implement definitions and events of temporal extent; see 3.2.8. Reserved tags for their rules. By partnering with a standard schema, a library schema is assured of having HED support for key features such as events of temporal extent and definitions.

7.3.5.3. Annotation conciseness

The most common use case for library schemas in annotation requires tags from both a standard schema and a library schema, thus requiring a namespace prefix (e.g., xx:) on the tags from one of the schemas when unpartnered library schemas are used.

Because a partnered library schema is merged with a standard schema to form a single, unified schema, users can annotate data without the xx: namespace prefix. The xx: is still needed when multiple incompatible library schemas are used together. See 7.3.6 Lazy partnering for more information on compatibility.

7.3.5.4. Library searches

The subtrees appearing in the library schemas are often elaborations of a particular term in the standard schema. However, if the library schema terms are not in the appropriate standard schema hierarchy, HED search cannot be leveraged to find these elaborations by searching for a more general standard schema term.

7.3.5.5. Suggested tags

Unpartnered library schemas cannot use the suggestedTag or relatedTag attributes to suggest using particular tags from the standard schema, since the values of the tags MUST be in the schemas themselves. However, partnered library schemas can refer to tags in the standard schema using the suggestedTag or relatedTag attributes.

7.3.6. Lazy partnering

HED allows the partnered schemas of a merge group to be combined into one unified vocabulary tree, provided that the schemas are compatible. We refer to this process as lazy partnering.

In the following example, all the library schemas are partnered with standard schema 8.4.0. Library schemas liba_1.0.0 and libc_4.3.2 are merged in the default namespace, and library schemas ac:libb_2.8.1 and ac:exam_2.3.2 are merged in the ac namespace. The schema sc:test_1.3.2 stays the same, and listing 8.4.0 adds nothing, since it is already the partner of liba_1.0.0 and libc_4.3.2. If there are any conflicts during the merging process, an error is raised.

Example: Merging of multiple schemas.

     ['liba_1.0.0', 'ac:libb_2.8.1', 'libc_4.3.2', '8.4.0', 'sc:test_1.3.2', 'ac:exam_2.3.2']

The full set of rules governing merge groups and partnered combination is given in the rule table of 3.1.2.4. Partnered combinations. The subsections below give worked examples of version specifications that load and version specifications that fail, organized by the row groups of that table. An incompatible list of schemas cannot be loaded.

Avoid new auxiliary section entries in library schemas.

Auxiliary sections have information for HED tools, and new entries may require modification to schema validation and analysis tools.

With the possible (and rare) exception of new unitClasses and units, partnered library schemas usually have empty auxiliary sections. The empty sections are still written (see 3.1.4. Schema layout overview).

While new value class and schema attribute definitions are allowed in library schemas, this is strongly discouraged. If a new entry is needed, contact the HED Working Group (hed.maintainers@gmail.com) to see if the entry might be added to the standard schema instead.

7.3.6.1. Test schema examples

The worked examples in the following subsections use four test-only library schemas: testconflict, testclash, testminimal, and testaux. These schemas are maintained in the hed-tests repository (under json_test_data/test_schemas/) and are not released HED schemas. Their contents are fully controlled, so each example exercises exactly one rule of the rule table in 3.1.2.4. Partnered combinations. Each example mirrors a test case in that repository’s json_test_data/validation_test_data/SCHEMA_LOAD_FAILED.json, keeping the specification and the validator test suites in sync.

Schema versions

Standard schema partner (withStandard)

testconflict_1.0.0, testconflict_1.1.0, testconflict_1.1.2

None (unpartnered)

testconflict_2.0.0, testconflict_2.1.0, testconflict_2.1.1

8.5.0

testclash_1.0.0 through testclash_19.0.0

8.5.0

testminimal_1.0.0

None (unpartnered)

testminimal_2.0.0

8.4.0

testminimal_2.1.0

8.5.0

testaux_1.0.0

8.5.0

The examples rely on the following facts about these libraries:

  • testconflict_2.1.0 is testconflict_2.0.0 plus one added tag. testconflict_2.1.1 differs from testconflict_2.1.0 only in one revised tag description (a patch-level change).

  • testconflict_2.0.0 declares the top-level tags Shared-item, Attribute-item (with suggestedTag=Object-one), Description-item, Anchor-item (with child Nested-item), Placeholder-item (with a # child), and Rooted-tag (with rooted=Event), whose children are Rooted-one (with child Deep-one) and Rooted-two.

  • Each testclash version declares its own Clash-tag subtree plus at most one probe element also declared by another test library, identical except for at most one controlled difference. Versions 1.0.0 through 12.0.0 probe tag elements declared by testconflict_2.0.0; the differences are tabulated in 7.3.6.5. Element compatibility examples. Versions 13.0.0 through 19.0.0 probe auxiliary elements and a schema attribute declared by testaux_1.0.0; the differences are tabulated in 7.3.6.6. Auxiliary element examples.

  • testminimal declares only its own Mini-tag subtree, which is disjoint from the vocabularies of the other libraries.

  • testaux_1.0.0 declares one auxiliary element of each kind - the unit class auxUnits (with units auxunit and bigauxunit), the unit modifier auxMod, and the value class auxClass - and the schema attribute auxAttribute, plus the tags Aux-measure (which takes a value with auxUnits units) and Aux-value (which takes a value of the auxClass value class). Its vocabulary is disjoint from the other libraries and from the standard schema.

7.3.6.2. Merge group examples

Version specification

Loads

Explanation

['testconflict_2.1.0', 'testclash_1.0.0', 'testminimal_2.1.0']

Yes

All three libraries are partnered with 8.5.0, and their elements are either disjoint or identical, so they merge into a single unprefixed vocabulary.

['8.4.0', 'sc:testconflict_2.1.0', 'ts:testminimal_1.0.0']

Yes

Three merge groups (unprefixed, sc:, ts:) resolve independently; the standard schema partners of different groups do not have to agree.

['8.5.0', 'sc:8.4.0']

Yes

A standard schema in its own namespace forms its own merge group, so the two standard versions do not conflict.

['testconflict_2.0.0', 'testconflict_2.0.0']

No

Duplicate schemas (the same name, whatever the version) cannot appear in the same merge group; an exact duplicate fails like two different versions.

['testconflict_2.0.0', 'testconflict_2.1.0']

No

Different versions of the same schema cannot appear in the same merge group, even though these two share the 8.5.0 partner and have no conflicts.

['8.5.0', 'sc:testconflict_2.0.0', 'sc:testminimal_2.0.0']

No

The rules apply inside each namespace: the sc namespace has conflicting partners (8.5.0 versus 8.4.0), even though the default namespace is fine.

7.3.6.3. Standard partner examples

Version specification

Loads

Explanation

['testconflict_2.0.0']

Yes

A partnered library schema automatically includes its standard schema partner (8.5.0), so standard schema tags such as Red validate without the standard schema being listed.

['8.5.0', 'testconflict_2.0.0']

Yes

A standard schema matching the group partner is allowed and adds nothing to the merged result.

['8.4.0', 'testconflict_2.0.0']

No

A standard schema in a merge group must match the group partner; testconflict_2.0.0 is partnered with 8.5.0, not 8.4.0.

['testconflict_2.0.0', 'testminimal_2.0.0']

No

Partnered library schemas in a merge group must have the same partner; here the partners are 8.5.0 and 8.4.0.

['8.4.0', '8.5.0']

No

Two standard schemas cannot be listed in the same merge group, whatever their versions; ['8.5.0', '8.5.0'] fails as well.

7.3.6.4. Unpartnered examples

Version specification

Loads

Explanation

['8.4.0', 'sc:testconflict_2.1.0', 'ts:testminimal_1.0.0']

Yes

The unpartnered testminimal_1.0.0 is alone in its own ts namespace, which is where an unpartnered schema must be.

['8.5.0', 'testconflict_1.1.0']

No

The unpartnered testconflict_1.1.0 cannot share the unprefixed merge group with another schema.

['ts:testconflict_1.1.2', 'ts:testminimal_1.0.0']

No

Two unpartnered library schemas cannot share a namespace; each needs its own.

7.3.6.5. Element compatibility examples

Each example in this subsection loads testconflict_2.0.0 together with one of the testclash versions 1.0.0 through 12.0.0, each of which carries at most one probe element shared with testconflict_2.0.0, so each pair isolates a single element compatibility rule:

Version specification

Probe element

Difference from testconflict_2.0.0

Loads

['testconflict_2.0.0', 'testclash_1.0.0']

Shared-item

None: an identical copy. Identical shared elements are compatible, and the merged vocabulary keeps a single copy.

Yes

['testconflict_2.0.0', 'testclash_2.0.0']

Attribute-item

The suggestedTag value is Clash-one instead of Object-one: the attribute values differ.

No

['testconflict_2.0.0', 'testclash_3.0.0']

Description-item

The description text differs.

No

['testconflict_2.0.0', 'testclash_4.0.0']

Nested-item

Declared at the top level instead of as a child of Anchor-item: the ancestor paths differ.

No

['testconflict_2.0.0', 'testclash_5.0.0']

Placeholder-item

Has no # child, while testconflict’s has one.

No

['testconflict_2.0.0', 'testclash_6.0.0']

Rooted-tag

Declared as an ordinary top-level tag instead of with rooted=Event: the merged ancestor paths differ (Rooted-tag versus Event/Rooted-tag).

No

['testconflict_2.0.0', 'testclash_7.0.0']

Rooted-tag

Declared with rooted=Item instead of rooted=Event: the same tag is anchored at different standard schema nodes.

No

['testconflict_2.0.0', 'testclash_8.0.0']

Rooted-tag subtree

Rooted-tag and its child Rooted-one are identical; testclash adds its own child Rooted-three. A shared element may have different non-# children, so the merged Rooted-tag has children Rooted-one (with Deep-one), Rooted-two, and Rooted-three.

Yes

['testconflict_2.0.0', 'testclash_9.0.0']

Rooted-tag subtree

The shared child Rooted-one carries a different description. The compatibility rules apply to shared children, so the changed shared child fails the merge even though the non-shared sibling Rooted-three would be allowed.

No

['testconflict_2.0.0', 'testclash_10.0.0']

Rooted-tag

Identical, but its only child is testclash’s own Rooted-four: a shared element’s children may be entirely disjoint.

Yes

['testconflict_2.0.0', 'testclash_11.0.0']

Rooted-tag subtree

The chain Rooted-tag/Rooted-one is identical; below it testclash declares Deep-two where testconflict declares Deep-one. The differing grandchildren are not shared, so the merged Rooted-one carries both.

Yes

['testconflict_2.0.0', 'testclash_12.0.0']

Rooted-tag subtree

The shared grandchild Deep-one carries a different description. Compatibility applies at every depth of a shared hierarchy.

No

Two versions of one library are never compared element by element, because different versions of the same schema cannot appear in the same merge group: ['testconflict_2.1.0', 'testconflict_2.1.1'] fails to load on that rule alone. To use two versions together, give one its own namespace, for example ['testconflict_2.1.0', 'alt:testconflict_2.1.1'] (a name such as v2 is not a namespace name; see 3.1.1. Schema versions).

Any failing pair in this subsection can still be used together by giving one schema its own namespace. For example, ['testconflict_2.0.0', 'cl:testclash_2.0.0'] loads because the two Attribute-item declarations are in different merge groups and are never compared.

7.3.6.6. Auxiliary element examples

The element compatibility rules apply to the auxiliary elements (unit classes, units, unit modifiers, and value classes) and to schema attributes exactly as they do to tags. The first example pairs testconflict_2.0.0, which declares neither, with testaux_1.0.0 to show direct merging; each remaining example loads testaux_1.0.0 together with one of the testclash versions 13.0.0 through 19.0.0, so each pair isolates a single rule:

Version specification

Probe element

Difference from testaux_1.0.0

Loads

['testconflict_2.0.0', 'testaux_1.0.0']

all auxiliary elements

None shared: every testaux auxiliary element and its schema attribute are new to the merge group. New unit classes with their units, unit modifiers, value classes, and schema attributes are merged directly.

Yes

['testaux_1.0.0', 'testclash_13.0.0']

all auxiliary elements

None: identical copies. Identical shared auxiliary elements and schema attributes are compatible, and the merged vocabulary keeps a single copy of each.

Yes

['testaux_1.0.0', 'testclash_14.0.0']

unit auxunit

The conversionFactor value differs: the attribute values of a shared unit differ.

No

['testaux_1.0.0', 'testclash_15.0.0']

unit class auxUnits

The shared units are identical; testclash adds its own unit smallauxunit. New units under an existing unit class are merged if there are no conflicts.

Yes

['testaux_1.0.0', 'testclash_16.0.0']

value class auxClass

The allowedCharacter value is digits instead of letters: the attribute values of a shared value class differ.

No

['testaux_1.0.0', 'testclash_17.0.0']

schema attribute auxAttribute

Declared without boolRange: for a schema attribute the schema properties are the attribute values that are compared.

No

['testaux_1.0.0', 'testclash_18.0.0']

schema attribute auxAttribute

The description text differs.

No

['testaux_1.0.0', 'testclash_19.0.0']

unit modifier auxMod

The conversionFactor value differs: the attribute values of a shared unit modifier differ.

No

7.4. Library schema design

Most library schema developers work with unmerged MediaWiki or unmerged TSV format. Developers SHOULD always validate the schema before converting to XML. Only validated versions of the schema SHOULD be uploaded to the GitHub hed-schemas repository. The online HEDtools provide easy access to tools for schema validation, conversion, and comparison. More information about the development process is contained in the HED Schema developers guide.

Because of the partnering rule of 7.3. Partnered library schemas, developers release new versions whenever HED updates its standard schema. This ensures that the partnered library schema benefits from the latest updates to HED features and tools.

If the update can be done without conflict, this update may be initiated as part of the release mechanism by the maintainers of the HED repositories.

7.4.1. General design rules

This section summarizes the general design rules for all library schema.

General design rules for HED library schema.

  1. Follow naming conventions:
    A library schema MUST be given a name containing only lowercase alphabetic characters. This name MUST appear in the schema header line in the required format.
     

  2. Use semantic versioning:
    A library schema MUST use semantic versioning and follow the versioning update rules used by the HED standard schema as specified in 3.1.3. Version updates.
     

  3. Tag uniqueness:
    The terms of a library schema follow the rules for nodes in 3.1.4.3. The schema section, uniqueness included.
     

  4. Have a meaningful prologue:
    The schema SHOULD include a prologue section giving an overview, purpose and scope of the library schema.
     

  5. Have a meaningful epilogue:
    The schema SHOULD include an epilogue section containing reference, citation, and license information.
     

  6. Be understandable:
    Schema terms SHOULD be readily understood by most users. The terms SHOULD NOT be ambiguous and SHOULD be meaningful in themselves without reference to their position in the schema hierarchy.
     

  7. Be well-organized:
    If possible, no schema sub-tree SHOULD have more than 7 direct subordinate sub-trees.
     

  8. Maintain subtree orthogonality:
    Terms that are used independently of one another SHOULD be in different sub-trees (orthogonality).
     

  9. Enforce is-a relationship between child nodes and their parents:
    Every node in a HED hierarchy is a subclass of its parent node, as 3.1. Schema rules requires. This is what makes HED search generalizable.

Validators enforce rules 1 and 3 and the version format of rule 2. The version update rules of rule 2, the content of the prologue and epilogue (rules 4 and 5), and rules 6 through 9 are the responsibility of the schema designers and review committees.

In general, library schema developers SHOULD avoid adding schema terms that duplicate those found in the latest HED standard schema at the time of release. For partnered library schemas this is a strict requirement: an unmerged partnered library schema MUST NOT have a schema element or schema attribute with the same name as one of its standard schema partner, except a unit class that it names only to add new units under it; the merged form necessarily contains all of its partner’s tags. Library schema developers SHOULD also try to avoid overlap of terms found in other schema libraries.

If your application requires schema classes that are not available in the standard HED schema and you would like these classes to be supported, please make a request using the issues forum of the hed-schemas GitHub repository.

7.4.2. Unpartnered design rules

A new library schema is partnered with the latest released standard schema (7.3. Partnered library schemas). A new unpartnered library schema is not supported until rules for one are specified: B.3. Differences for earlier schema versions states how the released unpartnered library, SCORE 1.0.0, is validated. The rules of 3.2.8. Reserved tags for library schemas apply to it; definitions and temporal scope come from a standard schema, either partnered with the library or listed separately in the version specification (see 7.5. Library schemas in BIDS).

7.4.3. Partnered design rules

Partnered library schemas are now the recommended format for the reasons listed in Motivation for partners. The following design rules are specifically meant for partnered library schemas. Developers usually work on their library schemas in either unmerged MediaWiki or unmerged TSV format because these formats are concise and easy to edit. The HED online tools provide online tools for converting from one schema format to all formats in merged or unmerged forms.

Design rules specific to partnered HED library schemas.

  1. Check for overlap:
    The terms of a partnered library schema follow 7.4.1. General design rules on duplicates, and no term may be rooted under a reserved tag (see 3.2.8. Reserved tags).
     

  2. Use the latest released version of the standard schema:
    A partnered library schema follows the partnering rule of 7.3. Partnered library schemas.
     

  3. The auxiliary sections of the unmerged partnered library schema are usually empty:
    The auxiliary sections of an unmerged partnered library schema hold only the items it adds (see 7.3.3. Merged vs unmerged).
     

  4. Seek reviews early in the process:
    Any additions to the auxiliary sections MUST be reviewed by the HED Working Group to determine what requirements the additions would impose on downstream tools.

It is recognized that HED standard and library schemas will both evolve and that additions or tag reorganizations may cause conflicts. These conflicts are resolved as they occur. In general the standard schema takes precedence over any library schema in resolving these conflicts.

7.5. Library schemas in BIDS

By far the most common use case is to tag events using a standard HED schema (preferably the latest one) available in the standard_schema/hedxml directory of the hed-schemas repository of the hed-standard organization on GitHub. The standard schemas are available at: https://github.com/hed-standard/hed-schemas/tree/main/standard_schema.

The official library schemas are available at https://github.com/hed-standard/hed-schemas/tree/main/library_schemas.

Standard schemas are referenced by their version number (e.g., 8.1.0), while library schema are referenced by a combination of library name and version number (e.g., score_1.0.0).

For BIDS datasets, the versions of the HED schema are specified by the HEDVersion field of the BIDS dataset_description.json file. The schema versions in this section’s examples are historical: SCORE 1.0.0 (unpartnered) and SCORE 1.1.0 (partnered) are used to illustrate the difference partnering makes for annotators. The following example specifies that version 8.1.0 of the standard HED schema is to be used in addition to score library schema version 1.0.0.

Illustration of using the namespace prefix for tagging.

The dataset_description.json file contains:

{
  "Name": "A great experiment",
  "BIDSVersion": "1.8.0",
  "HEDVersion": ["8.1.0", "sc:score_1.0.0"]
}

A typical annotation is:

"Data-feature, sc:Photomyogenic-response, sc:Wicket-spikes"

Based on the above description tools will download:

  1. The standard HED schema:
    https://raw.githubusercontent.com/hed-standard/hed-schemas/main/standard_schema/hedxml/HED8.1.0.xml.

  2. The HED score library schema version 1.0.0:
    https://raw.githubusercontent.com/hed-standard/hed-schemas/main/library_schemas/score/hedxml/HED_score_1.0.0.xml.

In the dataset annotations for the above example, tags drawn from the score schema would be prefixed with sc:, where sc is the namespace name chosen to distinguish tags from the additional schema.

SCORE version 1.0.0 is not partnered, so the HED version specification had to include both the library and standard schema versions. In contrast, SCORE version 1.1.0 is partnered with HED standard schema 8.2.0, so no namespace prefixes are needed as shown in the following example:

Example: An example specification of HED version for a partnered schema.

The dataset_description.json file contains:

{
  "Name": "A great experiment",
  "BIDSVersion": "1.8.0",
  "HEDVersion": "score_1.1.0"
}

A typical annotation is:

"Data-feature, Photomyogenic-response, Wicket-spikes"