|
1 | | -# Introduction to HED |
| 1 | +# Introduction to hedtools |
2 | 2 |
|
3 | | -## Why HED? |
| 3 | +## What is HED? |
4 | 4 |
|
5 | | -!!! info "Why use HED?" |
6 | | - HED (Hierarchical Event Descriptors) is an infrastructure and a controlled vocabulary that allows researchers to annotate their experimental data, especially events, so that tools can automatically use this information in analysis. |
| 5 | +HED (Hierarchical Event Descriptors) is a framework for systematically describing events and experimental metadata in machine-actionable form. HED provides: |
7 | 6 |
|
8 | | -For more information on using Hierarchical Event Descriptors (HED) visit [HED project homepage](https://www.hedtags.org). |
| 7 | +- **Controlled vocabulary** for annotating experimental data and events |
| 8 | +- **Standardized infrastructure** enabling automated analysis and interpretation |
| 9 | +- **Integration** with major neuroimaging standards (BIDS and NWB) |
9 | 10 |
|
10 | | -## Installing hedtools |
| 11 | +For more information, visit the [HED project homepage](https://www.hedtags.org). |
11 | 12 |
|
12 | | -You can install hedtools from PyPI: |
| 13 | +## What is hedtools? |
| 14 | + |
| 15 | +The **hedtools** Python package (`hed-python` repository) provides: |
| 16 | + |
| 17 | +- **Core validation** of HED annotations against schema specifications |
| 18 | +- **BIDS integration** for neuroimaging dataset processing |
| 19 | +- **Analysis tools** for event summarization, temporal processing, and tag analysis |
| 20 | +- **Transformation utilities** for converting between formats (JSON ↔ spreadsheet) |
| 21 | +- **Command-line interface** for scripting and automation |
| 22 | +- **Jupyter notebooks** for interactive analysis workflows |
| 23 | + |
| 24 | +### Related tools and resources |
| 25 | + |
| 26 | +- **[HED homepage](https://www.hedtags.org)**: Overview and links for HED |
| 27 | +- **[HED Schemas](https://github.com/hed-standard/hed-schemas)**: Standardized vocabularies in XML/MediaWiki/OWL formats |
| 28 | +- **[HED Specification](https://www.hedtags.org/hed-specification/)**: Formal specification defining HED annotation rules |
| 29 | +- **[HED Online Tools](https://hedtools.org/hed)**: Web-based interface requiring no programming |
| 30 | +- **[HED Examples](https://github.com/hed-standard/hed-examples)**: Example datasets annotated with HED |
| 31 | +- **[HED Resources](https://www.hedtags.org/hed-resources)**: Comprehensive tutorials and documentation |
| 32 | +- **[HED MATLAB Tools](https://www.hedtags.org/hed-resources/HedMatlabTools.html)**: MATLAB wrapper for Python tools |
| 33 | + |
| 34 | +## Installation |
| 35 | + |
| 36 | +### From PyPI (Recommended) |
| 37 | + |
| 38 | +Install the latest stable release: |
13 | 39 |
|
14 | 40 | ```bash |
15 | 41 | pip install hedtools |
16 | 42 | ``` |
17 | 43 |
|
18 | | -Or install directly from the [GitHub repository](https://github.com/hed-standard/hed-python): |
| 44 | +**Note**: The PyPI package includes the core hedtools library but **not the example Jupyter notebooks**. To access the notebooks, see the options below. |
| 45 | + |
| 46 | +### For Jupyter Notebook Examples |
| 47 | + |
| 48 | +The example notebooks are only available in the GitHub repository. Choose one of these options: |
| 49 | + |
| 50 | +**Option 1: Clone the full repository** |
| 51 | + |
| 52 | +```bash |
| 53 | +git clone https://github.com/hed-standard/hed-python.git |
| 54 | +cd hed-python |
| 55 | +pip install -r requirements.txt |
| 56 | +pip install jupyter notebook |
| 57 | +# Notebooks are in: examples/ |
| 58 | +``` |
| 59 | + |
| 60 | +**Option 2: Download just the examples directory** |
| 61 | + |
| 62 | +```bash |
| 63 | +svn export https://github.com/hed-standard/hed-python/trunk/examples |
| 64 | +cd examples |
| 65 | +pip install hedtools jupyter notebook |
| 66 | +``` |
| 67 | + |
| 68 | +See [examples/README.md](../examples/README.md) for detailed notebook documentation. |
| 69 | + |
| 70 | +### From GitHub (Latest Development Version) |
| 71 | + |
| 72 | +```bash |
| 73 | +pip install git+https://github.com/hed-standard/hed-python/@main |
| 74 | +``` |
| 75 | + |
| 76 | +### For development |
| 77 | + |
| 78 | +Clone the repository and install in editable mode: |
19 | 79 |
|
20 | 80 | ```bash |
21 | | -pip install git+https://github.com/hed-standard/hed-python.git |
| 81 | +git clone https://github.com/hed-standard/hed-python.git |
| 82 | +cd hed-python |
| 83 | +pip install -e . |
| 84 | +``` |
| 85 | + |
| 86 | +### Python requirements |
| 87 | + |
| 88 | +- **Python 3.10 or later** is required |
| 89 | +- Core dependencies: pandas, numpy, defusedxml, openpyxl |
| 90 | +- Jupyter support: Install with `pip install jupyter notebook` |
| 91 | + |
| 92 | +## Getting help |
| 93 | + |
| 94 | +### Documentation resources |
| 95 | + |
| 96 | +- **[User Guide](user_guide.md)**: Step-by-step instructions and examples |
| 97 | +- **[API reference](api/index.html)**: Detailed function and class documentation |
| 98 | +- **[HED specification](https://hed-specification.readthedocs.io/)**: Formal annotation rules |
| 99 | +- **[HED resources](https://www.hedtags.org/hed-resources)**: HED tutorials and guides |
| 100 | + |
| 101 | +### Support |
| 102 | + |
| 103 | +- **Issues and bugs**: [Open an issue](https://github.com/hed-standard/hed-python/issues) on GitHub |
| 104 | +- **Questions**: Use GitHub issues |
| 105 | +- **Online validation**: Try [HED online tools](https://hedtools.org/hed) for web-based access |
| 106 | + |
| 107 | +## Quick start |
| 108 | + |
| 109 | +### Basic validation example |
| 110 | + |
| 111 | +```python |
| 112 | +from hed import HedString, load_schema, get_printable_issue_string |
| 113 | + |
| 114 | +# Load the latest HED schema |
| 115 | +schema = load_schema() |
| 116 | + |
| 117 | +# Create and validate a HED string |
| 118 | +hed_string = HedString("Sensory-event, Visual-presentation, (Onset, (Red, Square))", schema) |
| 119 | +issues = hed_string.validate(schema) |
| 120 | + |
| 121 | +if issues: |
| 122 | + print(get_printable_issue_string(issues, "Validation issues found:")) |
| 123 | +else: |
| 124 | + print("✓ HED string is valid!") |
22 | 125 | ``` |
23 | 126 |
|
24 | | -## Finding help |
| 127 | +### BIDS dataset validation |
| 128 | + |
| 129 | +```python |
| 130 | +from hed.tools import BidsDataset |
25 | 131 |
|
26 | | -### Documentation |
| 132 | +# Load and validate a BIDS dataset |
| 133 | +dataset = BidsDataset("path/to/bids/dataset") # the description has schema version |
| 134 | +issues = dataset.validate() |
27 | 135 |
|
28 | | -- See [HED resources](https://www.hed-resources.org) for user documentation and tutorials |
29 | | -- The [HED online tools](https://hedtools.org) provide an easy-to-use interface that requires no programming |
| 136 | +if issues: |
| 137 | + print(f"Found {len(issues)} validation issues") |
| 138 | +else: |
| 139 | + print("✓ Dataset HED annotations are valid!") |
| 140 | +``` |
| 141 | + |
| 142 | +### Working with sidecars |
| 143 | + |
| 144 | +```python |
| 145 | +from hed import Sidecar, load_schema_version |
| 146 | + |
| 147 | +# Load and validate a BIDS JSON sidecar |
| 148 | +schema = load_schema_version("8.4.0") |
| 149 | +sidecar = Sidecar("task-rest_events.json") |
| 150 | +issues = sidecar.validate(schema) |
| 151 | +``` |
30 | 152 |
|
31 | | -### Issues and problems |
| 153 | +## Next steps |
32 | 154 |
|
33 | | -If you notice a bug in the python hedtools code or encounter other problems using the tools, please [open an issue](https://github.com/hed-standard/hed-python/issues) in the hed-python repository on GitHub. |
| 155 | +- **Explore the [User Guide](user_guide.md)** for detailed workflows |
| 156 | +- **Try the [Jupyter notebooks](../examples/README.md)** for interactive examples |
| 157 | +- **Check the [API Reference](api/index.html)** for complete function documentation |
| 158 | +- **Validate your data** using the [HED online tools](https://hedtools.org/hed) or the [HED browser-based tools](https://www.hedtags.org/hed-javascript) |
0 commit comments