Under development

These pages are under development.

Issues

Every problem the package finds is reported as an issue: an object with a HED error code, a level, and a message. The codes are those of Appendix B of the HED specification, which explains what each one means and when it applies. This page describes the objects and lists the codes the package produces.

The Issue class

The string functions (see Validating HED strings) return Issue objects:

const [, errors] = parseStandaloneString('Sensory-event, Blech', schemas)
const issue = errors[0]
console.log(issue instanceof Issue)
console.log(issue.hedCode, issue.internalCode, issue.level)
console.log(issue.parameters)

prints

true
TAG_INVALID invalidTag error
{
  tag: 'Blech',
  msg: 'Tag extensions must have a parent in the HED schema.'
}

Property

Meaning

hedCode

The HED error code from Appendix B, such as TAG_INVALID. Several internal codes share one.

internalCode

The validator’s own, more specific code, such as invalidTag. Use it to tell cases apart.

level

'error' or 'warning'. An error makes the annotation invalid; a warning does not.

message

The full message: level, code, the text with its parameters filled in, and a link to the code.

parameters

The values filled into the message, such as the tag, the sidecar key, or the TSV line.

message is built when it is read, from the template for internalCode and from parameters. Its last part names the code’s section of Appendix B.

Exceptions: IssueError

Most functions return their issues. A few cannot go on after a problem and throw it instead, as an IssueError whose issue property is the Issue. The main one is schema loading:

try {
  await buildSchemasFromVersion('8.4.0, 8.3.0')
} catch (error) {
  if (error instanceof IssueError) {
    console.log(error.issue.hedCode, error.issue.internalCode)
  } else {
    throw error
  }
}

prints

SCHEMA_LOAD_FAILED multipleVersionsOfSameLibrarySchema

BidsDataset.create catches these and returns them as creation issues, so it does not throw for a bad dataset (see Validating BIDS datasets).

BIDS issues: BidsHedIssue

BidsSidecar.validate, BidsTsvFile.validate, BidsDataset.create, and BidsDataset.validate return BidsHedIssue objects, the form the BIDS validator uses. Each wraps an Issue (hedIssue) and adds the file: code is HED_ERROR or HED_WARNING, subCode is the HED code, severity the level, location the file path, and line the line of a tabular file. The fields are listed in Issues returned.

BidsHedIssue has static helpers for lists of issues:

  • splitErrors(issues) - a Map from level ('error', 'warning') to the issues of that level.

  • categorizeByCode(issues) - a Map from HED code to the issues with that code.

  • processIssues(issues, checkWarnings, limitErrors) - the errors, plus the warnings if checkWarnings is true; if limitErrors is true, only the first issue of each code, with a count of all of them added to its message.

const file = new BidsTsvFile(
  'events.tsv',
  { path: 'events.tsv' },
  'onset\tduration\tHED\n0.5\t0\tRed/Blech\n1.5\t0\tBlech\n',
)
const issues = file.validate(schemas)
console.log(issues.map((issue) => `${issue.severity} ${issue.subCode} line ${issue.line}`))
console.log(BidsHedIssue.processIssues(issues).length, BidsHedIssue.processIssues(issues, true).length)

prints

[ 'error TAG_INVALID line 3', 'warning TAG_EXTENDED line 2' ]
1 2

Error codes

The table lists every HED code the package can report, with its level and the internal codes that produce it. It is generated from src/issues/data.ts, which holds the 114 issue templates. Each linked code opens its section of Appendix B. INTERNAL_ERROR (a failure inside the validator, or a file it could not read) and VERSION_DEPRECATED have no section there.

HED code

Level

Internal codes

CHARACTER_INVALID

error

invalidCharacter, invalidValueCharacter, curlyBracesInHedColumn, curlyBracesNotAllowed

COMMA_MISSING

error

commaMissing

DEFINITION_INVALID

error

