Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ hed_cache/
spec_tests/hed-specification/tests
spec_tests/hed-examples
spec_tests/*.json
spec_tests/hed-tests/json_test_data

# GitHub Copilot instructions (project-specific)
.github/copilot-instructions.md
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "spec_tests/hed-specification"]
path = spec_tests/hed-specification
url = https://github.com/hed-standard/hed-specification/
[submodule "spec_tests/hed-tests"]
path = spec_tests/hed-tests
url = https://github.com/hed-standard/hed-tests/
branch = main

[submodule "spec_tests/hed-examples"]
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
html_js_files = ["gh_icon_fix.js"]

# Add logo
html_logo = "source/_static/images/croppedWideLogo.png"
html_logo = "_static/images/croppedWideLogo.png"

# Furo theme options
html_theme_options = {
Expand Down
62 changes: 62 additions & 0 deletions docs/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ HEDTools provides a unified command-line interface (CLI) using a **git-style com
| ----------------------------- | ----------------------------------------------------------- |
| **Annotation management** | |
| `hedpy validate bids-dataset` | Validate HED annotations in BIDS datasets |
| `hedpy validate string` | Validate HED annotations in a string |
| `hedpy validate sidecar` | Validate HED annotations in a JSON sidecar |
| `hedpy validate tabular` | Validate HED annotations in a tabular file (TSV) |
| `hedpy extract bids-sidecar` | Extract JSON sidecar template from tabular (`.tsv`) files |
| **Schema management** | |
| `hedpy schema validate` | Validate HED schema files |
Expand Down Expand Up @@ -403,6 +406,62 @@ hedpy validate bids-dataset /path/to/bids/dataset \

______________________________________________________________________

### String validation

Validate a HED string using `hedpy validate string`.

```bash
# Basic validation
hedpy validate string "Event, Action" -sv 8.3.0

# With definitions
hedpy validate string "Event, Def/MyDef" \
-sv 8.4.0 \
-d "(Definition/MyDef, (Action, Move))"

# Check for warnings
hedpy validate string "Event, Action/Button-press" -sv 8.4.0 -w
```

______________________________________________________________________

### Sidecar validation

Validate a HED JSON sidecar using `hedpy validate sidecar`.

```bash
# Basic validation
hedpy validate sidecar task-rest_events.json -sv 8.3.0

# With multiple schemas
hedpy validate sidecar task-rest_events.json -sv 8.3.0 -sv score_1.1.0

# Check for warnings and save to file
hedpy validate sidecar task-rest_events.json -sv 8.4.0 -w -o results.txt
```

______________________________________________________________________

### Tabular validation

Validate a HED tabular file (TSV) using `hedpy validate tabular`.

```bash
# Basic validation
hedpy validate tabular events.tsv -sv 8.3.0

# With a sidecar
hedpy validate tabular events.tsv -s sidecar.json -sv 8.3.0

# Limit errors
hedpy validate tabular events.tsv -sv 8.3.0 -el 5

# Check for warnings and output JSON
hedpy validate tabular events.tsv -sv 8.3.0 -w -f json -o results.json
```

______________________________________________________________________

### Sidecar template extraction

Extract a JSON sidecar template from BIDS event files using `hedpy extract bids-sidecar`.
Expand Down Expand Up @@ -534,6 +593,9 @@ For backward compatibility, you can still access scripts directly using Python m
```bash
# Validation
python -m hed.scripts.validate_bids /path/to/dataset --check-warnings
python -m hed.scripts.validate_hed_string "Event, Action" -sv 8.3.0
python -m hed.scripts.validate_hed_sidecar sidecar.json -sv 8.3.0
python -m hed.scripts.validate_hed_tabular events.tsv -sv 8.3.0

# Sidecar extraction
python -m hed.scripts.hed_extract_bids_sidecar /path/to/dataset -s events
Expand Down
1 change: 0 additions & 1 deletion spec_tests/hed-specification
Submodule hed-specification deleted from a341da
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
[
{
"error_code": "SCHEMA_ATTRIBUTE_INVALID",
"name": "attribute-invalid-unknown",
"warning": true,
"description": "A schema attribute issue, saying there is an unknown one.",
"schema": "",
"error_category": "schema_development",
"common_causes": [
"Using undefined schema attributes",
"Applying attributes to wrong element types",
"Typos in attribute names",
"Using attributes from different schema versions",
"Incorrect attribute property assignments"
],
"explanation": "Schema attributes must be defined in the schema attributes section before use, and must be applied to the correct element types (tags, units, value classes, etc.). Each attribute has specific properties that determine where it can be used.",
"correction_strategy": "Define missing attributes or fix attribute usage",
"correction_examples": [
{
"wrong": "'''Tag-with-unknown''' {unknownAttribute}",
"correct": "'''Tag-with-unknown''' {extensionAllowed}",
"explanation": "Replaced undefined attribute with valid schema attribute"
},
{
"wrong": "* mod1 {unitAttribute}[Wrong attribute type]",
"correct": "* mod1 {unitModifierProperty}",
"explanation": "Used correct property type for unit modifier"
}
],
"correction_patterns": [
"Define all schema attributes in the Schema attributes section",
"Ensure attribute properties match element types",
"Use correct property types: nodeClassProperty, unitProperty, etc.",
"Check attribute names for typos",
"Verify attribute compatibility with schema version"
],
"fix_instructions": [
"1. Check if the attribute is defined in Schema attributes section",
"2. Verify the attribute property type matches the element",
"3. Correct spelling of attribute names",
"4. Add missing attribute definitions if needed",
"5. Ensure proper property assignment"
],
"validation_hints": [
"Review schema attributes section for all used attributes",
"Check property types match element usage",
"Verify attribute names are spelled correctly",
"Ensure attributes exist in current schema version"
],
"specification_reference": "A.1.4. Schema attributes",
"related_errors": [
"SCHEMA_ATTRIBUTE_VALUE_INVALID",
"SCHEMA_SECTION_MISSING"
],
"definitions": [],
"tests": {
"schema_tests": {
"fails": [
[
"HED version=\"1.0.0\"",
"'''Prologue'''",
"!# start schema",
"'''Tag-with-unknown''' {unknownAttribute}",
"!# end schema",
"'''Unit classes'''",
"'''Unit modifiers'''",
"'''Value classes'''",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
],
[
"HED version=\"1.0.0\"",
"'''Prologue'''",
"!# start schema",
"'''Tag-with-unknown''' {unitAttribute}",
"!# end schema",
"'''Unit classes'''",
"'''Unit modifiers'''",
"'''Value classes'''",
"'''Schema attributes''' <nowiki>{unitProperty}</nowiki>",
"* unitAttribute <nowiki>{unitProperty}</nowiki>",
"'''Properties''' <nowiki></nowiki>",
"* unitProperty <nowiki></nowiki>",
"'''Epilogue'''",
"!# end hed"
],
[
"HED version=\"1.0.0\"",
"'''Prologue'''",
"!# start schema",
"'''Tag'''",
"!# end schema",
"'''Unit classes'''",
"'''Unit modifiers''' <nowiki></nowiki>",
"* mod1 <nowiki>{unitAttribute}[Wrong attribute type]</nowiki>",
"'''Value classes'''",
"'''Schema attributes''' <nowiki>{unitProperty}</nowiki>",
"* unitAttribute <nowiki>{unitProperty}</nowiki>",
"'''Properties''' <nowiki></nowiki>",
"* unitProperty <nowiki></nowiki>",
"'''Epilogue'''",
"!# end hed"
]
],
"passes": [
[
"HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"",
"'''Prologue'''",
"!# start schema",
"'''Tag-with-unknown''' {suggestedTag=Event}",
"!# end schema",
"'''Unit classes'''",
"'''Unit modifiers'''",
"'''Value classes'''",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
]
]
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
[
{
"error_code": "SCHEMA_ATTRIBUTE_VALUE_INVALID",
"name": "attribute-invalid-allowed-character",
"warning": true,
"description": "A schema unit has an invalid conversion factor",
"schema": "",
"error_category": "schema_development",
"common_causes": [
"Using invalid characters in allowedCharacter attribute values",
"Incorrect character specification format",
"Including forbidden characters in allowed character sets",
"Malformed character range specifications",
"Using deprecated character specification syntax"
],
"explanation": "The allowedCharacter attribute defines valid characters for specific schema elements. Invalid character specifications can cause parsing errors and validation failures.",
"correction_strategy": "Use valid character specifications according to HED schema format",
"correction_examples": [
{
"wrong": "allowedCharacter=\"[invalid]\"",
"correct": "allowedCharacter=\"letters,digits\"",
"explanation": "Replaced invalid character specification with valid format"
}
],
"correction_patterns": [
"Use standard character class names (letters, digits, etc.)",
"Avoid invalid character specifications",
"Follow HED character specification format"
],
"fix_instructions": [
"1. Identify invalid allowedCharacter specifications",
"2. Replace with valid character class names",
"3. Verify character specification syntax",
"4. Test schema validation with corrected attributes"
],
"validation_hints": [
"Check character specification format",
"Verify against HED allowed character classes",
"Test schema loading after character corrections"
],
"specification_reference": "3.1.2.3. Schema attributes and character specifications",
"related_errors": ["SCHEMA_ATTRIBUTE_INVALID", "CHARACTER_INVALID"],
"definitions": [],
"tests": {
"schema_tests": {
"fails": [
[
"HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"",
"'''Prologue'''",
"!# start schema",
"!# end schema",
"'''Unit classes''' ",
"'''Unit modifiers'''",
"'''Value classes'''",
"* testValueClass {allowedCharacter=?d}",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
]
],
"passes": [
[
"HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"",
"'''Prologue'''",
"!# start schema",
"!# end schema",
"'''Unit classes''' ",
"'''Unit modifiers'''",
"'''Value classes'''",
"* testValueClass {allowedCharacter=?, allowedCharacter=letters}",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
],
[
"HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"",
"'''Prologue'''",
"!# start schema",
"!# end schema",
"'''Unit classes''' ",
"'''Unit modifiers'''",
"'''Value classes'''",
"* testValueClass {allowedCharacter=letters}",
"'''Schema attributes'''",
"'''Properties'''",
"'''Epilogue'''",
"!# end hed"
]
]
}
}
}
]
Loading