Skip to content

Commit 2c7f71c

Browse files
authored
Merge pull request #1154 from VisLab/json_schema
Updated the cli and the README
2 parents f7bba6c + b1f2d6d commit 2c7f71c

14 files changed

+905
-67
lines changed

CHANGELOG.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
```markdown
2-
Release 0.8.0 November 17, 2025
2+
Release 0.8.0 November 18, 2025
3+
- **Unified CLI Interface**: Added `hedpy` command-line tool with git-like subcommand structure.
4+
- Main command: `hedpy` with subcommands for all HED operations.
5+
- Subcommands organized by category: `hedpy validate-bids`, `hedpy remodel run`, `hedpy schema validate`, etc.
6+
- Prevents CLI namespace collisions with other tools (e.g., `validate_bids``hedpy validate-bids`).
7+
- Legacy commands still available for backward compatibility but deprecated.
8+
- Built with `click` framework for better CLI user experience.
9+
- Added comprehensive help text: `hedpy --help`, `hedpy COMMAND --help`.
10+
- **CLI Parameter Fidelity**: All CLI wrapper commands now correctly match original script parameters (38+ parameter fixes across 7 commands).
11+
- Fixed `validate-bids`: Added missing suffixes, output format, error control, and print options.
12+
- Fixed `remodel` commands: Corrected argument names, added missing parameters, fixed option conflicts.
13+
- Fixed `schema` commands: Corrected positional vs option argument structures for add-ids and create-ontology.
14+
- Added comprehensive test suite (`tests/test_cli_parameter_parity.py`) to verify CLI parameters match original parsers.
315
- **JSON Schema Format Support**: Added comprehensive JSON format support for HED schemas alongside existing XML, MediaWiki, and TSV formats.
416
- Implemented `SchemaLoaderJSON` class for loading JSON schemas (`hed/schema/schema_io/json2schema.py`).
517
- Implemented `Schema2JSON` class for exporting schemas to JSON (`hed/schema/schema_io/schema2json.py`).
@@ -14,10 +26,10 @@ Release 0.8.0 November 17, 2025
1426
- Comprehensive logging support with file output and verbosity control.
1527
- Integrated with BidsDataset and TabularSummary classes for robust extraction.
1628
- **Schema Validation Enhancements**: Extended schema validation to include JSON format in roundtrip testing.
17-
- Updated `script_util.py` to validate all 4 schema formats (XML, MediaWiki, TSV, JSON).
29+
- Updated `hed_script_util.py` to validate all 4 schema formats (XML, MediaWiki, TSV, JSON).
1830
- Updated schema conversion script to automatically generate JSON format alongside other formats.
1931
- **Python Version Requirements**: Minimum Python version raised to 3.10 (dropped 3.9 support).
20-
- **Documentation Improvements**: Added comprehensive Google-style docstrings to all functions in `script_util.py`.
32+
- **Documentation Improvements**: Added comprehensive Google-style docstrings to all functions in `hed_script_util.py`.
2133
- **Configuration Updates**:
2234
- Added `status` directory to Black exclude list in `pyproject.toml` for development scripts.
2335
- Updated matplotlib dependency to 3.10.7.

README.md

Lines changed: 67 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Code Coverage](https://qlty.sh/gh/hed-standard/projects/hed-python/coverage.svg)](https://qlty.sh/gh/hed-standard/projects/hed-python)
44
![Python3](https://img.shields.io/badge/python->=3.10-yellow.svg)
55
![PyPI - Status](https://img.shields.io/pypi/v/hedtools)
6-
[![Documentation](https://img.shields.io/badge/docs-hedtags.org-blue.svg)](https://www.hedtags.org/hed-python)
6+
[![Documentation](https://img.shields.io/badge/docs-hed--python-blue.svg)](https://www.hedtags.org/hed-python)
77

88
# HEDTools - Python
99

@@ -14,22 +14,25 @@
1414
HED (Hierarchical Event Descriptors) is a framework for systematically describing both laboratory and real-world events as well as other experimental metadata. HED tags are comma-separated path strings that provide a standardized vocabulary for annotating events and experimental conditions.
1515

1616
**Key Features:**
17-
- ✅ Validate HED annotations against schema specifications
18-
- 📊 Analyze and summarize HED-tagged datasets
19-
- 🔄 Transform and remodel event data
20-
- 📁 Full BIDS (Brain Imaging Data Structure) dataset support
21-
- 🌐 Platform-independent and data-neutral
22-
- 🔧 Command-line tools and Python API
17+
- Validate HED annotations against schema specifications
18+
- Analyze and summarize HED-tagged datasets
19+
- Transform and remodel event data
20+
- Full HED support in BIDS (Brain Imaging Data Structure)
21+
- HED support in NWB (Neurodata Without Borders) when used the [ndx-hed](https://github.com/hed-standard/ndx-hed) extension.
22+
- Platform-independent and data-neutral
23+
- Command-line tools and Python API
2324

24-
## Quick Start
25+
## Quick start
2526

26-
### Online Tools (No Installation Required)
27+
### Online tools (no installation required)
2728

28-
For simple validation or transformation tasks, use the online tools at [https://hedtools.org](https://hedtools.org) - no installation needed!
29+
For simple validation or transformation tasks, use the online tools at [https://hedtools.org/hed](https://hedtools.org/hed) - no installation needed!
30+
31+
Browser-based validation (no data upload) is available at [https://www.hedtags.org/hed-javascript](https://www.hedtags.org/hed-javascript)
2932

3033
A development version is available at: [https://hedtools.org/hed_dev](https://hedtools.org/hed_dev)
3134

32-
### Python Installation
35+
### Python installation
3336

3437
**Requirements:** Python 3.10 or higher
3538

@@ -43,39 +46,53 @@ Or install from GitHub (latest):
4346
pip install git+https://github.com/hed-standard/hed-python/@main
4447
```
4548

