Skip to main content

MetricProof-NWB

Tests PyPI

Reproducible evidence reports for NWB files.

Release history is tracked in CHANGELOG.md.

MetricProof-NWB complements schema and best-practice validators by preserving the evidence around an audit: the input path, SHA-256 digest, selected NWB metadata, validation findings, warnings, and timestamp. That makes a result easier to attach to a paper, archive submission, or CI run.

Version 0.3 can run PyNWB and NWBInspector as separate, independently versioned validators. Reports preserve NWBInspector's check name, importance, object, location, and message while recording each validator's version and effective configuration. They use MetricProof's shared evidence envelope: producer identity, artifact fingerprints, structured results, execution context, and explicit schema versioning.

It also provides a session evidence ledger. A ledger inventories the files that travel together, records parent/child lineage, and makes review gates explicit. The checks are configuration-driven: sample rates, graph nodes, expected counts, required files, and curation policy come from the session manifest, not from hard-coded HexMaze or laboratory constants.

Install

The base package depends only on MetricProof. Install the PyNWB extra for schema validation, the Inspector extra for PyNWB plus NWBInspector, or all optional validators:

python -m pip install "metricproof-nwb[nwb]"
python -m pip install "metricproof-nwb[inspector]"
python -m pip install "metricproof-nwb[all]"

Usage

metricproof-nwb audit session.nwb
metricproof-nwb audit session.nwb --format json --output evidence.json
metricproof-nwb audit session.nwb \
  --nwbinspector \
  --artifact-uri archive://study/session.nwb \
  --format json \
  --output evidence.json

Create and use a session manifest:

metricproof-nwb manifest path/to/session --output session-manifest.json
metricproof-nwb audit path/to/session/session.nwb \
  --manifest session-manifest.json --format json --output proof.json
metricproof-nwb bundle proof.json --output proof.html
metricproof-nwb verify proof.json

verify rehashes every local artifact and distinguishes a changed file (fail), a missing handoff (incomplete), and a remote or undigested object that still needs a human check (needs_review). The HTML bundle is offline and includes the artifact graph, exact hashes, validator findings, and review reasons so it can be attached to a paper, archive submission, or CI artifact.

For session-specific checks, pass a JSON object to --session-json when creating the manifest. For example:

{
  "session": {
    "session_id": "hexmaze-2026-08-21-01",
    "timebases": [{"name": "lfp", "rate": 1500, "sample_count": 3000, "start": 0, "stop": 2}],
    "curation": {"human_reviewed": true, "recompute_required": true, "recomputed": true}
  },
  "config": {
    "required_artifacts": ["session.nwb"],
    "node_ids": ["start", "goal"],
    "graph_edges": [["start", "goal"]]
  }
}

The checks cover artifact inventory and lineage, placeholder metadata, timebase consistency, recording durations, trial intervals and graph paths, declared NWB/file/unit counts, and curation gates. A report can therefore be technically valid while still being marked needs_review or incomplete when a human handoff is not evidenced.

The JSON document conforms to MetricProof's bundled evidence schema:

metricproof schema evidence

Its top-level report_type is nwb-audit; the audited file appears in artifacts, each validator has a separate entry in results, selected NWB metadata is stored in context.nwb_metadata, and software provenance is stored in context.validators. JSON keys are sorted before writing, so equivalent audits produce stable evidence files that are easier to diff and archive.

NWBInspector is called with skip_validate=True because MetricProof-NWB already runs PyNWB separately. This avoids duplicate schema findings while retaining a clear version and configuration for each validator. Best-practice suggestions and violations are preserved but do not fail the audit; critical findings and validator execution errors do.

The command exits with 0 when all critical checks pass, 1 when a critical validator or session check fails, 2 when the audit cannot run (for example, when PyNWB is not installed or the file cannot be opened), and 3 when a manifest completes with a non-blocking needs_review handoff state.

The Python API accepts injectable validator and metadata functions so projects can add study-specific checks without coupling their tests to one PyNWB release:

from metricproof_nwb import (
    audit_nwb,
    nwbinspector_validator,
    pynwb_validator,
)

report = audit_nwb(
    "session.nwb",
    validators=[pynwb_validator(), nwbinspector_validator()],
)
print(report.sha256)
print(report.validators)
print(report.inspector_findings)
print(report.to_dict())

The compatibility properties (status, sha256, size_bytes, validation_errors, and exit_code) remain available, while report.report provides direct access to the underlying metricproof.EvidenceReport.

The Python API exposes the same ledger primitives:

from metricproof_nwb import build_manifest, run_session_checks, verify_manifest

manifest = build_manifest("path/to/session", session={"session_id": "s-01"})
summary = run_session_checks(manifest)
verification = verify_manifest(manifest, base_dir="path/to/session")
print(summary.status, verification.status)

Reproducible example

examples/academic_workflow contains a bundled, synthetic extracellular-electrophysiology NWB file and the evidence JSON created from that exact artifact. The workflow verifies the report's SHA-256 digest and shows why validator versions matter when findings change over time.

See Validator responsibilities for a precise comparison of PyNWB validation, NWBInspector, dandi validate, and MetricProof-NWB.

Development

$env:PYTHONPATH = (Resolve-Path src).Path
python -m unittest discover -s tests -v

On macOS or Linux, use export PYTHONPATH="$PWD/src" instead.

Scope

MetricProof-NWB does not replace PyNWB validation, NWBInspector, or DANDI validation. It records their result alongside file identity and metadata so a research workflow can show exactly what was checked. It also does not infer scientific correctness from a complete manifest: a clean handoff is evidence of traceability, not a substitute for experimental judgment or domain review.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metricproof_nwb-0.3.0.tar.gz (96.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metricproof_nwb-0.3.0-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

Details for the file metricproof_nwb-0.3.0.tar.gz.

File metadata

  • Download URL: metricproof_nwb-0.3.0.tar.gz
  • Upload date:
  • Size: 96.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for metricproof_nwb-0.3.0.tar.gz
Algorithm Hash digest
SHA256 08936bb3752c1c735ee24d418c3d9e365fea292306337a22d73c009f95686cdd
MD5 83f90976fc2cc9dc32789626c7a56a26
BLAKE2b-256 eac6f1edb35c90387fb85bbcf8374982d624d4927a235c51c1c407f2fab54f7e

See more details on using hashes here.

Provenance

The following attestation bundles were made for metricproof_nwb-0.3.0.tar.gz:

Publisher: publish.yml on AtomicGlance/metricproof-nwb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file metricproof_nwb-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: metricproof_nwb-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 28.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for metricproof_nwb-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a57c06e16ae4eb3778a6f02b4aed2ee34af02072218f99d5a3b41e90cf3400b7
MD5 601c2b4109cfcd174d913f462b550f25
BLAKE2b-256 2206dfa091273ec033bf26b8c88393bfd091b308cd333ca7ffdbc9f8727cef45

See more details on using hashes here.

Provenance

The following attestation bundles were made for metricproof_nwb-0.3.0-py3-none-any.whl:

Publisher: publish.yml on AtomicGlance/metricproof-nwb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page