Skip to content

Commit

Permalink
Merge pull request #239 from VisLab/revised-validator
Browse files Browse the repository at this point in the history
Duration should be allowed in files without timeline
  • Loading branch information
VisLab authored Jan 8, 2025
2 parents 2d74edf + e1aa32a commit ff30baa
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bids/validator/tsvValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export class BidsHedTsvValidator extends BidsValidator {
_checkNoTime(elements) {
const timeIssues = []
for (const element of elements) {
if (element.parsedHedString.tags.some((tag) => this.special.temporalTags.has(tag.schemaTag.name))) {
if (element.parsedHedString.tags.some((tag) => this.special.timelineTags.has(tag.schemaTag.name))) {
timeIssues.push(
BidsHedIssue.fromHedIssue(
generateIssue('temporalTagInNonTemporalContext', { string: element.hedString, tsvLine: element.tsvLine }),
Expand Down
18 changes: 9 additions & 9 deletions data/json/reservedTags.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"ERROR_CODE": "DEF_INVALID",
"noSpliceInGroup": false,
"forbiddenSubgroupTags": [],
"isTemporalTag": false,
"requiresTimeline": false,
"requiresDef": false,
"otherAllowedNonDefTags": null
},
Expand All @@ -31,7 +31,7 @@
"ERROR_CODE": "DEF_EXPAND_INVALID",
"noSpliceInGroup": true,
"forbiddenSubgroupTags": ["Def", "Def-expand"],
"isTemporalTag": false,
"requiresTimeline": false,
"requiresDef": false,
"otherAllowedNonDefTags": []
},
Expand All @@ -49,7 +49,7 @@
"ERROR_CODE": "DEFINITION_INVALID",
"noSpliceInGroup": true,
"forbiddenSubgroupTags": ["Def", "Def-expand"],
"isTemporalTag": false,
"requiresTimeline": false,
"requiresDef": false,
"otherAllowedNonDefTags": []
},
Expand All @@ -67,7 +67,7 @@
"ERROR_CODE": "TEMPORAL_TAG_ERROR",
"noSpliceInGroup": false,
"forbiddenSubgroupTags": [],
"isTemporalTag": true,
"requiresTimeline": true,
"requiresDef": false,
"otherAllowedNonDefTags": ["Duration", "Onset", "Offset", "Inset"]
},
Expand All @@ -85,7 +85,7 @@
"ERROR_CODE": "TEMPORAL_TAG_ERROR",
"noSpliceInGroup": false,
"forbiddenSubgroupTags": [],
"isTemporalTag": true,
"requiresTimeline": false,
"requiresDef": false,
"otherAllowedNonDefTags": ["Delay"]
},
Expand All @@ -103,7 +103,7 @@
"ERROR_CODE": "TAG_GROUP_ERROR",
"noSpliceInGroup": true,
"forbiddenSubgroupTags": [],
"isTemporalTag": false,
"requiresTimeline": false,
"requiresDef": false,
"otherAllowedNonDefTags": []
},
Expand All @@ -121,7 +121,7 @@
"ERROR_CODE": "TEMPORAL_TAG_ERROR",
"noSpliceInGroup": false,
"forbiddenSubgroupTags": [],
"isTemporalTag": true,
"requiresTimeline": true,
"requiresDef": true,
"otherAllowedNonDefTags": ["Delay"]
},
Expand All @@ -139,7 +139,7 @@
"ERROR_CODE": "TEMPORAL_TAG_ERROR",
"noSpliceInGroup": false,
"forbiddenSubgroupTags": [],
"isTemporalTag": true,
"requiresTimeline": true,
"requiresDef": true,
"otherAllowedNonDefTags": ["Delay"]
},
Expand All @@ -157,7 +157,7 @@
"ERROR_CODE": "TEMPORAL_TAG_ERROR",
"noSpliceInGroup": false,
"forbiddenSubgroupTags": [],
"isTemporalTag": true,
"requiresTimeline": true,
"requiresDef": true,
"otherAllowedNonDefTags": ["Delay"]
}
Expand Down
2 changes: 1 addition & 1 deletion parser/reservedChecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ReservedChecker {
this.requiresDefTags = ReservedChecker._getSpecialTagsByProperty('requiresDef')
this.groupTags = ReservedChecker._getSpecialTagsByProperty('tagGroup')
this.exclusiveTags = ReservedChecker._getSpecialTagsByProperty('exclusive')
this.temporalTags = ReservedChecker._getSpecialTagsByProperty('isTemporalTag')
this.timelineTags = ReservedChecker._getSpecialTagsByProperty('requiresTimeline')
this.noSpliceInGroup = ReservedChecker._getSpecialTagsByProperty('noSpliceInGroup')
this.hasForbiddenSubgroupTags = new Set(
[...ReservedChecker.reservedMap.values()]
Expand Down
2 changes: 1 addition & 1 deletion tests/bidsTests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { DefinitionManager } from '../parser/definitionManager'
//const skipMap = new Map([['definition-tests', ['invalid-missing-definition-for-def', 'invalid-nested-definition']]])
const skipMap = new Map()
const runAll = true
const runMap = new Map([['duplicate-tag-tests', ['invalid-duplicate-multiple-onset']]])
const runMap = new Map([['delay-tests', ['delay-non-timeline-file']]])

describe('BIDS validation', () => {
const schemaMap = new Map([['8.3.0', undefined]])
Expand Down
56 changes: 56 additions & 0 deletions tests/testData/bidsTests.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,62 @@ export const bidsTestData = [
),
],
},
{
testname: 'delay-non-timeline-file',
explanation: 'A delay tag in not allowed in a file without a timeline',
schemaVersion: '8.3.0',
definitions: ['(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))', '(Definition/MyColor, (Label/Pie))'],
sidecar: {
event_code: {
HED: {
face: '(Delay/5.0 s, (Red))',
},
},
},
eventsString: 'event_code\tHED\nn/a\t(Delay/5.0 s, (Blue))\n',
sidecarErrors: [],
tsvErrors: [
BidsHedIssue.fromHedIssue(
generateIssue('temporalTagInNonTemporalContext', {
string: '(Delay/5.0 s, (Blue))',
}),
{
path: 'delay-non-timeline-file.tsv',
relativePath: 'delay-non-timeline-file.tsv',
},
{ tsvLine: '2' },
),
],
comboErrors: [
BidsHedIssue.fromHedIssue(
generateIssue('temporalTagInNonTemporalContext', {
string: '(Delay/5.0 s, (Blue))',
}),
{
path: 'delay-non-timeline-file.tsv',
relativePath: 'delay-non-timeline-file.tsv',
},
{ tsvLine: '2' },
),
],
},
{
testname: 'duration-non-timeline-file',
explanation: 'A duration tag is allowed a file without a timeline',
schemaVersion: '8.3.0',
definitions: ['(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))', '(Definition/MyColor, (Label/Pie))'],
sidecar: {
event_code: {
HED: {
face: '(Duration/5.0 s, (Red))',
},
},
},
eventsString: 'event_code\tHED\nn/a\t(Duration/5.0 s, (Blue))\n',
sidecarErrors: [],
tsvErrors: [],
comboErrors: [],
},
],
},
{
Expand Down

0 comments on commit ff30baa

Please sign in to comment.