46-
### Basic Usage
49+
### Basic usage
4750

4851
```python
49-
from hed import HedString, load_schema
52+
from hed import HedString, load_schema_version
5053

5154
# Load the latest HED schema
52-
schema = load_schema()
55+
schema = load_schema_version("8.4.0")
5356

5457
# Create and validate a HED string
5558
hed_string = HedString("Sensory-event, Visual-presentation, (Onset, (Red, Square))")
5659
issues = hed_string.validate(schema)
5760

5861
if issues:
59-
print("Validation issues found:")
60-
for issue in issues:
61-
print(f" - {issue}")
62+
print(get_printable_issue_string(issues, title="Validation issues found"))
6263
else:
63-
print("HED string is valid!")
64+
print("HED string is valid!")
6465
```
6566

66-
### Command-Line Tools
67+
### Command-line tools
6768

68-
HEDTools includes several command-line utilities:
69+
HEDTools provides a unified command-line interface with git-like subcommands:
6970

7071
```bash
72+
# Main command (new unified interface)
73+
hedpy --help
74+
7175
# Validate a BIDS dataset
72-
validate_bids /path/to/bids/dataset
76+
hedpy validate-bids /path/to/bids/dataset
7377

74-
# Run remodeling operations on event files
75-
run_remodel /path/to/remodel_config.json /path/to/data
78+
# Extract sidecar template from BIDS dataset
79+
hedpy extract-sidecar /path/to/dataset --suffix events
7680

7781
# Validate HED schemas
82+
hedpy schema validate /path/to/schema.xml
83+
84+
# Convert schema between formats (XML, MediaWiki, TSV, JSON)
85+
hedpy schema convert /path/to/schema.xml
86+
87+
# Run remodeling operations on event files
88+
hedpy remodel run /path/to/data /path/to/remodel_config.json
89+
```
90+
91+
**Legacy commands** (deprecated, use `hedpy` instead):
92+
```bash
93+
validate_bids /path/to/dataset
7894
hed_validate_schemas /path/to/schema.xml
95+
run_remodel /path/to/data /path/to/config.json
7996
```
8097

