Production-ready wrapper and reimplementation of Temple University's NEDC EEG Evaluation v6.0.0
β οΈ Independent Project: This is an open-source contribution, not officially maintained by Temple University, NEDC, or affiliates. We wrap the original NEDC v6.0.0 software unchanged, and provide a modern reimplementation. All algorithmic credit goes to the original authors (Shah et al., 2021).
NEDC-BENCH transforms Temple University's NEDC EEG evaluation suite into a production-ready platform. We maintain a dual-pipeline architecture that guarantees scoring parity while offering modern infrastructure for scalable deployment.
The Problem: NEDC's evaluation software is excellent for research but challenging to deploy β dependency management, I/O conventions, and operational ergonomics make deployment and usage difficult.
Our Solution: Best of both worlds β preserve exact scientific behavior while making it effortless to run in production:
- 100% algorithmic parity with NEDC v6.0.0 (continuously validated)
- REST API & WebSockets for programmatic access
- Docker/Kubernetes ready with Redis caching and Prometheus metrics
- 92% test coverage with 187 tests
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β NEDC-BENCH Platform β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββββββββββββ βββββββββββββββββββββββββ β
β β Pipeline Alpha β β Pipeline Beta β β
β β (Legacy Wrapper) β β (Modern Rewrite) β β
β βββββββββββββββββββββββββ€ βββββββββββββββββββββββββ€ β
β β β’ Original NEDC code β β β’ Clean architecture β β
β β β’ Research-grade β β β’ Type-safe Python β β
β β β’ Text-based I/O β β β’ Async/parallel β β
β β β’ 100% fidelity β β β’ Cloud-native β β
β βββββββββββββββββββββββββ βββββββββββββββββββββββββ β
β β β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Unified API & Result Validator β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- TAES β Time-Aligned Event Scoring
- DP β Dynamic Programming Alignment
- Overlap β Any-overlap detection
- Epoch β 250ms epoch-based sampling
- IRA β Inter-Rater Agreement (Cohen's ΞΊ)
- Alpha (Legacy Wrapper): When you need bit-exact reproducibility with NEDC v6.0.0
- Beta (Modern Rewrite): For production deployments requiring speed and modern APIs
- Dual: To validate parity between pipelines (used in CI/CD)
git clone https://github.com/Clarity-Digital-Twin/nedc-bench.git
cd nedc-bench
# Build and start all services (API, Redis, Prometheus, Grafana)
docker compose up -d --build
# Verify health
curl http://localhost:8000/api/v1/health
# Expected: {"status":"healthy"}
# View API documentation
open http://localhost:8000/docs # Swagger UI
open http://localhost:3000 # Grafana dashboards (admin/admin)Quick test with sample data:
curl -X POST "http://localhost:8000/api/v1/evaluate" \
-F "reference=@data/csv_bi_parity/csv_bi_export_clean/ref/aaaaaajy_s001_t000.csv_bi" \
-F "hypothesis=@data/csv_bi_parity/csv_bi_export_clean/hyp/aaaaaajy_s001_t000.csv_bi" \
-F "algorithms=all" \
-F "pipeline=beta"π‘ Windows/WSL users: Use
docker compose(v2) notdocker-compose(v1). See deployment guide for troubleshooting.
# Using uv (10-100x faster than pip)
curl -LsSf https://astral.sh/uv/install.sh | sh
make dev # Installs deps + pre-commit hooks
# Or traditional pip
python -m venv .venv && source .venv/bin/activate
pip install -e ".[api]"
# Verify installation
make test # Run full test suite
make lint # Check code qualityimport requests
# Upload and evaluate EEG annotations
with open("ref.csv_bi", "rb") as ref, open("hyp.csv_bi", "rb") as hyp:
response = requests.post(
"http://localhost:8000/api/v1/evaluate",
files={"reference": ref, "hypothesis": hyp},
data={"algorithms": ["taes", "epoch", "ira"], "pipeline": "dual"},
)
job_id = response.json()["job_id"]
# Get results with parity validation
result = requests.get(f"http://localhost:8000/api/v1/evaluate/{job_id}").json()
print(f"TAES Sensitivity: {result['beta']['taes']['sensitivity']:.2f}%")
print(f"Parity Check: {'β
PASS' if result['parity']['match'] else 'β FAIL'}")import asyncio
import websockets
async def monitor_job(job_id):
async with websockets.connect(f"ws://localhost:8000/ws/{job_id}") as ws:
async for message in ws:
print(f"Progress: {message}")# Original NEDC wrapper (preserves exact v6.0.0 behavior)
./run_nedc.sh nedc_eeg_eval/v6.0.0/data/lists/ref.list \
nedc_eeg_eval/v6.0.0/data/lists/hyp.list
# Python scripts for batch processing
python scripts/run_alpha_complete.py # Full Alpha pipeline
python scripts/run_beta_batch.py # All Beta algorithms
python scripts/compare_parity.py # Compare Alpha vs Beta# Verify 100% algorithmic match with NEDC v6.0.0
python scripts/compare_parity.py --verbose
# Expected output (exact values):
# β
TAES: TP=133.84, FP=552.77, Sensitivity=12.45%, FA/24h=30.46
# β
Epoch: TP=33704, FP=18816, Sensitivity=11.86%, FA/24h=259.23
# β
Overlap: TP=253, FP=536, Sensitivity=23.53%, FA/24h=29.54
# β
DP: TP=328, FP=966, Sensitivity=30.51%, FA/24h=53.23
# β
IRA: Kappa=0.1887 (multi-class Cohen's ΞΊ)| Component | Metric | Value | Notes |
|---|---|---|---|
| API Latency | P50 | ~250ms | With Redis cache |
| API Latency | P99 | ~2.5s | Cold start |
| Throughput | RPS | ~100 | 4 workers, single node |
| Cache Hit Rate | % | >90% | After warm-up |
| Test Coverage | % | 92% | 187 tests |
| Parity | Match | 100% | All algorithms |
nedc-bench/
βββ src/
β βββ nedc_bench/ # Modern Beta pipeline (clean-room implementation)
β β βββ algorithms/ # Reimplemented scoring algorithms
β β βββ api/ # FastAPI application & endpoints
β β βββ models/ # Pydantic models for type safety
β β βββ orchestration/ # Dual-pipeline coordinator
β β βββ validation/ # Parity checking framework
β βββ alpha/ # Alpha pipeline wrapper
β βββ wrapper/ # Minimal wrapper around NEDC v6.0.0
βββ nedc_eeg_eval/ # Original NEDC v6.0.0 (vendored, unchanged)
β βββ v6.0.0/ # DO NOT MODIFY β reference implementation
βββ scripts/ # Utility scripts for testing & validation
β βββ compare_parity.py # Verify algorithmic equivalence
β βββ ultimate_parity_test.py # Full validation suite
βββ tests/ # Comprehensive test suite
βββ k8s/ # Kubernetes manifests
βββ docker-compose.yml # Full stack with Redis & Prometheus
- CSV_BI: Temple's annotation format (included examples)
- XML: Alternative annotation format
- List files: Batch processing of multiple files
- Redis caching provides >10x speedup for repeated evaluations
- Prometheus metrics for production monitoring
- WebSocket support for real-time progress updates
- Async processing for parallel execution
- π Installation Guide β Detailed setup instructions
- π Quick Start Tutorial β Get running in 5 minutes
- π API Reference β Endpoints, examples, OpenAPI access
- π³ Deployment Guide β Production deployment
- π Migration Guide β Moving from vanilla NEDC
- π¬ TAES Algorithm β Time-Aligned Event Scoring with multi-overlap sequencing
- π Epoch Algorithm β 250ms epoch-based sampling details
- π― Overlap Algorithm β Any-overlap detection
- π DP Alignment β Dynamic programming with NULL sentinel design
- π IRA Algorithm β Inter-Rater Agreement (Cohen's ΞΊ)
- ποΈ Architecture Guide β Dual-pipeline design & router pattern
- π Bug Fixes 2025 β Complete technical reference for 11 critical fixes
- βοΈ Beta Configuration β Three-tier architecture documentation
- π§ͺ Testing Guide β Comprehensive test strategy & stability solutions
- β Parity Validation β 100% parity on 1832 file pairs
- π§ Contributing Guide β Development workflow
The Temple University Hospital (TUH) EEG Corpus is the world's largest open EEG dataset. To access:
- Request access at https://isip.piconepress.com/projects/tuh_eeg/
- Email completed form to
help@nedcdata.org - Use provided credentials for rsync access
For testing NEDC-BENCH, we include sample data in nedc_eeg_eval/v6.0.0/data/.
If you use NEDC-BENCH in your research, please cite both:
@incollection{shah2021objective,
title={Objective Evaluation Metrics for Automatic Classification of EEG Events},
author={Shah, V. and Golmohammadi, M. and Obeid, I. and Picone, J.},
booktitle={Signal Processing in Medicine and Biology},
year={2021},
publisher={Springer},
doi={10.1007/978-3-030-36844-9_1}
}@software{nedc_bench2025,
title={NEDC-BENCH: A Modern Dual-Pipeline Platform for EEG Evaluation},
author={{Clarity Digital Twin}},
year={2025},
url={https://github.com/Clarity-Digital-Twin/nedc-bench},
note={Production wrapper and reimplementation with 100% parity validation
and modern infrastructure}
}We welcome contributions! See CONTRIBUTING.md for guidelines.
- New code (
src/nedc_bench/,src/alpha/,tests/): Apache 2.0 - Original NEDC (
nedc_eeg_eval/): No explicit license; Β© Temple University
- π Issues
- π Documentation
- π¬ Original NEDC
NEDC-BENCH bridges neuroscience research and production systems β’ Built on Temple University's foundational algorithms