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
2 changes: 1 addition & 1 deletion .github/workflows/mdformat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mdformat>=0.7.0 mdformat-myst>=0.1.5 mdformat-tables>=0.4.0
pip install mdformat>=0.7.0 mdformat-myst>=0.1.5

- name: Run mdformat (check only)
run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8056010.svg)](https://doi.org/10.5281/zenodo.8056010) [![Maintainability](https://qlty.sh/gh/hed-standard/projects/hed-python/maintainability.svg)](https://qlty.sh/gh/hed-standard/projects/hed-python) [![Code Coverage](https://qlty.sh/gh/hed-standard/projects/hed-python/coverage.svg)](https://qlty.sh/gh/hed-standard/projects/hed-python) ![Python3](https://img.shields.io/badge/python-%3E=3.10-yellow.svg) ![PyPI - Status](https://img.shields.io/pypi/v/hedtools) [![Documentation](https://img.shields.io/badge/docs-hed--python-blue.svg)](https://www.hedtags.org/hed-python)
![PyPI - Status](https://img.shields.io/pypi/v/hedtools) ![Python3](https://img.shields.io/badge/python-%3E=3.10-yellow.svg) [![Maintainability](https://qlty.sh/gh/hed-standard/projects/hed-python/maintainability.svg)](https://qlty.sh/gh/hed-standard/projects/hed-python) [![Code Coverage](https://qlty.sh/gh/hed-standard/projects/hed-python/coverage.svg)](https://qlty.sh/gh/hed-standard/projects/hed-python) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8056010.svg)](https://doi.org/10.5281/zenodo.8056010) [![Docs](https://img.shields.io/badge/docs-hed--python-blue.svg)](https://www.hedtags.org/hed-python)

# HEDTools - Python

Expand Down
99 changes: 39 additions & 60 deletions docs/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,15 @@ HEDTools provides a unified command-line interface (CLI) using a **git-style com

### Available commands

| Command | Description |
| ------------------------------ | ----------------------------------------------------------- |
| **Annotation management** | |
| `hedpy validate-bids` | Validate HED annotations in BIDS datasets |
| `hedpy extract-sidecar` | Extract JSON sidecar template from tabular (`.tsv`) files |
| **Schema management** | |
| `hedpy schema validate` | Validate HED schema files |
| `hedpy schema convert` | Convert schemas between formats (XML, MEDIAWIKI, TSV, JSON) |
| `hedpy schema add-ids` | Add unique HED IDs to schema terms |
| `hedpy schema create-ontology` | Generate OWL ontology files from HED schemas |
| Command | Description |
| ----------------------------- | ----------------------------------------------------------- |
| **Annotation management** | |
| `hedpy validate bids-dataset` | Validate HED annotations in BIDS datasets |
| `hedpy extract bids-sidecar` | Extract JSON sidecar template from tabular (`.tsv`) files |
| **Schema management** | |
| `hedpy schema validate` | Validate HED schema files |
| `hedpy schema convert` | Convert schemas between formats (XML, MEDIAWIKI, TSV, JSON) |
| `hedpy schema add-ids` | Add unique HED IDs to schema terms |

### Installation and basic usage

Expand All @@ -305,7 +304,7 @@ Get help on available commands:
hedpy --help

# Help for a specific command
hedpy validate-bids --help
hedpy validate bids-dataset --help

# Help for command groups
hedpy schema --help
Expand All @@ -321,35 +320,35 @@ ______________________________________________________________________

### BIDS validation

Validate HED annotations in BIDS datasets using `hedpy validate-bids`.
Validate HED annotations in BIDS datasets using `hedpy validate bids-dataset`.

#### Basic validation

```bash
# Validate a BIDS dataset
hedpy validate-bids /path/to/bids/dataset
hedpy validate bids-dataset /path/to/bids/dataset

# Include warnings in addition to errors
hedpy validate-bids /path/to/bids/dataset -w
hedpy validate bids-dataset /path/to/bids/dataset -w

# Enable verbose output
hedpy validate-bids /path/to/bids/dataset -v
hedpy validate bids-dataset /path/to/bids/dataset -v
```

#### Output options

```bash
# Save results to a file
hedpy validate-bids /path/to/bids/dataset -o validation_results.txt
hedpy validate bids-dataset /path/to/bids/dataset -o validation_results.txt

# Output in compact JSON format (array of issues only)
hedpy validate-bids /path/to/bids/dataset -f json -o results.json
hedpy validate bids-dataset /path/to/bids/dataset -f json -o results.json

# Pretty-printed JSON with version metadata (recommended for saving)
hedpy validate-bids /path/to/bids/dataset -f json_pp -o results.json
hedpy validate bids-dataset /path/to/bids/dataset -f json_pp -o results.json

# Print to stdout AND save to file
hedpy validate-bids /path/to/bids/dataset -o results.txt -p
hedpy validate bids-dataset /path/to/bids/dataset -o results.txt -p
```

**Output format differences:**
Expand All @@ -362,83 +361,83 @@ hedpy validate-bids /path/to/bids/dataset -o results.txt -p

```bash
# Validate specific file types (default: events, participants)
hedpy validate-bids /path/to/bids/dataset -s events -s participants -s sessions
hedpy validate bids-dataset /path/to/bids/dataset -s events -s participants -s sessions

# Exclude certain directories (default: sourcedata, derivatives, code, stimuli)
hedpy validate-bids /path/to/bids/dataset -x derivatives -x sourcedata -x mydata
hedpy validate bids-dataset /path/to/bids/dataset -x derivatives -x sourcedata -x mydata

# Limit number of errors reported per error type
hedpy validate-bids /path/to/bids/dataset -ec 5
hedpy validate bids-dataset /path/to/bids/dataset -el 5

# Apply error limit per file instead of overall
hedpy validate-bids /path/to/bids/dataset -ec 5 -ef
hedpy validate bids-dataset /path/to/bids/dataset -el 5 -ef
```

#### Logging options

```bash
# Set log level
hedpy validate-bids /path/to/bids/dataset -l DEBUG
hedpy validate bids-dataset /path/to/bids/dataset -l DEBUG

# Save logs to file
hedpy validate-bids /path/to/bids/dataset -lf validation.log
hedpy validate bids-dataset /path/to/bids/dataset -lf validation.log

# Save logs to file without stderr output
hedpy validate-bids /path/to/bids/dataset -lf validation.log -lq
hedpy validate bids-dataset /path/to/bids/dataset -lf validation.log -lq
```

#### Complete example

```bash
# Comprehensive validation with all options
hedpy validate-bids /path/to/bids/dataset \
hedpy validate bids-dataset /path/to/bids/dataset \
-w \
-v \
-f json_pp \
-o validation_results.json \
-s events \
-x derivatives \
-ec 10 \
-el 10 \
-lf validation.log
```

______________________________________________________________________

### Sidecar template extraction

Extract a JSON sidecar template from BIDS event files using `hedpy extract-sidecar`.
Extract a JSON sidecar template from BIDS event files using `hedpy extract bids-sidecar`.

#### Basic extraction

```bash
# Extract template for events files
hedpy extract-sidecar /path/to/bids/dataset -s events
hedpy extract bids-sidecar /path/to/bids/dataset -s events

# Save to specific file
hedpy extract-sidecar /path/to/bids/dataset -s events -o task_events.json
hedpy extract bids-sidecar /path/to/bids/dataset -s events -o task_events.json
```

#### Column handling

```bash
# Specify value columns (use single annotation for column with # placeholder)
hedpy extract-sidecar /path/to/bids/dataset -s events \
hedpy extract bids-sidecar /path/to/bids/dataset -s events \
-vc response_time -vc accuracy -vc subject_id

# Skip specific columns (default: onset, duration, sample)
hedpy extract-sidecar /path/to/bids/dataset -s events \
hedpy extract bids-sidecar /path/to/bids/dataset -s events \
-sc onset -sc duration -sc trial_type

# Exclude certain directories
hedpy extract-sidecar /path/to/bids/dataset -s events \
hedpy extract bids-sidecar /path/to/bids/dataset -s events \
-x derivatives -x pilot_data
```

#### Complete example

```bash
# Extract events template with custom column handling
hedpy extract-sidecar /path/to/bids/dataset \
hedpy extract bids-sidecar /path/to/bids/dataset \
-s events \
-vc response_time \
-vc reaction_time \
Expand Down Expand Up @@ -517,23 +516,6 @@ hedpy schema add-ids /path/to/hed-schemas score 2.2.0
- Modifies all schema formats (XML, MEDIAWIKI, TSV, JSON) in-place
- Should be run after all schema content changes are finalized

#### Create ontology

Generate OWL (Web Ontology Language) ontology files from HED schemas for semantic web applications and ontology-based tools.

```bash
# Create ontology for a standard schema
hedpy schema create-ontology /path/to/hed-schemas standard 8.4.0

# Create ontology for a library schema with custom output location
hedpy schema create-ontology /path/to/hed-schemas score 2.1.0 \
--dest /path/to/output

# Create ontology with all outputs in specific directory
hedpy schema create-ontology /path/to/hed-schemas lang 1.1.0 \
--dest ./ontologies
```

**Best practices:**

1. Validate schema thoroughly before adding IDs
Expand Down Expand Up @@ -575,7 +557,7 @@ Each command provides help at several levels
hedpy --help

# Command-specific help
hedpy validate-bids --help
hedpy validate bids-dataset --help
hedpy schema validate --help

# Command group help
Expand All @@ -586,16 +568,16 @@ hedpy schema --help

```bash
# Step 1: Extract sidecar template
hedpy extract-sidecar /path/to/dataset -s events -o events.json
hedpy extract bids-sidecar /path/to/dataset -s events -o events.json

# Step 2: Edit events.json to add HED tags
# (manual editing step)

# Step 3: Validate with warnings
hedpy validate-bids /path/to/dataset -w -v -o validation.txt
hedpy validate bids-dataset /path/to/dataset -w -v -o validation.txt

# Step 4: Fix issues and re-validate
hedpy validate-bids /path/to/dataset -w
hedpy validate bids-dataset /path/to/dataset -w
```

#### Workflow 3: Schema development and testing
Expand All @@ -614,11 +596,8 @@ hedpy schema validate my_schema.xml --add-all-extensions
#### Workflow 4: Preparing for schema release

```bash
# Step 1: Add HED IDs
# Add HED IDs
hedpy schema add-ids /path/to/hed-schemas my_library 1.0.0

# Step 2: Generate ontology
hedpy schema create-ontology /path/to/hed-schemas my_library 1.0.0
```

______________________________________________________________________
Expand Down
Loading