8198
For more examples, see the [user guide](https://www.hedtags.org/hed-python/user_guide.html).
@@ -84,24 +101,28 @@ For more examples, see the [user guide](https://www.hedtags.org/hed-python/user_
84101

85102
📖 **Full Documentation:** [https://www.hedtags.org/hed-python](https://www.hedtags.org/hed-python)
86103

87-
- [User Guide](https://www.hedtags.org/hed-python/user_guide.html) - Comprehensive usage instructions
104+
- [User Guide](https://www.hedtags.org/hed-python/user_guide.html) - Usage instructions
88105
- [API Reference](https://www.hedtags.org/hed-python/api/index.html) - Detailed API documentation
89-
- [HED Specification](https://hed-specification.readthedocs.io/) - Full HED standard specification
106+
- [HED Specification](https://www.hedtags.org/hed-specification) - Full HED standard specification
90107

91-
### Building Documentation Locally
108+
### Building docs locally
92109

93110
```bash
94111
# Install documentation dependencies
95-
pip install -r docs/requirements.txt
112+
pip install -e .[docs]
96113

97114
# Build the documentation
98-
mkdocs build
115+
cd docs
116+
sphinx-build -b html . _build/html
99117

100-
# Serve locally with live reload at http://localhost:8000
101-
mkdocs serve
118+
# Or use the make command (if available)
119+
make html
120+
121+
# View the built documentation
122+
# Open docs/_build/html/index.html in your browser
102123
```
103124

104-
### Code Formatting with Black
125+
### Formatting with Black
105126

106127
This project uses [Black](https://black.readthedocs.io/) for consistent code formatting.
107128

@@ -140,27 +161,23 @@ The HED ecosystem consists of several interconnected repositories:
140161
|------------|-------------|
141162
| [hed-python](https://github.com/hed-standard/hed-python) | Python validation and analysis tools (this repo) |
142163
| [hed-web](https://github.com/hed-standard/hed-web) | Web interface and deployable Docker services |
143-
| [hed-examples](https://github.com/hed-standard/hed-examples) | Example code in Python and MATLAB + HED resources |
164+
| [hed-resources](https://github.com/hed-standard/hed-resources) | Example code in Python and MATLAB + HED resources |
144165
| [hed-specification](https://github.com/hed-standard/hed-specification) | Official HED specification documents |
145-
| [hed-schemas](https://github.com/hed-standard/hed-schemas) | Official HED schema repository |
146-
147-
### Branch Strategy
166+
| [hed-schemas](https://github.com/hed-standard/hed-schemas) | Official HED schema repository |
167+
| [ndx-hed](https://github.com/hed-standard/ndx-hed) | HED support for NWB |
168+
| [hed-javascript](https://github.com/hed-standard/hed-javascript) | JavaScript HEd validation tools |
148169

149-
| Branch | Purpose | Synchronized With |
150-
|--------|---------|-------------------|
151-
| `stable` | Officially released on PyPI as tagged versions | `stable@hed-web`, `stable@hed-specification`, `stable@hed-examples` |
152-
| `main` | Latest stable development version | `latest@hed-web`, `latest@hed-specification`, `latest@hed-examples` |
153170

154171
## Contributing
155172

156173
We welcome contributions! Here's how you can help:
157174

158-
1. **Report Issues:** Use [GitHub Issues](https://github.com/hed-standard/hed-python/issues) for bug reports and feature requests
159-
2. **Submit Pull Requests:** PRs should target the `main` branch
160-
3. **Improve Documentation:** Help us make HED easier to use
161-
4. **Share Examples:** Contribute example code and use cases
175+
1. **Report issues:** Use [GitHub Issues](https://github.com/hed-standard/hed-python/issues) for bug reports and feature requests
176+
2. **Submit pull requests (PRs):** PRs should target the `main` branch
177+
3. **Improve documentation:** Help us make HED easier to use
178+
4. **Share examples:** Contribute example code and use cases
162179

163-
**Development Setup:**
180+
**Development setup:**
164181
```bash
165182
# Clone the repository
166183
git clone https://github.com/hed-standard/hed-python.git
@@ -181,7 +198,7 @@ For detailed contribution guidelines, please see [CONTRIBUTING.md](CONTRIBUTING.
181198

182199
## Configuration
183200

184-
### Schema Caching
201+
### Schema caching
185202

186203
By default, HED schemas are cached in `~/.hedtools/` (location varies by OS).
187204

@@ -199,7 +216,7 @@ If you use HEDTools in your research, please cite:
199216

200217
```bibtex
201218
@software{hedtools,
202-
author = {Robbins, Kay and others},
219+
author = {Ian Callanan, Robbins, Kay and others},
203220
title = {HEDTools: Python tools for HED},
204221
year = {2024},
205222
publisher = {GitHub},
@@ -214,7 +231,7 @@ HEDTools is licensed under the MIT License. See [LICENSE](LICENSE) for details.
214231

215232
## Support
216233

217-
- 📖 [Documentation](https://www.hedtags.org/hed-python)
218-
- 💬 [GitHub Issues](https://github.com/hed-standard/hed-python/issues)
219-
- 🌐 [HED Homepage](https://www.hedtags.org)
220-
- 📧 Contact: [email protected]
234+
- [Documentation](https://www.hedtags.org/hed-python)
235+
- [GitHub Issues](https://github.com/hed-standard/hed-python/issues)
236+
- [HED Homepage](https://www.hedtags.org)
237+

hed/cli/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""HED command-line interface package."""

0 commit comments

Comments
 (0)