Members
destinationTags
The destination schema's tag collection.
- Source:
(constant) find
Execute an XPath query on an xml2js object.
- Source:
(constant) generateIssue
Generate a new issue object.
- Source:
(constant) getCharacterCount
Get number of instances of an character in a string.
- Source:
(constant) getTagSlashIndices
Get the indices of all slashes in a HED tag.
- Source:
hasUnitClass
Checks if this HED tag has the {@code unitClass} attribute.
- Source:
isDeprecated
Indicates whether the tag is deprecated
- Source:
isExtended
Indicates whether the tag is deprecated
- Source:
(constant) localSchemas
Bundled HED schema configuration.
- Source:
normalized
Return a normalized string representation
- Source:
normalized
Return the normalized version of this tag.
- Source:
schemaTag
Get the schema tag object for this tag.
- Source:
(constant) setParent
Handle top level of parent-setting recursion before passing to setNodeParent.
- Source:
sourceTags
The source schema's tag collection.
- Source:
(constant) stringTemplate
Parse a template literal string. Copied from
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals.
- Source:
takesValue
Checks if this HED tag has the {@code takesValue} attribute.
- Source:
takesValueTag
Get the schema tag object for this tag's value-taking form.
- Source:
unitClasses
Get the unit classes for this HED tag.
- Source:
Methods
_convertTag(hedSchemas, hedString, tagSpec)
Convert this tag to its various forms
Parameters:
Name | Type | Description |
---|---|---|
hedSchemas |
Schemas | The collection of HED schemas. |
hedString |
string | The original HED string. |
tagSpec |
TagSpec | The token for this tag. |
- Source:
Throws:
-
If tag conversion or parsing fails.
- Type
- IssueError
_createParsedGroups(tags, groupSpecs) → {Array.<ParsedHedGroup>}
Create parsed HED groups from parsed tags and group specifications.
Parameters:
Name | Type | Description |
---|---|---|
tags |
Array.<ParsedHedTag> | The parsed HED tags. |
groupSpecs |
Array.<GroupSpec> | The group specifications. |
- Source:
Returns:
The parsed HED groups.
- Type
- Array.<ParsedHedGroup>
_createParsedTags(tagSpecs, groupSpecs) → {Array}
Create parsed HED tags and groups from specifications.
Parameters:
Name | Type | Description |
---|---|---|
tagSpecs |
Array.<TagSpec> | The tag specifications. |
groupSpecs |
GroupSpec | The group specifications. |
- Source:
Returns:
- [ParsedHedSubstring[], Issue[]] representing the parsed HED tags and any issues found.
- Type
- Array
_getSplitValue(remainder)
Handle reserved three-level tags.
Parameters:
Name | Type | Description |
---|---|---|
remainder |
string | The remainder of the tag string after schema tag. |
- Source:
_handleIssueError(issueError)
Handle any issue encountered during tag parsing.
Parameters:
Name | Type | Description |
---|---|---|
issueError |
Error | IssueError | The error encountered. |
- Source:
(protected) _memoize(propertyName, valueComputer) → {T}
Memoize a property.
Parameters:
Name | Type | Description |
---|---|---|
propertyName |
string | The property name. |
valueComputer |
function | A function to compute the property's value. |
- Source:
Returns:
The computed value.
- Type
- T
_separateUnits(schemaTag, remainder) → {Array}
Separate the remainder of the tag into three parts.
Parameters:
Name | Type | Description |
---|---|---|
schemaTag |
SchemaTag | The part of the tag that is in the schema. |
remainder |
string | The leftover part. |
- Source:
Throws:
-
- If parsing the remainder section fails.
- Type
- IssueError
Returns:
- [SchemaUnit, string, string] representing the actual Unit, the unit string and the value string.
- Type
- Array
buildBidsSchemas(datasetDescription) → {Promise}
Build a HED schema collection based on the defined BIDS schemas.
Parameters:
Name | Type | Description |
---|---|---|
datasetDescription |
BidsJsonFile | The description of the BIDS dataset being validated. |
- Source:
Throws:
-
If the schema specification is invalid.
- Type
- IssueError
Returns:
A Promise with the schema collection, or null if the specification is missing.
- Type
- Promise
buildSchemaObject(xmlData) → {Schema}
Build a single schema container object from an XML file.
Parameters:
Name | Type | Description |
---|---|---|
xmlData |
Object | The schema's XML data |
- Source:
Returns:
The HED schema object.
- Type
- Schema
buildSchemaObjects(xmlData) → {Schema}
Build a single merged schema container object from one or more XML files.
Parameters:
Name | Type | Description |
---|---|---|
xmlData |
Array.<Object> | The schemas' XML data. |
- Source:
Returns:
The HED schema object.
- Type
- Schema
buildSchemas(schemaSpecs) → {Promise.<Schemas>}
Build a schema collection object from a schema specification.
Parameters:
Name | Type | Description |
---|---|---|
schemaSpecs |
SchemasSpec | The description of which schemas to use. |
- Source:
Returns:
The schema container object and any issues found.
- Type
- Promise.<Schemas>
buildSchemasSpec(datasetDescription) → {SchemasSpec|null}
Build a HED schema specification based on the defined BIDS schemas.
Parameters:
Name | Type | Description |
---|---|---|
datasetDescription |
BidsJsonFile | The description of the BIDS dataset being validated. |
- Source:
Throws:
-
If the schema specification is invalid.
- Type
- IssueError
Returns:
The schema specification to be used to build the schemas, or null if the specification is missing.
- Type
- SchemasSpec | null
categorizeTagsByName(tagList, tagNames) → {Map}
Create a map of the ParsedHedTags by type.
Parameters:
Name | Type | Description |
---|---|---|
tagList |
Array.<ParsedHedTag> | The HED tags to be categorized. |
tagNames |
Set | The tag names to use as categories. |
- Source:
Returns:
- A map (string --> ParsedHedTag) of tag name to a list of tags with that name.
- Type
- Map
checkValue(value) → {boolean}
Check if value is a valid value for this tag.
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The value to be checked. |
- Source:
Returns:
The result of check -- false if not a valid value.
- Type
- boolean
cleanupEmpties(stringIn) → {string}
lean up a string and remove redundant commas and parentheses.
Parameters:
Name | Type | Description |
---|---|---|
stringIn |
string | The input string to be cleaned up. |
- Source:
Returns:
- The cleaned-up string with redundant commas and parentheses removed.
- Type
- string
(generator) columnSpliceIterator() → {ParsedHedColumnSplice}
Iterator over the parsed HED column splices in this HED tag group.
- Source:
Yields:
This tag group's HED column splices.
convert() → {Array}
Retrieve the SchemaTag object for a tag specification.
- Source:
Throws:
-
If tag conversion.
- Type
- IssueError
Returns:
- [SchemaTag, string] representing schema's corresponding tag object and the remainder of the tag string.
- Type
- Array
convertParsedTSVData(oldParsedTsv) → {Map.<string, Array.<string>>}
Convert parsed TSV file data from the old BIDS format to the new BIDS format.
Parameters:
Name | Type | Description |
---|---|---|
oldParsedTsv |
Object | Parsed TSV data using the old format |
- Source:
Returns:
The parsed contents of the TSV file, using the new format.
- Type
- Map.<string, Array.<string>>
equivalent(other) → {boolean}
Determine if this HED tag is equivalent to another HED tag. Note: HED tags are deemed equivalent if they
have the same schema and normalized tag string.
Parameters:
Name | Type | Description |
---|---|---|
other |
ParsedHedTag | A HED tag to compare with this one. |
- Source:
Returns:
Whether other True, if other is equivalent to this HED tag.
- Type
- boolean
filterByClass(items, classType) → {Array.<ParsedHedSubstring>}
Extract the items of a specified subtype from a list of ParsedHedSubstring
Parameters:
Name | Type | Description |
---|---|---|
items |
Array.<ParsedHedSubstring> | Objects to be filtered by class type. |
classType |
Class | The class type to filter by. |
- Source:
Returns:
- A list of objects of the specified subclass of ParsedHedSubstring
- Type
- Array.<ParsedHedSubstring>
filterByTagName(tags, tagName) → {Array.<ParsedHedTag>}
Extract the ParsedHedTag tags with a specified tag name
Parameters:
Name | Type | Description |
---|---|---|
tags |
Array.<ParsedHedTag> | to be filtered by name |
tagName |
string | name of the tag to filter by |
- Source:
Returns:
- Type
- Array.<ParsedHedTag>
filterTagMapByNames(tagMap, tagNames) → {Array.<ParsedHedTag>}
Extract the ParsedHedTag tags with a specified tag name.
Parameters:
Name | Type | Description |
---|---|---|
tagMap |
Map.<string, Array.<ParsedHedTag>> | The Map of parsed HED tags for extraction (must be defined). |
tagNames |
Array.<string> | The names to use as keys for the filter. |
- Source:
Returns:
- A list of temporal tags.
- Type
- Array.<ParsedHedTag>
format(long) → {string}
Nicely format this tag group.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
long |
boolean | true | Whether the tags should be in long form. |
- Source:
Returns:
- Type
- string
format(long) → {string}
Nicely format this tag.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
long |
boolean | true | Whether the tags should be in long form. |
- Source:
Returns:
- The nicely formatted version of this tag.
- Type
- string
getAllTags(tagElementName) → {Map.<Object, string>}
Retrieve all the tags in the schema.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
tagElementName |
string | node | The name of the tag element. |
- Source:
Returns:
The tag names and XML elements.
- Type
- Map.<Object, string>
getDuplicates(itemList) → {Array.<string>}
Return a list of duplicate strings.
Parameters:
Name | Type | Description |
---|---|---|
itemList |
Array.<string> | A list of strings to look for duplicates in. |
- Source:
Returns:
- A list of unique duplicate strings (multiple copies not repeated).
- Type
- Array.<string>
getElementTagName(element) → {string}
Extract the name of an XML element. NOTE: This method cannot be merged into
getElementTagValue because it is used as a first-class object.
Parameters:
Name | Type | Description |
---|---|---|
element |
Object | An XML element. |
- Source:
Returns:
The name of the element.
- Type
- string
getElementTagValue(element, tagName) → {string}
Extract a value from an XML element.
Parameters:
Name | Type | Description |
---|---|---|
element |
Object | An XML element. |
tagName |
string | The tag value to extract. |
- Source:
Returns:
The value of the tag in the element.
- Type
- string
getTagListString(tagList) → {string}
Convert a list of ParsedHedTag objects into a comma-separated string of their string representations.
Parameters:
Name | Type | Description |
---|---|---|
tagList |
Array.<ParsedHedTag> | The HED tags whose string representations should be put in a comma-separated list. |
- Source:
Returns:
A comma separated list of original tag names for tags in tagList.
- Type
- string
hasAttribute(attribute) → {boolean}
Determine whether this tag has a given attribute.
Parameters:
Name | Type | Description |
---|---|---|
attribute |
string | An attribute name. |
- Source:
Returns:
Whether this tag has the named attribute.
- Type
- boolean
(async) loadBundledSchema(schemaDef) → {Promise.<object>}
Load schema XML data from a bundled file.
Parameters:
Name | Type | Description |
---|---|---|
schemaDef |
SchemaSpec | The description of which schema to use. |
- Source:
Throws:
-
If the schema could not be loaded.
- Type
- IssueError
Returns:
The schema XML data.
- Type
- Promise.<object>
loadLocalSchema(path) → {Promise.<object>}
Load schema XML data from a local file.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | The path to the schema XML data. |
- Source:
Throws:
-
If the schema could not be loaded.
- Type
- IssueError
Returns:
The schema XML data.
- Type
- Promise.<object>
(async) loadPromise(schemaDef) → {Promise.<Object>}
Choose the schema Promise from a schema version or path description.
Parameters:
Name | Type | Description |
---|---|---|
schemaDef |
SchemaSpec | The description of which schema to use. |
- Source:
Throws:
-
If the schema could not be loaded.
- Type
- IssueError
Returns:
The schema XML data.
- Type
- Promise.<Object>
loadRemoteSchema(schemaDef) → {Promise.<object>}
Load schema XML data from the HED GitHub repository.
Parameters:
Name | Type | Description |
---|---|---|
schemaDef |
SchemaSpec | The standard schema version to load. |
- Source:
Throws:
-
If the schema could not be loaded.
- Type
- IssueError
Returns:
The schema XML data.
- Type
- Promise.<object>
(async) loadSchemaFile(xmlDataPromise, issueCode, issueArgs) → {Promise.<object>}
Actually load the schema XML file.
Parameters:
Name | Type | Description |
---|---|---|
xmlDataPromise |
Promise.<string> | The Promise containing the unparsed XML data. |
issueCode |
string | The issue code. |
issueArgs |
Object.<string, string> | The issue arguments passed from the calling function. |
- Source:
Throws:
-
If the schema could not be loaded.
- Type
- IssueError
Returns:
The parsed schema XML data.
- Type
- Promise.<object>
mergeSchemas() → {PartneredSchema}
Merge the lazy partnered schemas.
- Source:
Returns:
The merged partnered schema.
- Type
- PartneredSchema
parseHedString(hedString, hedSchemas, definitionsAllowed, placeholdersAllowed, fullValidation) → {Array}
Parse a HED string. ###Note: now separates errors and warnings for easier handling.
Parameters:
Name | Type | Description |
---|---|---|
hedString |
string | ParsedHedString | A (possibly already parsed) HED string. |
hedSchemas |
Schemas | The collection of HED schemas. |
definitionsAllowed |
boolean | True if definitions are allowed. |
placeholdersAllowed |
boolean | True if placeholders are allowed. |
fullValidation |
boolean | True if full validation is required. |
- Source:
Returns:
- [ParsedHedString, Issue[], Issue[]] representing the parsed HED string and any issues found.
- Type
- Array
parseHedStrings(hedStrings, hedSchemas, definitionsAllowed, placeholdersAllowed) → {Array}
Parse a list of HED strings. ###Note: now separates errors and warnings for easier handling.
Parameters:
Name | Type | Description |
---|---|---|
hedStrings |
Array.<string> | Array.<ParsedHedString> | A list of HED strings. |
hedSchemas |
Schemas | The collection of HED schemas. |
definitionsAllowed |
boolean | True if definitions are allowed |
placeholdersAllowed |
boolean | True if placeholders are allowed |
- Source:
Returns:
- [ParsedHedString[], Issue[], Issue[]] representing the parsed HED strings and any issues found.
- Type
- Array
parseSchemaXML(data) → {Promise.<object>}
Parse the schema XML data.
Parameters:
Name | Type | Description |
---|---|---|
data |
string | The XML data. |
- Source:
Returns:
The schema XML data.
- Type
- Promise.<object>
parseTSV(contents) → {Map.<string, Array.<string>>}
Parse a TSV file.
Parameters:
Name | Type | Description |
---|---|---|
contents |
string | The contents of a TSV file. |
- Source:
Returns:
The parsed contents of the TSV file.
- Type
- Map.<string, Array.<string>>
parseTags()
Parse the schema's tags.
- Source:
parseXPath(query) → {Object}
Parse an XPath query. This is a minimal parser only suitable for this package.
Parameters:
Name | Type | Description |
---|---|---|
query |
string | An XPath query. |
- Source:
Returns:
The parsed search parameters.
- Type
- Object
readFile(fileName) → {Promise}
Read a local file.
Parameters:
Name | Type | Description |
---|---|---|
fileName |
string | The file path. |
- Source:
Returns:
- A promise with the file contents.
- Type
- Promise
readHTTPSFile(url) → {Promise.<string>}
Read a remote file using HTTPS.
Parameters:
Name | Type | Description |
---|---|---|
url |
string | The remote URL. |
- Source:
Returns:
A promise with the file contents.
- Type
- Promise.<string>
recursiveMap(fn, array) → {Array.<U>}
Apply a function recursively to an array.
Parameters:
Name | Type | Description |
---|---|---|
fn |
function | The function to apply. |
array |
Array.<T> | The array to map. |
- Source:
Returns:
The mapped array.
- Type
- Array.<U>
search(element, elementName, attributeName) → {Array.<Object>}
Search for children of an element with a given name and attribute.
Parameters:
Name | Type | Description |
---|---|---|
element |
Object | An xml2js element. |
elementName |
string | The element name. |
attributeName |
string | The attribute name. |
- Source:
Returns:
An array of xml2js elements with the given name and attribute.
- Type
- Array.<Object>
setNodeParent(node, parent)
Recursively set a field on each node of the tree pointing to the node's parent.
Parameters:
Name | Type | Description |
---|---|---|
node |
Object | The child node. |
parent |
Object | The parent node. |
- Source:
splitHedString() → {Array}
Split and parse a HED string into tags and groups.
- Source:
Returns:
- [ParsedHedSubstring[], Issue[]] representing the parsed HED string data and any issues found.
- Type
- Array
stripBOM()
Module for parsing TSV files. Adapted from
https://github.com/bids-standard/bids-validator/blob/6fc6d152b52266934575442e61f1477ba18f42ec/bids-validator/validators/tsv/tsvParser.js
and
https://github.com/bids-standard/bids-validator/blob/a5c63b445e3103bcc0843deac192033a9f0b4c5b/bids-validator/src/files/tsv.ts
- Source:
(generator) subParsedGroupIterator(tagName) → {ParsedHedGroup}
Iterator over the ParsedHedGroup objects in this HED tag group.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
tagName |
string | null | null | The name of the tag whose groups are to be iterated over or null if all tags. |
- Source:
Yields:
- This object and the ParsedHedGroup objects belonging to this tag group.
- Type
- ParsedHedGroup
(generator) tagIterator() → {ParsedHedTag}
Iterator over the parsed HED tags in this HED tag group.
- Source:
Yields:
This tag group's HED tags.
- Type
- ParsedHedTag
toString() → {string}
Override of Object.prototype.toString.
- Source:
Returns:
The original form of this HED tag.
- Type
- string
(generator) topLevelGroupIterator() → {ParsedHedTag}
Iterator over the top-level parsed HED groups in this HED tag group.
- Source:
Yields:
This tag group's top-level HED groups.
- Type
- ParsedHedTag