Skip to main content
NOT A MEDICAL DEVICE. Research prototype only. Not validated for clinical use. No regulatory clearance (FDA/CE). Do not use for diagnosis or patient monitoring.

Rate-Based Cardiac Rhythm Triage

Sub-millisecond, sub-kilobyte rhythm-regime classifier. Triages beat-rate patterns (bradycardic, normal, tachycardic, transition-irregular) in 928 bytes of RAM using delay-line coincidence detection.

Validation status: v0.6 AAMI EC57:2012 inter-patient evaluation on MIT-BIH DS2 (22 records) with clinician rhythm-annotation ground truth (AFIB / SBR / SVTA / VT / B / T …): 78.4 % pooled accuracy, macro-F1 0.78, balanced accuracy 0.75. Adding a normalised RR-range rule (range/RR > 0.40) lifted Irregular recall from 0.19 to 0.78 (4×) on the same data. Side-by-side with a hand-coded band-gate + RR-window rule: 78.7 % — CricketBrain is on par, not better. The legacy v0.5 96.6 % number used a CV-based ground truth that was partially circular; v0.6 numbers are the honest replacement.

Triage, not diagnosis. Flags beat-rate regimes only — not morphology-aware arrhythmia, not AF / VT / AVB / ST-elevation, not a substitute for clinical ECG. Targets the earlier layer in the monitoring chain.

View Source Live Simulation

Real MIT-BIH Results — v0.6 (AAMI DS2, clinician GT)

