npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hed-validator

v3.13.4

Published

A JavaScript validator for HED (Hierarchical Event Descriptor) strings.

Downloads

3,296

Readme

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.