Skip to content

Commit

Permalink
update hed-validator map file. Add lookup for old style hed issues
Browse files Browse the repository at this point in the history
  • Loading branch information
rwblair committed Sep 26, 2023
1 parent 398e62e commit 9a6caf9
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
8 changes: 4 additions & 4 deletions bids-validator/src/deps/hed-validator/index.js.map

Large diffs are not rendered by default.

40 changes: 39 additions & 1 deletion bids-validator/src/issues/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,42 @@ export const filenameIssues: IssueDefinitionRecord = {
},
}

export const nonSchemaIssues = { ...filenameIssues }
const hedIssues = {
HED_ERROR: {
severity: 'error',
reason: 'The validation on this HED string returned an error.',
},
HED_WARNING: {
severity: 'warning',
reason: 'The validation on this HED string returned a warning.',
},
HED_INTERNAL_ERROR: {
severity: 'error',
reason: 'An internal error occurred during HED validation.',
},
HED_INTERNAL_WARNING: {
severity: 'warning',
reason: 'An internal warning occurred during HED validation.',
},
HED_MISSING_VALUE_IN_SIDECAR: {
severity: 'warning',
reason:
'The json sidecar does not contain this column value as a possible key to a HED string.',
},
HED_VERSION_NOT_DEFINED: {
severity: 'warning',
reason:
"You should define 'HEDVersion' for this file. If you don't provide this information, the HED validation will use the latest version available.",
},
}

export const hedOldToNewLookup = {
104: hedIssues['HED_ERROR'],
105: hedIssues['HED_WARNING'],
106: hedIssues['HED_INTERNAL_ERROR'],
107: hedIssues['HED_INTERNAL_WARNING'],
108: hedIssues['HED_MISSING_VALUE_IN_SIDECAR'],
109: hedIssues['HED_VERSION_NOT_DEFINED']
}

export const nonSchemaIssues = { ...filenameIssues, ...hedIssues }
20 changes: 20 additions & 0 deletions bids-validator/src/validators/hed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ function columnsToContent(columns): tsvContent {
}
}

function detectHed(tsvData, sidecarData) {
return (
sidecarData.some((sidecarFileData) => {
return Object.values(sidecarFileData.sidecarData).some(sidecarValueHasHed)
}) ||
tsvData.some((tsvFileData) => {
return tsvFileData.parsedTsv.headers.indexOf('HED') !== -1
})
)
}

function sidecarValueHasHed(sidecarValue) {
return (
sidecarValue !== null &&
typeof sidecarValue === 'object' &&
sidecarValue.HED !== undefined
)
}

export async function hedAccumulator(schema, context) {
if (context.file.name == 'dataset_description.json') {
hedArgs.datasetDescription = new hedValidator.validator.BidsJsonFile(
Expand Down Expand Up @@ -65,3 +84,4 @@ export async function hedValidate(schema, dsContext, issues) {
})
return Promise.resolve()
}

0 comments on commit 9a6caf9

Please sign in to comment.