invalidPlaceholderInDefinition, invalidDefinition, invalidDefinitionManager, nestedDefinition, invalidDefinitionGroupStructure, invalidDefinitionForbidden, duplicateDefinition, conflictingDefinitions, duplicateDefinitionNames, multipleTagGroupsInDefinition, illegalDefinitionGroupTag, illegalDefinitionContext, curlyBracesInDefinition

DEF_EXPAND_INVALID

error

missingDefinitionForDefExpand, invalidDefExpandGroupStructure, defExpandContentsInvalid

DEF_INVALID

error

missingDefinitionForDef

ELEMENT_DEPRECATED

warning

deprecatedTag

INTERNAL_ERROR

error

internalError, networkReadError, fileReadError, genericError

PARENTHESES_MISMATCH

error

parentheses, unopenedParenthesis, unclosedParenthesis

PLACEHOLDER_INVALID

error

invalidPlaceholderContext, invalidSidecarPlaceholder, invalidPlaceholder, missingPlaceholder, extraPlaceholder

REQUIRED_TAG_MISSING

warning

requiredPrefixMissing

SCHEMA_DUPLICATE_NODE

error

duplicateTagsInSchema

SCHEMA_LOAD_FAILED

error

invalidSchemaSpecification, missingSchemaSpecification, multipleVersionsOfSameLibrarySchema, bundledSchemaLoadFailed, localSchemaLoadFailed, remoteSchemaLoadFailed, differentWithStandard, lazyPartneredSchemaOverloadsStandardTag, lazyPartneredSchemasShareTag, lazyPartneredSchemasShareEntry, nonPartneredSchemaWithAnotherSchema, invalidSchema

SIDECAR_BRACES_INVALID

error

unopenedCurlyBrace, unclosedCurlyBrace, nestedCurlyBrace, emptyCurlyBrace, recursiveCurlyBraces, recursiveCurlyBracesWithKey, undefinedCurlyBraces

SIDECAR_INVALID

error

illegalSidecarHedType, illegalSidecarHedKey, paddedSidecarKey, paddedSidecarCategoricalKey, illegalSidecarData, illegalSidecarHedCategoricalValue, illegalSidecarHedDeepKey

SIDECAR_KEY_MISSING

warning

sidecarKeyMissing, hedUsedAsSpliceButNoTsvHed

TABULAR_INVALID

error

duplicateTsvColumn, paddedTsvColumn, blankTsvColumn, emptyTsvLine, tsvCellCount, paddedTsvValue

TAG_EMPTY

error

emptyTagFound

TAG_EXPRESSION_REPEATED

error

duplicateTag, duplicateTagInSubstitution

TAG_EXTENDED

warning

extendedTag

TAG_EXTENSION_INVALID

error

invalidParentNode, invalidExtension

TAG_GROUP_ERROR

error

missingTagGroup, invalidTagGroup, forbiddenSubgroupTags, invalidTopLevelTagGroupTag, invalidGroupTags, invalidGroupTopTags, tooManyGroupTopTags, multipleTopLevelTagGroupTags, invalidNumberOfSubgroups, invalidTopLevelTag, invalidGroupTag, curlyBracesInReservedGroup

TAG_INVALID

error

invalidTag, extraSlash, extraBlank, extraCommaOrInvalid, childForbidden, illegalInExclusiveContext, invalidTagString

TAG_NAMESPACE_PREFIX_INVALID

error

invalidTagPrefix, unmatchedBaseSchema, unmatchedLibrarySchema

TAG_NOT_UNIQUE

error

multipleUniqueTags

TAG_REQUIRES_CHILD

error

childRequired, valueRequired

TEMPORAL_TAG_ERROR

error

inactiveOnset, temporalWithoutInnerGroup, temporalWithWrongNumberDefs, temporalWithWrongNumberOfGroups, temporalWithoutDefinition, extraTagsInTemporal, temporalTagInNonTemporalContext, temporalTagNoConversion, duplicateTemporal, multipleTemporalTags, multipleRequiresDefTags, simultaneousDuplicateEvents

UNITS_INVALID

error

unitClassInvalidUnit

VALUE_INVALID

error

invalidValue

VERSION_DEPRECATED

error

deprecatedStandardSchemaVersion