hed-standard / hed-specification

Specification documents for HED (Hierarchical Event Descriptors)
https://hed-specification.readthedocs.io/en/latest/index.html
Creative Commons Attribution 4.0 International
8 stars 11 forks source link

Allow `Def/` with `Duration` and `Delay` #609

Closed neuromechanist closed 3 months ago

neuromechanist commented 3 months ago

Currently, the Duration and Delay can't be grouped with Def/ tags. This is the error I get from the validator:

TEMPORAL_TAG_ERROR: Tag 'Def/left-target' should not be grouped with Duration or Delay.  Context tags should be in a sub-group.  Problem spans string indexes: 1, 16

This means that the full description should be included, which might be very long and hard to follow, especially for untrained eyes. Here is an example from HBN's Contrast Change Detection:

"right_target": "((Visual-presentation, (Background-view, Gray), (Foreground-view, ((Circle, (Center-of, Computer-screen), (Radius, Angle/6 degree), (Pattern, Rightward, Label/Grating), (Increasing, Luminance-Contrast)), (Circle, (Center-of, Computer-screen), (Radius, Angle/6 degree), (Pattern, Leftward, Label/Grating), (Decreasing, Luminance-Contrast))))), Duration/1600 ms), (Delay/1600 ms, Duration/800 ms, (Visual-presentation, (Background-view, Gray), (Foreground-view, ((Circle, (Center-of, Computer-screen), (Radius, Angle/6 degree), (Pattern, Rightward, Label/Grating), (Decreasing, Luminance-Contrast)), (Circle, (Center-of, Computer-screen), (Radius, Angle/6 degree), (Pattern, Leftward, Label/Grating), (Increasing, Luminance-Contrast)))))), (Delay/2400 ms, {feedback}, Duration/400 ms)",

However, if using Def/ is allowed, the long descriptions can be moved to the Definition section, and the event description becomes much more readable. Now the reader can easily follow that there is temporal context that is being followed one after another without getting stuck in the huge amount of (necessary) HED tags:

"left_target": "(Def/left-target, Duration/1600 ms), (Delay/1600 ms, Def/left-comeback, Duration/800 ms), (Delay/2400 ms, {feedback}, Duration/400 ms)"

Then the HED Definitions can be at the end of the sidecar:

  "hed_defs":{
    "Description": "Metadata dictionary for defining the stimulus",
    "HED":{
      "contrastChange": "(Definition/contrastChange,((Visual-presentation, (Background-view, Gray), (Foreground-view, (Dots, Item-count/1, White, (Center-of, Computer-screen)))), Recording))",
      "left-target": "(Definition/left-target, (Visual-presentation, (Background-view, Gray), (Foreground-view, ((Circle, (Center-of, Computer-screen), (Radius, Angle/6 degree), (Pattern, Leftward, Label/Grating), (Increasing, Luminance-Contrast)), (Circle, (Center-of, Computer-screen), (Radius, Angle/6 degree), (Pattern, Rightward, Label/Grating), (Decreasing, Luminance-Contrast))))))",
      "left-comeback": "(Definition/left-comeback, (Visual-presentation, (Background-view, Gray), (Foreground-view, ((Circle, (Center-of, Computer-screen), (Radius, Angle/6 degree), (Pattern, Leftward, Label/Grating), (Decreasing, Luminance-Contrast)), (Circle, (Center-of, Computer-screen), (Radius, Angle/6 degree), (Pattern, Rightward, Label/Grating), (Increasing, Luminance-Contrast))))))"
    }
VisLab commented 3 months ago

The problem is the syntax: (Def/left-target, Duration/1600 ms) isn't correct. The stuff inside the Duration group needs parentheses:

((Def/left-target), Duration/1600 ms)

See: Using Duration.

neuromechanist commented 3 months ago

Interesting, I did not realize the single tags would need parentheses. I guess that Def/ actually expands later on, so the tag indeed needs to be in parentheses. Thanks 🙏