Skip to content

Commit

Permalink
Missing HED column when using {HED} is not an error
Browse files Browse the repository at this point in the history
  • Loading branch information
VisLab committed Oct 28, 2024
1 parent aa3884e commit 24f1ffc
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 37 deletions.
11 changes: 6 additions & 5 deletions parser/columnSplicer.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,15 @@ export class ColumnSplicer {
_spliceHedColumnTemplate() {
const columnName = 'HED'
const replacementString = this.columnValues.get(columnName)
if (replacementString === null || replacementString === 'n/a' || replacementString === '') {
if (
replacementString === undefined ||
replacementString === null ||
replacementString === 'n/a' ||
replacementString === ''
) {
return null
}

if (replacementString === undefined) {
this.issues.push(generateIssue('undefinedCurlyBraces', { column: columnName }))
return []
}
return this._reparseAndSpliceString(replacementString)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/bidsTests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const fs = require('fs')
const displayLog = true

// Ability to select individual tests to run
const runAll = false
const runAll = true
let onlyRun = new Map()
if (!runAll) {
onlyRun = new Map([['duplicate-tag-tests', ['invalid-duplicate-groups-first-level-tsv']]])
Expand Down
92 changes: 73 additions & 19 deletions tests/runLog.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,77 @@
Total tests:3 Wrong errors:0 MissingErrors:0
----Skipping valid-bids-datasets-with-limited-hed: no-hed-at-all-but-both-tsv-json-non-empty
----Skipping valid-bids-datasets-with-limited-hed: only-header-in-tsv-with-return
----Skipping valid-bids-datasets-with-limited-hed: empty-json-empty-tsv
----Skipping valid-json-invalid-tsv: valid-sidecar-bad-tag-tsv
----Skipping valid-json-invalid-tsv: valid-sidecar-tsv-curly-brace
----Skipping duplicate-tag-tests: invalid-first-level-duplicate-json-tsv
Total tests:57 Wrong errors:0 MissingErrors:0
[no-hed-at-all-but-both-tsv-json-non-empty (Expect pass)]
[valid-bids-datasets-with-limited-hed:no-hed-at-all-but-both-tsv-json-non-empty][Sidecar only](Expect pass)
[valid-bids-datasets-with-limited-hed:no-hed-at-all-but-both-tsv-json-non-empty][Events only](Expect pass)
[valid-bids-datasets-with-limited-hed:no-hed-at-all-but-both-tsv-json-non-empty][Events+side](Expect pass)
[only-header-in-tsv-with-return (Expect pass)]
[valid-bids-datasets-with-limited-hed:only-header-in-tsv-with-return][Sidecar only](Expect pass)
[valid-bids-datasets-with-limited-hed:only-header-in-tsv-with-return][Events only](Expect pass)
[valid-bids-datasets-with-limited-hed:only-header-in-tsv-with-return][Events+side](Expect pass)
[empty-json-empty-tsv (Expect pass)]
[valid-bids-datasets-with-limited-hed:empty-json-empty-tsv][Sidecar only](Expect pass)
[valid-bids-datasets-with-limited-hed:empty-json-empty-tsv][Events only](Expect pass)
[valid-bids-datasets-with-limited-hed:empty-json-empty-tsv][Events+side](Expect pass)
[valid-sidecar-bad-tag-tsv (Expect pass)]
[valid-json-invalid-tsv:valid-sidecar-bad-tag-tsv][Sidecar only](Expect pass)
[valid-json-invalid-tsv:valid-sidecar-bad-tag-tsv][Events only](Expect fail)
[valid-json-invalid-tsv:valid-sidecar-bad-tag-tsv][Events+side](Expect fail)
[valid-sidecar-tsv-curly-brace (Expect pass)]
[valid-json-invalid-tsv:valid-sidecar-tsv-curly-brace][Sidecar only](Expect pass)
[valid-json-invalid-tsv:valid-sidecar-tsv-curly-brace][Events only](Expect fail)
[valid-json-invalid-tsv:valid-sidecar-tsv-curly-brace][Events+side](Expect fail)
[invalid-first-level-duplicate-json-tsv (Expect pass)]
[duplicate-tag-tests:invalid-first-level-duplicate-json-tsv][Sidecar only](Expect pass)
[duplicate-tag-tests:invalid-first-level-duplicate-json-tsv][Events only](Expect pass)
[duplicate-tag-tests:invalid-first-level-duplicate-json-tsv][Events+side](Expect fail)
[invalid-duplicate-groups-first-level-tsv (Expect pass)]
[duplicate-tag-tests:invalid-duplicate-groups-first-level-tsv][Sidecar only](Expect pass)
[duplicate-tag-tests:invalid-duplicate-groups-first-level-tsv][Events only](Expect fail)
[duplicate-tag-tests:invalid-duplicate-groups-first-level-tsv][Events+side](Expect fail)
----Skipping curly-brace-tests: valid-curly-brace-in-sidecar-with-value-splice
----Skipping curly-brace-tests: valid-curly-brace-in-sidecar-with-category-splice
----Skipping curly-brace-tests: valid-curly-brace-in-sidecar-with-n/a-splice
----Skipping curly-brace-tests: valid-HED-column-splice
----Skipping curly-brace-tests: valid-HED-column-splice-with-n/a
----Skipping curly-brace-tests: invalid-curly-brace-column-slice-has-no hed
----Skipping curly-brace-tests: invalid-HED-curly-brace-but-tsv-has-no-HED-column
----Skipping curly-brace-tests: invalid-curly-brace-in-HED-tsv-column
----Skipping curly-brace-tests: invalid-curly-brace-in-HED-tsv-column
----Skipping curly-brace-tests: invalid-recursive-curly-braces
----Skipping curly-brace-tests: invalid-self-recursive-curly-braces
----Skipping curly-brace-tests: invalid-recursive-curly-brace-chain
[valid-curly-brace-in-sidecar-with-value-splice (Expect pass)]
[curly-brace-tests:valid-curly-brace-in-sidecar-with-value-splice][Sidecar only](Expect pass)
[curly-brace-tests:valid-curly-brace-in-sidecar-with-value-splice][Events only](Expect pass)
[curly-brace-tests:valid-curly-brace-in-sidecar-with-value-splice][Events+side](Expect pass)
[valid-curly-brace-in-sidecar-with-category-splice (Expect pass)]
[curly-brace-tests:valid-curly-brace-in-sidecar-with-category-splice][Sidecar only](Expect pass)
[curly-brace-tests:valid-curly-brace-in-sidecar-with-category-splice][Events only](Expect pass)
[curly-brace-tests:valid-curly-brace-in-sidecar-with-category-splice][Events+side](Expect pass)
[valid-curly-brace-in-sidecar-with-n/a-splice (Expect pass)]
[curly-brace-tests:valid-curly-brace-in-sidecar-with-n/a-splice][Sidecar only](Expect pass)
[curly-brace-tests:valid-curly-brace-in-sidecar-with-n/a-splice][Events only](Expect pass)
[curly-brace-tests:valid-curly-brace-in-sidecar-with-n/a-splice][Events+side](Expect pass)
[valid-HED-column-splice (Expect pass)]
[curly-brace-tests:valid-HED-column-splice][Sidecar only](Expect pass)
[curly-brace-tests:valid-HED-column-splice][Events only](Expect pass)
[curly-brace-tests:valid-HED-column-splice][Events+side](Expect pass)
[valid-HED-column-splice-with-n/a (Expect pass)]
[curly-brace-tests:valid-HED-column-splice-with-n/a][Sidecar only](Expect pass)
[curly-brace-tests:valid-HED-column-splice-with-n/a][Events only](Expect pass)
[curly-brace-tests:valid-HED-column-splice-with-n/a][Events+side](Expect pass)
[invalid-curly-brace-column-slice-has-no hed (Expect pass)]
[curly-brace-tests:invalid-curly-brace-column-slice-has-no hed][Sidecar only](Expect fail)
[curly-brace-tests:invalid-curly-brace-column-slice-has-no hed][Events only](Expect pass)
[curly-brace-tests:invalid-curly-brace-column-slice-has-no hed][Events+side](Expect fail)
[valid-HED-curly-brace-but-tsv-has-no-HED-column (Expect pass)]
[curly-brace-tests:valid-HED-curly-brace-but-tsv-has-no-HED-column][Sidecar only](Expect pass)
[curly-brace-tests:valid-HED-curly-brace-but-tsv-has-no-HED-column][Events only](Expect pass)
[curly-brace-tests:valid-HED-curly-brace-but-tsv-has-no-HED-column][Events+side](Expect pass)
[invalid-curly-brace-in-HED-tsv-column (Expect pass)]
[curly-brace-tests:invalid-curly-brace-in-HED-tsv-column][Sidecar only](Expect pass)
[curly-brace-tests:invalid-curly-brace-in-HED-tsv-column][Events only](Expect fail)
[curly-brace-tests:invalid-curly-brace-in-HED-tsv-column][Events+side](Expect fail)
[invalid-curly-brace-in-HED-tsv-column (Expect pass)]
[curly-brace-tests:invalid-curly-brace-in-HED-tsv-column][Sidecar only](Expect pass)
[curly-brace-tests:invalid-curly-brace-in-HED-tsv-column][Events only](Expect fail)
[curly-brace-tests:invalid-curly-brace-in-HED-tsv-column][Events+side](Expect fail)
[invalid-recursive-curly-braces (Expect pass)]
[curly-brace-tests:invalid-recursive-curly-braces][Sidecar only](Expect fail)
[curly-brace-tests:invalid-recursive-curly-braces][Events only](Expect pass)
[curly-brace-tests:invalid-recursive-curly-braces][Events+side](Expect fail)
[invalid-self-recursive-curly-braces (Expect pass)]
[curly-brace-tests:invalid-self-recursive-curly-braces][Sidecar only](Expect fail)
[curly-brace-tests:invalid-self-recursive-curly-braces][Events only](Expect pass)
[curly-brace-tests:invalid-self-recursive-curly-braces][Events+side](Expect fail)
[invalid-recursive-curly-brace-chain (Expect pass)]
[curly-brace-tests:invalid-recursive-curly-brace-chain][Sidecar only](Expect fail)
[curly-brace-tests:invalid-recursive-curly-brace-chain][Events only](Expect pass)
[curly-brace-tests:invalid-recursive-curly-brace-chain][Events+side](Expect fail)
15 changes: 3 additions & 12 deletions tests/testData/bidsTests.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ export const bidsTestData = [
},
{
testname: 'invalid-curly-brace-column-slice-has-no hed',
explanation: 'A column name is used in a splice but does not have HED',
explanation: 'A column name is used in a splice but does not have a HED key',
schemaVersion: '8.3.0',
sidecar: {
event_code: {
Expand All @@ -351,7 +351,7 @@ export const bidsTestData = [
],
},
{
testname: 'invalid-HED-curly-brace-but-tsv-has-no-HED-column',
testname: 'valid-HED-curly-brace-but-tsv-has-no-HED-column',
explanation: 'A {HED} column splice is used in a sidecar but the tsv has no HED column',
schemaVersion: '8.3.0',
sidecar: {
Expand All @@ -365,16 +365,7 @@ export const bidsTestData = [
eventsString: 'onset\tduration\tevent_code\n' + '19\t6\tball\n',
sidecarOnlyErrors: [],
eventsOnlyErrors: [],
comboErrors: [
BidsHedIssue.fromHedIssue(
generateIssue('undefinedCurlyBraces', { column: 'HED' }),
{
path: 'invalid-HED-curly-brace-but-tsv-has-no-HED-column.tsv',
relativePath: 'invalid-HED-curly-brace-but-tsv-has-no-HED-column.tsv',
},
{ tsvLine: 2 },
),
],
comboErrors: [],
},
{
testname: 'invalid-curly-brace-in-HED-tsv-column',
Expand Down

0 comments on commit 24f1ffc

Please sign in to comment.