Skip to content

Commit d43cfd5

Browse files
committed
Moved hedtools Jupyter examples from hed-examples
1 parent 8a693ef commit d43cfd5

17 files changed

Lines changed: 1976 additions & 2 deletions
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Notebook Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'examples/**'
8+
- 'tests/test_notebooks.py'
9+
- 'pyproject.toml'
10+
- 'requirements*.txt'
11+
pull_request:
12+
branches: [main]
13+
paths:
14+
- 'examples/**'
15+
- 'tests/test_notebooks.py'
16+
- 'pyproject.toml'
17+
- 'requirements*.txt'
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
test-notebooks:
24+
name: Test Jupyter Notebooks
25+
runs-on: ubuntu-latest
26+
strategy:
27+
matrix:
28+
python-version: ["3.10", "3.13"]
29+
30+
steps:
31+
- uses: actions/checkout@v6
32+
with:
33+
submodules: true
34+
35+
- name: Set up Python ${{ matrix.python-version }}
36+
uses: actions/setup-python@v6
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
40+
- name: Install dependencies
41+
run: |
42+
python -m pip install --upgrade pip
43+
pip install -r requirements.txt
44+
# Install hedtools from repo + Jupyter dependencies
45+
# Note: examples/ directory is from the checkout, not PyPI
46+
pip install jupyter notebook nbformat nbconvert ipykernel
47+
48+
- name: Test notebook structure and imports
49+
run: |
50+
python -m unittest tests.test_notebooks.TestNotebooks -v
51+
52+
- name: Test notebook execution setup
53+
run: |
54+
python -m unittest tests.test_notebooks.TestNotebookExecution -v
55+
56+
- name: List example notebooks
57+
run: |
58+
echo "Example notebooks found:"
59+
ls -la examples/*.ipynb

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ lib/
5959
lib64/
6060
parts/
6161
sdist/
62+
.status/
6263
status/
6364
var/
6465
*.egg-info/

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
include versioneer.py
22
include hed/_version.py
3-
include requirements.txt
3+
include requirements.txt
4+
recursive-include examples *.ipynb *.md

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,36 @@ run_remodel /path/to/data /path/to/config.json
9797

9898
For more examples, see the [user guide](https://www.hedtags.org/hed-python/user_guide.html).
9999

100+
### Jupyter notebook examples
101+
102+
**Note:** Example notebooks are available in the [GitHub repository](https://github.com/hed-standard/hed-python/tree/main/examples) only, not in the PyPI package.
103+
104+
The [`examples/`](examples/) directory contains Jupyter notebooks demonstrating common HED workflows with BIDS datasets:
105+
106+
- **validate_bids_dataset.ipynb** - Validate HED annotations in a BIDS dataset
107+
- **summarize_events.ipynb** - Summarize event file contents and value counts
108+
- **sidecar_to_spreadsheet.ipynb** - Convert JSON sidecars to spreadsheet format
109+
- **merge_spreadsheet_into_sidecar.ipynb** - Merge spreadsheet annotations into JSON sidecars
110+
- **extract_json_template.ipynb** - Generate JSON sidecar templates from event files
111+
- **find_event_combinations.ipynb** - Find unique combinations of event values
112+
- **validate_bids_dataset_with_libraries.ipynb** - Validate with HED library schemas
113+
114+
To use these notebooks:
115+
116+
```bash
117+
# Clone the repository to get the examples
118+
git clone https://github.com/hed-standard/hed-python.git
119+
cd hed-python
120+
121+
# Install HEDTools with Jupyter support
122+
pip install -e .[examples]
123+
124+
# Launch Jupyter
125+
jupyter notebook examples/
126+
```
127+
128+
See [`examples/README.md`](examples/README.md) for more details.
129+
100130
## Documentation
101131

102132
📖 **Full Documentation:** [https://www.hedtags.org/hed-python](https://www.hedtags.org/hed-python)
@@ -183,7 +213,11 @@ We welcome contributions! Here's how you can help:
183213
git clone https://github.com/hed-standard/hed-python.git
184214
cd hed-python
185215

186-
# Install in development mode with dependencies
216+
# Install in development mode with all dependencies (including Jupyter)
217+
pip install -e .[examples]
218+
pip install -r requirements-dev.txt
219+
220+
# Or just core development dependencies
187221
pip install -e .
188222
pip install -r requirements.txt
189223

@@ -192,6 +226,9 @@ python -m unittest discover tests
192226

193227
# Run specific test file
194228
python -m unittest tests/path/to/test_file.py
229+
230+
# Test notebooks (requires Jupyter dependencies)
231+
python -m unittest tests.test_notebooks
195232
```
196233

197234
For detailed contribution guidelines, please see [CONTRIBUTING.md](CONTRIBUTING.md) (coming soon).

examples/README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
### Jupyter notebooks to demo HED processing with BIDS
2+
3+
The Jupyter notebooks in this directory are useful for annotating,
4+
validating, summarizing, and analyzing your BIDS datasets.
5+
6+
**Table 1:** Useful Jupyter notebooks for processing BIDS datasets.
7+
8+
| Notebooks | Purpose |
9+
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------|
10+
| [`extract_json_template`](https://github.com/hed-standard/hed-examples/blob/main/src/jupyter_notebooks/bids/extract_json_template.ipynb) | Creates a JSON sidecar based on all the event files in a dataset. |
11+
| [`find_event_combinations`](https://github.com/hed-standard/hed-examples/blob/main/src/jupyter_notebooks/bids/find_event_combinations.ipynb) | Creates a spreadsheet of unique combinations of event values. |
12+
| [`merge_spreadsheet_into_sidecar`](https://github.com/hed-standard/hed-examples/blob/main/src/jupyter_notebooks/bids/merge_spreadsheet_into_sidecar.ipynb) | Merges a spreadsheet version of a sidecar into a JSON sidecar. |
13+
| [`sidecar_to_spreadsheet`](https://github.com/hed-standard/hed-examples/blob/main/src/jupyter_notebooks/bids/sidecar_to_spreadsheet.ipynb) | Converts the HED portion of a JSON sidecar into a 4-column spreadsheet. |
14+
| [`summarize_events`](https://github.com/hed-standard/hed-examples/blob/main/src/jupyter_notebooks/bids/summarize_events.ipynb) | Summarizes the contents of the event files, including value counts. |
15+
| [`validate_bids_dataset`](https://github.com/hed-standard/hed-examples/blob/main/src/jupyter_notebooks/bids/validate_bids_dataset.ipynb) | Validates the HED annotations in a BIDS dataset. |
16+
| [`validate_bids_dataset_with_libraries`](https://github.com/hed-standard/hed-examples/blob/main/src/jupyter_notebooks/bids/validate_bids_dataset_with_libraries.ipynb) | Demonstrates use of HED libraries in validation. |
17+
| [`validate_bids_datasets`](https://github.com/hed-standard/hed-examples/blob/main/src/jupyter_notebooks/bids/validate_bids_datasets.ipynb) | Validates the HED annotations in a list of BIDS datasets. |
18+
19+
## Getting Started
20+
21+
**Note:** These example notebooks are only available in the [GitHub repository](https://github.com/hed-standard/hed-python),
22+
not in the PyPI distribution. To use them, clone or download the repository.
23+
24+
### Installation
25+
26+
1. **Clone the repository** (to get the example notebooks):
27+
```bash
28+
git clone https://github.com/hed-standard/hed-python.git
29+
cd hed-python/examples
30+
```
31+
32+
2. **Install HEDTools with Jupyter support**:
33+
34+
From PyPI:
35+
```bash
36+
pip install hedtools jupyter notebook
37+
```
38+
39+
Or from the repository root in development mode:
40+
```bash
41+
cd ..
42+
pip install -e .[examples]
43+
```
44+
45+
3. **Launch Jupyter** and open the notebooks:
46+
```bash
47+
jupyter notebook
48+
```
49+
50+
### Alternative: Download examples separately
51+
52+
If you already have `hedtools` installed from PyPI, you can download just the examples:
53+
54+
```bash
55+
# Download the examples directory from GitHub
56+
svn export https://github.com/hed-standard/hed-python/trunk/examples
57+
58+
# Or manually download from:
59+
# https://github.com/hed-standard/hed-python/tree/main/examples
60+
```
61+
62+
### Requirements
63+
64+
- Python 3.10 or greater
65+
- HEDTools package
66+
- Jupyter notebook environment
67+

0 commit comments

Comments
 (0)