hed-validator

3.13.5 • Public • Published

Maintainability Test Coverage npm DOI

hed-validator

This package contains a JavaScript validator for HED (hierarchical event descriptor) strings.

HED is a system for annotating events using comma-separated path strings. Any type of event can be annotated using HED-type syntax. The HED annotation strategy is very general and a standardized vocabulary in the form of a HED schema enables annotation of events in an understandable, machine-actionable format.

Additional library schemas with specialized vocabularies needed for particular subfields are under development.

HED validation occurs at several levels. Syntactic validation checks that HED strings comply with the required syntax, but not whether tags comply with the additional requirements of a HED schema.

Semantic validation verifies validity at many levels:

  1. Tag-level validation checks that tags are in the schema and have correct units and value type.
  2. String-level validation performs additional checks for correctness. In this implementation, tag-level and string-level validation occur at the same time.
  3. Event-level validation checks that the entire assembled HED annotation for an event is valid. This includes checks for required tags, duplicate tags, top-level tags, top-level tag groups, and unique tags. This usually implies the existence of an events file and an accompanying JSON sidecar so that annotations for different columns of an events file can be assembled into a single string.
  4. Dataset-level validation parses out the definitions and checks that the needed definitions are present and not duplications. Dataset-level validation also checks for Onset-Offset tag consistency.

The current version of hed-validator performs both syntactic and semantic validation. Because full validation of all the features of HED-3G (versions >= 8.0.0) requires full knowledge of an events file and its merged sidecars, the hed-validator currently only exposes its interface at the dataset level. The current focus of the hed-validator package is to support full validation of HED in BIDS datasets

HED validation is currently also supported in an online version of the HED validator, which is implemented in Python and developed in a public GitHub repository. Validation and other HED operations are also available through web-services and a docker module.

Usage from JavaScript

The JavaScript version of the HED validator, implemented in this package, is meant primarily to be called during validation of BIDS datasets and is called by the bids-validator. This package has been deployed on npm as hed-validator.

To use the hed-validator, you must install the npm hed-validator package and add: const hedValidator = require('hed-validator') to your JavaScript program.

Currently, only validation at the BIDS dataset level is supported as an external interface, because full HED-3G validation requires the entire events file and merged sidecars be available.

A sample call can be found in the BIDS validator in hed.js

const dataset = new hedValidator.validator.BidsDataset(eventData, sidecarData, datasetDescriptionData, dir)
try {
  return hedValidator.validator.validateBidsDataset(dataset).then((hedValidationIssues) => {
    return schemaDefinitionIssues.concat(convertHedIssuesToBidsIssues(hedValidationIssues))
  })
} catch (error) {
  const issues = schemaDefinitionIssues.concat(internalHedValidatorIssue(error))
  return Promise.resolve(issues)
}

eventData is an array of BidsEventFile objects created from BIDS events.tsv files, while sidecarData is an array of BidsSidecar objects created from BIDS JSON sidecars. datasetDescriptionData is a BidsJsonFile object representing the dataset's dataset_description.json file, and dir is the path to the dataset's root directory.

The primary objects needed for HED validation can be found in validator/bids/types.js.

Readme

Keywords

none

Package Sidebar

Install

npm i hed-validator

Weekly Downloads

371

Version

3.13.5

License

MIT

Unpacked Size

24.4 MB

Total Files

9

Last publish

Collaborators

  • hed-maintainers
  • vislab
  • happy5214