AAMI EC57:2012 inter-patient evaluation on the canonical MIT-BIH DS2 split — 22 patients, 49 584 annotation beats. v0.6 introduces two corrections: (1) ground truth is now a hybrid — the MIT-BIH clinician rhythm-change annotation ((AFIB, (SBR, (SVTA, (B, (T, …) when unambiguous, falling back to a 5-beat sliding RR window otherwise (mitbih::rhythm_label_to_class); (2) the detector now uses an additional normalised RR-range rule (range/RR > 0.40) so that bigeminy / trigeminy / AFIB with stable short RRs are no longer missed.

78.44 %
Pooled accuracy (35 246 / 44 936) under hybrid GT
0.779
Macro F1 (4 classes, all with support)
0.78
Irregular recall (was 0.19 in v0.5)
22
Patients (AAMI DS2)
928 B
CricketBrain RAM (unchanged)
~0.13
µs / step (release)

Pooled confusion matrix — AAMI DS2, hybrid GT

pred Normalpred Tachypred Bradypred Irregularrecall
truth Normal17 81313793 3820.837
truth Tachy493 05801 3080.693
truth Brady28005 2682 0200.696
truth Irregular2 227304289 1070.781

The Irregular-class fix. v0.5 reported 0.84 Irregular recall against a CV-based ground truth that was partially circular with the detector's own CV rule. Under the more honest clinician-annotated hybrid GT, the v0.5 detector dropped to 0.19 Irregular recall — AFIB segments with stable short RR were silently misclassified. v0.6 adds range/RR > 0.40 to the classifier and lifts Irregular recall to 0.78 on the same data. Trade-off: Normal / Tachy / Brady recalls drop ~10–30 pp because the new rule fires more often. Stable rapid AFIB cannot be reliably distinguished from sinus tachy by short-window RR features alone — that is a fundamental limit of rate-regime triage and is not solved here.

Per-record accuracy — honest patient-level variability

RecordBeatsTruthAccuracyAAMI N / S / V / F / Q
1002 2722 266100.0 %2 238 / 33 / 1 / 0 / 0
1032 0832 077100.0 %2 081 / 2 / 0 / 0 / 0
1052 5562 37097.3 %2 511 / 0 / 41 / 0 / 4
1112 1232 114100.0 %2 122 / 0 / 1 / 0 / 0
1131 7951 41793.7 %1 789 / 6 / 0 / 0 / 0
1171 5351 51899.9 %1 534 / 1 / 0 / 0 / 0
1211 8631 69998.3 %1 861 / 1 / 1 / 0 / 0
1231 5171 42998.7 %1 514 / 0 / 3 / 0 / 0
2002 5941 89790.9 %1 738 / 30 / 824 / 2 / 0
2022 1341 85297.3 %2 060 / 54 / 19 / 1 / 0
2102 6442 28896.4 %2 421 / 22 / 191 / 10 / 0
2122 7482 59498.3 %2 748 / 0 / 0 / 0 / 0
2133 2503 21699.8 %2 641 / 28 / 219 / 362 / 0
2142 2571 79889.2 %2 001 / 0 / 253 / 1 / 2
2192 1531 97998.2 %2 081 / 7 / 64 / 1 / 0
2212 4201 82393.5 %2 028 / 0 / 392 / 0 / 0
2222 4661 79492.6 %2 258 / 208 / 0 / 0 / 0
2282 0471 61296.0 %1 683 / 3 / 361 / 0 / 0
2311 5701 40597.9 %1 568 / 1 / 1 / 0 / 0
2321 7461 31890.7 %365 / 1 381 / 0 / 0 / 0
2333 0591 32986.5 %2 228 / 7 / 813 / 11 / 0
2342 7522 71599.7 %2 699 / 50 / 3 / 0 / 0

Range: 86.5 % (record 233, frequent PVCs & AF) ↔ 100.0 % (records 100, 103, 111). Accuracy drops on records with frequent ventricular ectopics (200, 214, 233) and AF (232) because rate-regime classification is fundamentally limited when ectopic beats disrupt the RR pattern. AAMI N/S/V/F/Q columns are traceability only: CricketBrain does not classify morphology classes.

Baseline comparison — CricketBrain on par with a hand-coded rule

SystemEmissionsAccuracyMacro F1Balanced acc
CricketBrain (v0.6)44 93678.44 %0.77930.7515
ThresholdBurst rule (band-gate + RR-window, same v0.6 rule)44 92078.74 %0.78270.7551
Frequency rule (1-second window QRS counter)9 57318.21 %0.07700.2500

Honest finding (under hybrid clinician GT). A 50-line band-gate + RR-window rule (ThresholdBurstBaseline) is ~0.3 pp better than CricketBrain on AAMI DS2. The trivial 1-second-window rule fails badly at 18.2 %, so the task is non-trivial — but the neuromorphic core does not beat a careful classical rule on rate-regime triage. CricketBrain's value proposition is: 928 bytes RAM, deterministic, zero training, the same circuit reused across UC02 bearings / UC03 marine / UC04 grid, not "we solve a hard problem".

Drift-robustness sweep — honest result

We hypothesised CricketBrain's Gaussian tuning would degrade more gracefully than the rule's hard ±10 % band-pass under QRS carrier-frequency drift. The data did not support that hypothesis. A synthetic drift sweep (15 offsets in [−20 %, +20 %]) shows the rule has clean cliffs at ±10 % (its band edge), while CricketBrain's response is non-monotonic: it works at off ∈ {0 %, ±1 %, ±5 %, +20 %} and emits zero classifications at off ∈ {−3 %, −7 %, −10 %, +3 %, +7 %, +10 %, ±15 %}. Both systems break around the same drift band, but neither is meaningfully more robust. CSV at results/cardiac_drift_sweep.csv.

Reproduce: pip install -r python/requirements.txtpython python/download_mitbih.pyfor r in 100 103 105 111 113 117 121 123 200 202 210 212 213 214 219 221 222 228 231 232 233 234; do python python/preprocess.py --record $r; donecargo run --release --example cardiac_mitbih -- --records-dir <dir> --aami-split ds2 --write and cargo run --release --example cardiac_mitbih_baselines -- --records-dir <dir> --aami-split ds2 --write. Result files committed to use_cases/01_cardiac_arrhythmia/results/.

Synthetic-only Hardening — v0.2

Baseline measurements on synthetic P-QRS-T waveforms (deterministic SplitMix64 generator, fixed seed). Used for stress-test sweeps and reject-aware curves where real-patient data has no equivalent ground truth.

87.3%
Truth-based accuracy (after warmup, v0.2)
0.876
Macro F1 (4 classes incl. Irregular)
100%
Covered accuracy at confidence ≥ 0.9 (reject-aware)
928 B
CricketBrain RAM
0.13
µs / step (release)
~8 M
Steps / sec

The legacy 92.5 % / 0.962 numbers used a circular ground-truth path (the detector's own BPM defined the truth) and have been retired. v0.2 truth-based numbers above are the honest replacement; full per-class metrics, stress sweeps and the reject-aware curve live in BENCHMARK_ROADMAP.md.

Signal Detection Theory — synthetic

d′ / TPR / FPR (Green & Swets 1966)

Conditiond'TPRFPRTPR 95% CIRating
Tachycardia vs Normal6.181.0000.000[0.981, 1.000]EXCELLENT
Bradycardia vs Normal6.181.0000.000[0.981, 1.000]EXCELLENT
Normal vs Tachycardia6.181.0000.000[0.981, 1.000]EXCELLENT

200 signal + 200 noise trials per condition on synthetic P-QRS-T cycles. Wilson 95 % confidence intervals. d′ uses the Hautus 1995 log-linear correction. This SDT setup measures synthetic-rhythm discriminability, not real-patient performance — for that, see the v0.4 MIT-BIH section above.

Stress Test — Honest Limits

Where does the detector break? Side-by-side: raw CricketBrain vs. with preprocessing.

Noise Rejection: Without vs. With Preprocessor

Noise LevelWithout PreprocessorWith PreprocessorImprovement
0% (clean)100.0%100.0%
10%42.1%75.6%+33.5%
20%16.7%84.4%+67.7%
30%35.1%70.0%+34.9%
50%82.6%63.6%
70%8.6%1.9%Both fail

The EcgPreprocessor applies temporal consistency filtering: in-band signals must persist for 3+ consecutive steps to pass through. Single-step noise spikes are rejected. Gap tolerance (2 steps) bridges brief interruptions within real QRS bursts.

Other Stress Tests

TestConditionsResultVerdict
Extreme rates (30–250 BPM)10 rates, 12 cycles each10/10 correctPASSES
Boundary ±1 BPM59/61/99/101 BPM4/4 correctPASSES
Random RR (irregular)300–1200 ms, 30 beats82% detectedPASSES
Rapid switching (3-beat)Normal↔Tachy alternation89% IrregularExpected

How It Works

The 5-neuron Münster circuit

CricketBrain's core is a hardwired 5-neuron / 6-synapse delay-line coincidence detector inspired by the field cricket's auditory T-cell circuit (Münster model). Two delay lines feed a coincidence neuron: only when both inputs arrive within the integration window does it fire. There is no matrix multiplication, no weights to train, no GPU — just timing.

CricketBrain Münster Circuit — 5 neurons, 6 synapses, delay-line coincidence detection

Why this matters for UC01. The same 5-neuron circuit is reused across UC02 (bearing vibrations), UC03 (marine acoustics) and UC04 (power-grid harmonics) by changing only min_freq/max_freq. No retraining, no new architecture — the “Daseinsberechtigung” is cross-domain reuse in 928 bytes, not state-of-the-art rate-regime accuracy on any single task. On AAMI DS2 a 50-line band-gate rule is on par with this circuit; what the circuit buys you is portability across signal domains and zero training data.

Cardiac detection pipeline

INPUT FILTER DETECT CLASSIFY ECG Signal raw freq / ms R-Peak Extract beat timestamps RR Intervals milliseconds Freq Mapping BPM → Hz EcgPreprocessor Temporal Consistency Filter 3+ steps in-band · 2-step gap tolerance · moving average Rejects single-step noise spikes · Bridges brief interruptions Noise Rejected 1-2 step spikes → suppressed CricketBrain 5 Neurons · 6 Synapses · 928 bytes Gaussian tuning @ 4500 Hz · Coincidence gate Refractory period 150 ms · Burst energy validation Spike Output amplitude > 0 = beat RR Interval Tracker sliding window · 8 beats · CV analysis Tachycardia > 100 BPM Normal Sinus 60 – 100 BPM Bradycardia < 60 BPM CV > 0.3 → Irregular PERFORMANCE 0.126 µs/step 928 bytes d' = 6.18

How It Compares

Against Pan-Tompkins QRS detection, TinyML ECG classifiers (Nuzzo 2023 Tiny MF-CNN), the Stanford cardiologist-level DNN (Hannun 2019), and the Apple Watch AFib algorithm. All TinyML / DNN numbers from peer-reviewed papers or FDA filings.

RAM, Model Size & Latency

SystemRAMModel sizeLatency
CricketBrain UC01928 B~20 KB flash0.126 µs/step
Pan-Tompkins (QRS + rule-based)< 1 KB< 5 KB1-10 ms/beat
Tiny MF-CNN (Nuzzo 2023)~4-8 KB15 KB< 1 ms on RPi
Stanford DNN (Hannun 2019)GPU-class~10-40 MB30 s window
Apple Watch AFibproprietary~1-10 MB30-60 s polling

Accuracy & Training Data

SystemTaskAccuracy / F1Training data
CricketBrain UC01 (v0.6)4 rate classes78.4 % MIT-BIH AAMI DS2 (clinician GT), macro-F1 0.78Zero
Pan-Tompkins + rate logic4 rate classes~90% on MIT-BIHZero
Tiny MF-CNN (Nuzzo 2023)5 AAMI classes98.18% acc, F1 0.92MIT-BIH inter-patient
Stanford DNN (Hannun 2019)12 rhythm classesF1 0.837 (beat cardiologist avg 0.780)91 k ECGs, 53 k patients
Apple Watch AFibAFib vs Sinus98.3% sens / 99.6% specmillions of users

CricketBrain's 78.4 % pooled accuracy on real MIT-BIH AAMI DS2 with clinician rhythm-annotation ground truth is on rate-regime triage only — and a hand-coded band-gate + RR-window rule reaches 78.7 % on the same data, so the neuromorphic core does not beat classical rules here. Morphology-aware CNNs (Tiny MF-CNN, Stanford DNN) tackle the harder 5- and 12-class problems with 15 KB – 40 MB RAM and labelled training data. Different problems, different operating envelopes — see docs/competitive_analysis.md.

When to Pick Which

ScenarioRecommendation
Implantable loop recorder, sub-mW, rate-only triageCricketBrain
Earbud / patch, privacy-preserving, no cloudCricketBrain
Wearable with Cortex-M4F+, AAMI 5-class morphologyTiny MF-CNN / TinyML
Clinical monitor, 12-class rhythm + morphologyStanford DNN / commercial wearable
FDA-cleared AFib detectionApple Watch / commercial

Full sourced breakdown (Nuzzo 2023, Hannun 2019, Apple FDA DEN180044): docs/competitive_analysis.md.

Dataset & License

FieldValue
Primary DatasetMIT-BIH Arrhythmia Database
Dataset LicenseOpen Data Commons Attribution v1.0
Dataset URLphysionet.org/content/mitdb/1.0.0/
Records48 × 30 min two-channel ambulatory ECG
Sampling Rate360 Hz
Annotations~110,000 beat labels by 2+ cardiologists
License: CricketBrain source code is AGPL-3.0. Commercial use in proprietary software requires a paid license (details). The MIT-BIH dataset is ODC-By (attribution required). Citation: Goldberger et al. (2000), Moody & Mark (2001).

Quick Start

Terminal
# Clone and build
git clone https://github.com/BEKO2210/cricket-brain.git
cd cricket-brain/use_cases/01_cardiac_arrhythmia

# Run synthetic demo
cargo run --release

# Classify CSV data
cargo run --release -- --csv data/processed/sample_record.csv

# Run all benchmarks
cargo run --release --example cardiac_sdt
cargo run --release --example cardiac_latency
cargo run --release --example cardiac_stress