Skip to content

Commit c987cc3

Browse files
committed
Corrected handling of delay with temporal tag
1 parent 45d3bcc commit c987cc3

File tree

14 files changed

+226
-260
lines changed

14 files changed

+226
-260
lines changed

bids/validator/sidecarValidator.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,11 @@ export class BidsHedSidecarValidator extends BidsValidator {
4848
for (const [sidecarKeyName, hedData] of this.bidsFile.parsedHedData) {
4949
if (hedData instanceof ParsedHedString) {
5050
// Value options have HED as string.
51-
issues.push(...this._checkDetails(sidecarKeyName, hedData, true))
51+
issues.push(...this._checkDetails(sidecarKeyName, hedData))
5252
} else if (hedData instanceof Map) {
5353
// Categorical options have HED as a Map.
5454
for (const valueString of hedData.values()) {
55-
const placeholdersAllowed = this.bidsFile.sidecarKeys.get(sidecarKeyName).hasDefinitions
56-
issues.push(...this._checkDetails(sidecarKeyName, valueString, placeholdersAllowed))
55+
issues.push(...this._checkDetails(sidecarKeyName, valueString))
5756
}
5857
} else {
5958
IssueError.generateAndThrow('internalConsistencyError', {

common/issues/data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ export default {
277277
tooManyGroupTopTags: {
278278
hedCode: 'TAG_GROUP_ERROR',
279279
level: 'error',
280-
message: stringTemplate`Group "${'string'}" has too many or too few tags at the top level.`,
280+
message: stringTemplate`Group "${'string'}" has too many or too few tags or Def-expand groups at the top level.`,
281281
},
282282
multipleTopLevelTagGroupTags: {
283283
hedCode: 'TAG_GROUP_ERROR',

data/json/reservedTags.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
"forbiddenSubgroupTags": [],
142142
"isTemporalTag": true,
143143
"requiresDef": true,
144-
"otherAllowedNonDefTags": ["Def", "Delay"]
144+
"otherAllowedNonDefTags": ["Delay"]
145145
},
146146
"Onset": {
147147
"name": "Onset",

parser/definitionManager.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { generateIssue, IssueError } from '../common/issues/issues'
22
import { parseHedString } from './parser'
3-
//import { filterNonEqualDuplicates } from './parseUtils'
43
import { filterByTagName } from './parseUtils'
54

65
export class Definition {
@@ -219,7 +218,7 @@ export class DefinitionManager {
219218
}
220219

221220
/**
222-
* Evaluate the definition based on a parsed HED tag
221+
* Evaluate the definition based on a parsed HED tag.
223222
* @param {ParsedHedTag} tag - The tag to evaluate against the definitions.
224223
* @param {Schemas} hedSchemas - The schemas to be used to assist in the evaluation.
225224
* @param {boolean} placeholderAllowed - If true then placeholder is allowed in the def tag.

parser/parseUtils.js

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,6 @@ export function filterTagMapByNames(tagMap, tagNames) {
4444
return keys.flatMap((key) => tagMap.get(key))
4545
}
4646

47-
/*/!**
48-
* Extract the ParsedHedTag tags that have a name from a specified list of names
49-
* @param {ParsedHedTag[]} tags - to be filtered by name
50-
* @param {[string]} tagList - List of tag names to filter by.
51-
* @returns {ParsedHedTag[]} - A list of tags whose
52-
*!/
53-
54-
export function filterByTagNames(tags, tagList) {
55-
if (!tags || !tagList) {
56-
return []
57-
}
58-
return tags.filter((tag) => tagList.includes(tag.schemaTag.name))
59-
}*/
60-
6147
/**
6248
* Convert a list of ParsedHedTag objects into a comma-separated string of their string representations.
6349
* @param {ParsedHedTag []} tagList - The HED tags whose string representations should be put in a comma-separated list.
@@ -68,10 +54,10 @@ export function getTagListString(tagList) {
6854
}
6955

7056
/**
71-
* Create a map of the ParsedHedTags by type
72-
* @param { ParsedHedTag[] } tagList
73-
* @param {Set} tagNames
74-
* @returns {Map<string, ParsedHedTag[]>}
57+
* Create a map of the ParsedHedTags by type.
58+
* @param { ParsedHedTag[] } tagList - The HED tags to be categorized.
59+
* @param {Set} tagNames - The tag names to use as categories.
60+
* @returns {Map<string, ParsedHedTag[]>} - A map of tag name to a list of tags with that name.
7561
*/
7662
export function categorizeTagsByName(tagList, tagNames = null) {
7763
// Initialize the map with keys from tagNames and an "other" key
@@ -89,9 +75,9 @@ export function categorizeTagsByName(tagList, tagNames = null) {
8975
}
9076

9177
/**
92-
* Return a list of duplicate strings
93-
* @param { string[] } itemList - A list of strings to look for duplicates in
94-
* @returns {string []} - a list of unique duplicate strings (multiple copies not repeated
78+
* Return a list of duplicate strings.
79+
* @param { string[] } itemList - A list of strings to look for duplicates in.
80+
* @returns {string []} - a list of unique duplicate strings (multiple copies not repeated.
9581
*/
9682
export function getDuplicates(itemList) {
9783
const checkSet = new Set()

parser/parsedHedGroup.js

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,41 @@ import {
1919
*/
2020
export default class ParsedHedGroup extends ParsedHedSubstring {
2121
/**
22-
* The parsed HED tags or parsedHedGroups or parsedColumnSplices in the HED tag group at the top level
22+
* The parsed HED tags, groups, or splices in the HED tag group at the top level.
2323
* @type {ParsedHedSubstring[]}
2424
*/
2525
tags
2626

27+
/**
28+
* The top-level parsed HED tags in this string.
29+
* @type {ParsedHedTag[]}
30+
*/
2731
topTags
2832

33+
/**
34+
* The top-level parsed HED groups in this string.
35+
* @type {ParsedHedGroup[]}
36+
*/
2937
topGroups
3038

39+
/**
40+
* The top-level column splices in this string
41+
* @type {ParsedHedColumnSplice[]}
42+
*/
3143
topSplices
3244

45+
/**
46+
* All the parsed HED tags in this string.
47+
* @type {ParsedHedTag[]}
48+
*/
3349
allTags
50+
3451
/**
35-
* Any HED tags with special handling. This only covers top-level tags in the group
52+
* Any HED tags with special handling. This only covers top-level tags in the group.
3653
* @type {Map<string, ParsedHedTag[]>}
3754
*/
3855
specialTags
56+
3957
/**
4058
* Whether this HED tag group has child groups with a Def-expand tag.
4159
* @type {boolean}
@@ -48,12 +66,28 @@ export default class ParsedHedGroup extends ParsedHedSubstring {
4866
*/
4967
defExpandChildren
5068

69+
/**
70+
* True if this group has a Def-expand tag at the top level.
71+
* @type {boolean}
72+
*/
5173
isDefExpandGroup
5274

75+
/**
76+
* True if this group has a Definition tag at the top level.
77+
* @type {boolean}
78+
*/
5379
isDefinitionGroup
5480

81+
/**
82+
* The total number of top-level Def tags and top-level Def-expand groups.
83+
* @type {Number}
84+
*/
5585
defCount
5686

87+
/**
88+
* The unique top-level tag requiring a Def or Def-expand group, if any.
89+
* @type {ParsedHedTag | null}
90+
*/
5791
requiresDefTag
5892

5993
/**
@@ -74,11 +108,20 @@ export default class ParsedHedGroup extends ParsedHedSubstring {
74108
this._initializeGroups()
75109
}
76110

111+
/**
112+
* Recursively create a list of all the tags in this group.
113+
* @returns {ParsedHedTag[]}
114+
* @private
115+
*/
77116
_getAllTags() {
78117
const subgroupTags = this.topGroups.flatMap((tagGroup) => tagGroup.allTags)
79118
return this.topTags.concat(subgroupTags)
80119
}
81120

121+
/**
122+
* Sets information about the special tags, particularly definition-related tags in this group.
123+
* @private
124+
*/
82125
_initializeGroups() {
83126
const special = ReservedChecker.getInstance()
84127
this.specialTags = categorizeTagsByName(this.topTags, special.specialNames)
@@ -91,10 +134,11 @@ export default class ParsedHedGroup extends ParsedHedSubstring {
91134
}
92135

93136
/**
94-
* Filter top subgroups that include a special at the top-level of the group
137+
* Filter top subgroups that include a special at the top-level of the group.
95138
*
96139
* @param {string} tagName - The schemaTag name to filter by.
97140
* @returns {Array} - Array of subgroups containing the specified tag.
141+
* @private
98142
*/
99143
_filterSubgroupsByTagName(tagName) {
100144
return Array.from(this.topLevelGroupIterator()).filter((subgroup) => subgroup.specialTags.has(tagName))
@@ -147,18 +191,6 @@ export default class ParsedHedGroup extends ParsedHedSubstring {
147191
return this.specialTags.get(tagName) ?? []
148192
}
149193

150-
isSpecialGroup(tagName) {
151-
return this.specialTags.has(tagName)
152-
}
153-
154-
/**
155-
* Whether this HED tag group is an onset, offset, or inset group.
156-
* @returns {boolean}
157-
*/
158-
get isTemporalGroup() {
159-
return this.isSpecialGroup('Onset') || this.isSpecialGroup('Offset') || this.isSpecialGroup('Inset')
160-
}
161-
162194
get defTags() {
163195
const tags = this.getSpecial('Def')
164196
for (const group of this.defExpandChildren) {
@@ -178,22 +210,6 @@ export default class ParsedHedGroup extends ParsedHedSubstring {
178210
)
179211
}
180212

181-
/**
182-
* The deeply nested array of parsed tags.
183-
* @returns {ParsedHedTag[]}
184-
*/
185-
nestedGroups() {
186-
const groups = []
187-
for (const innerTag of this.tags) {
188-
if (innerTag instanceof ParsedHedTag) {
189-
groups.push(innerTag)
190-
} else if (innerTag instanceof ParsedHedGroup) {
191-
groups.push(innerTag.nestedGroups())
192-
}
193-
}
194-
return groups
195-
}
196-
197213
/**
198214
* Return a normalized string representation
199215
* @returns {string}
@@ -220,20 +236,6 @@ export default class ParsedHedGroup extends ParsedHedSubstring {
220236
return `(${sortedNormalizedItems.join(',')})` // Using curly braces to indicate unordered group
221237
}
222238

223-
/**
224-
* Iterator over the full HED groups and subgroups in this HED tag group.
225-
*
226-
* @yields {ParsedHedTag[]} The subgroups of this tag group.
227-
*/
228-
*subGroupArrayIterator() {
229-
for (const innerTag of this.tags) {
230-
if (innerTag instanceof ParsedHedGroup) {
231-
yield* innerTag.subGroupArrayIterator()
232-
}
233-
}
234-
yield this.tags
235-
}
236-
237239
/**
238240
* Iterator over the ParsedHedGroup objects in this HED tag group.
239241
* @param {string | null} tagName - The name of the tag whose groups are to be iterated over or null if all tags.

parser/parsedHedString.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class ParsedHedString {
3939
*/
4040
columnSplices
4141
/**
42-
* The top-level tag groups in the string, split into arrays.
42+
* The tags in the top-level tag groups in the string, split into arrays.
4343
* @type {ParsedHedTag[][]}
4444
*/
4545
topLevelGroupTags

0 commit comments

Comments
 (0)