open_eeg_codec_standard/lib.rs
1//! # OpenECS — the Open EEG Codec Standard
2//!
3//! OpenECS is a vendor-neutral, codec-agnostic benchmark for evaluating EEG
4//! compression quality. Any codec — lossless, lossy, neural, classical, hybrid,
5//! in any language — can declare compliance with an OpenECS quality tier by
6//! passing the standard test suite against a hash-pinned holdout corpus. No
7//! self-reported numbers, no cherry-picked patients: standardized corpus,
8//! standardized metrics, deterministic pass/fail.
9//!
10//! The crate is `open-eeg-codec-standard`; the library is `open_eeg_codec_standard`; the
11//! reference CLI is `openecs`.
12//!
13//! ## Tiers (strictness order L < N < C < M < A)
14//!
15//! | Tier | Name | Intent |
16//! |------|---------------|-------------------------------------------------|
17//! | L | Lossless | bit-exact reconstruction (PRD == 0 exactly) |
18//! | N | Near-Lossless | small error, shape preserved (R≥0.99, PRD≤5 %) |
19//! | C | Clinical | a neurologist cannot distinguish the recon |
20//! | M | Monitoring | automated analysis preserved |
21//! | A | Alerting | event detection preserved |
22//!
23//! A codec declares e.g. "I am ECS-C compliant at CR=42:1" and the harness
24//! verifies or rejects the claim. Grades render as `ECS-<tier>`.
25//!
26//! ## Layout
27//!
28//! - [`levels`] — the spec: tier table + the `grade` gate logic.
29//! - [`metrics`] — canonical metric formulas (PRD, Pearson R, SNR, CR…).
30//! - [`bands`] — per-EEG-band fidelity helpers.
31//! - [`adapter`] — the `Codec` trait + reference adapters (store, gzip, zstd).
32//! - [`adapters_external`] — the file-based contract for ANY external codec.
33//! - [`harness`] — the compliance grader + corpus runner.
34//! - [`corpus`] / [`manifest`] — hash-pinned corpus + codec manifests.
35//! - [`report`] / [`report_html`] — submission JSON + the HTML report.
36//! - [`term`] / [`charts`] / [`stats`] — terminal read-out, charts, CIs.
37
38/// The OpenECS specification version this crate implements (see `SPEC/`).
39/// Stamped onto every emitted report and submission. The tier ladder
40/// L < N < C < M < A is part of OpenECS v1.0.
41pub const SPEC_VERSION: &str = "1.0";
42
43/// The major component of [`SPEC_VERSION`]. A grader accepts a manifest whose
44/// major is this or older, and refuses a newer major it does not implement
45/// (see the spec's version policy).
46pub const SPEC_MAJOR: u64 = 1;
47
48/// Parse the major component of a `"MAJOR.MINOR"` spec-version string.
49pub fn spec_major(version: &str) -> Option<u64> {
50 version.split('.').next()?.parse().ok()
51}
52
53pub mod adapter;
54pub mod adapters_external;
55pub mod bands;
56pub mod charts;
57pub mod corpus;
58pub mod edf;
59pub mod harness;
60pub mod levels;
61pub mod manifest;
62pub mod metrics;
63pub mod report;
64pub mod report_html;
65pub mod stats;
66pub mod subprocess;
67pub mod suites;
68pub mod term;