Skip to main content
Glama

radpareto-engine

Closed-Loop AAPM TG-233 Task-Based Image Quality × Organ & Peak-Skin-Dose Pareto Protocol Optimization Engine with Frontier Agent Harness & MCP Server

Python 3.11 | 3.12 License: Apache-2.0 Research Software Standards: AAPM TG-233 / TG-204 / TG-220 / TG-293 MCP: JSON-RPC 2.0 Audit: 14/14 Pass Version: v0.2.0

RESEARCH SOFTWARE NOTICE — NOT A MEDICAL DEVICE. radpareto-engine is provided exclusively for medical physics research, algorithm benchmarking, and phantom metrology education under the Apache-2.0 License. It has not been cleared or approved by the FDA, EU MDR, or any regulatory authority, and must not be used for clinical diagnosis, automated scanner exposure control, or unverified clinical dose reporting without Qualified Medical Physicist (QMP) commissioning.


Why radpareto-engine?

Consumer AI chat interfaces cannot ingest binary DICOM phantoms or DICOM Radiation Dose Structured Reports (RDSR), verify discrete Parseval noise-power conservation, ray-cast multi-angle C-arm fluoroscopy beams onto 3D patient entrance skin, or enforce real X-ray tube current/power/heat saturation ceilings while solving exact inverse Dose–Detectability frontiers.

radpareto-engine solves this end-to-end with strictly typed Pydantic v2 Physics IR, cryptographic SHA-256 provenance, 5 hard AbstentionCode safety gates, an autonomous Critic-Verifier Agent Harness, and a zero-bloat JSON-RPC 2.0 stdio MCP server.


Related MCP server: OpenClaw GenPark Agent Forge

System Architecture

flowchart TD
    A["DICOM CT / Phantom & RDSR Input (pydicom)"] --> B["AAPM TG-233 Metrology Kernel (TTF, 2D/3D NPS, Parseval, NPWE & CHO d')"]
    A --> C["Dosimetry & RDSR Engine (TG-204/220/293 SSDE, ATCM, 3D Fluoro PSD)"]
    B --> D["Multi-Vendor Pareto & Inverse d' Solver (Siemens / GE / Philips / Canon)"]
    C --> D
    E["X-Ray Tube Hardware Limits (mA, kW, MHU, Sn-Filter)"] --> D
    D --> F["Hard Abstention & Provenance Layer (SHA-256 + 5 AbstentionCode Gates)"]
    D --> G["Saltelli-Jansen QMC Sobol' UQ (S_1, S_T, 95% CI)"]
    F --> H["Frontier Agent Orchestrator & Independent Critic-Verifier Gate"]
    G --> H
    H --> I["ACR / AAPM TG-233 Physics Audit Dossier (Markdown + JSON)"]
    H --> J["JSON-RPC 2.0 Stdio MCP Server (6 Provenance-Gated Tools)"]

Verified Benchmark & Independent Audit Dashboard

All metrics below are deterministically reproduced by scripts/run_benchmarks_and_figures.py and independently verified by scripts/run_independent_audit.py (see docs/AUDIT_REPORT.md).

Benchmark / Verification Domain

Metric

Verified Result

Reference / Gate

AAPM TG-233 Parseval Invariant

Max discrete 2D NPS integral vs. variance error ($n=12$)

2.93e-16

Tolerance < 0.02 (PARSEVAL_NPS_VIOLATION)

Closed-Form $d'$ Scaling

Max error for $d'(2C)=2d'(C)$ and $d'(4\cdot\mathrm{NPS})=0.5,d'$

2.02e-16

Exact quantum-limited NPWE identity

Nonlinear IR Resolution Shift

MBIR $f_{50}$ High (+500 HU) vs. Low (+45 HU) contrast

0.42 → 0.34 mm⁻¹

AAPM TG-233 contrast-dependent TTF

Iodine CTA Spectral Pareto

2 mm vessel ($d'=6.0$, $D_w=27\text{ cm}$): 80 kVp DLR vs 140 kVp FBP

1.71 vs. 18.20 mGy

-90.6% exact inverse CTDIvol solve

3D Fluoroscopy PSD (RDSR)

6-event CTO-PCI RDSR round-trip Peak Skin Dose

6.22 Gy (53 cm² > 5 Gy)

NCRP 168 / ICRP 120 FOLLOWUP_5GY tier

Multi-Vendor Fleet Drift Audit

6-scanner fleet (Siemens, GE, Philips, Canon)

-41.5% mean CTDIvol

Compliance 3/6 → 6/6; 6/6 Critic-Verifier APPROVED

Saltelli–Jansen Sobol' UQ

Analytical Ishigami accuracy ($N_{\text{base}}=1024$)

Max err 0.0124

Saltelli 2010 / Jansen 1999 QMC

Public Open-License CT Sample

data/public_ct_sample/CT_small.dcm (MIT)

$D_w = 8.72\text{ cm}$

SHA-256 verified against MANIFEST.json

Hard Safety Abstention Gates

Adversarial trigger suite across all 5 AbstentionCodes

5 / 5 FIRED

Zero silent bypasses

3D Volumetric NPS Parseval

Full 3D FFT $\mathrm{NPS}_{3D}(f_x, f_y, f_z)$ variance check

< 1e-15

Exact 3D Parseval conservation

Empirical Scanner Calibration

Phantom-to-surrogate regression fit ($n=6$ scans)

$R^2_{\text{noise}} = 1.000$, $R^2_{f_{50}} = 0.992$

RMS $d'$ error 0.31

Joint Multi-Task Pareto & VMI

Simultaneous Liver + CTA compliance & PCCT VMI UHR

6.68 mGy joint min; PCCT 40 keV $d'=21.0$

Binding-task guardrail + K-edge peak

Longitudinal ATCM & QA CUSUM

$z$-axis ATCM DLP savings & 30-session SQLite CUSUM

-44.8% DLP; Alert at Session 20

Tube aging onset at Session 18 caught in 2 runs

Multi-Procedure Cranial PSD

3 staged neuro-angiography runs (120-day window)

15.8 Gy strict vs. 12.7 Gy repair-weighted

TJC $\ge 15\text{ Gy}$ sentinel gate


Publication-Grade Visuals (300-DPI PNG & Vector PDF)

All 6 figures follow Medical Physics / Radiology styling with the colorblind-safe Okabe–Ito palette, physical scalebars, bold panel labels, and cryptographic SHA-256 provenance footers.

1. AAPM TG-233 Nonlinear Phantom Metrology (TTF, 2D/1D NPS, NPWE & CHO $d'$)

TG-233 Phantom Metrology

2. Habitus-Stratified Dose–Detectability Pareto Frontiers & Tube Saturation Boundary

Dose-Detectability Pareto

3. 3D Patient-Surface Fluoroscopy Peak Skin Dose (PSD) Map from DICOM RDSR

Fluoroscopy 3D PSD Map

4. Autonomous Multi-Vendor Fleet Protocol Drift Audit & Critic-Verifier Gate

Fleet Protocol Drift Audit

5. Saltelli–Jansen Global Sobol' Sensitivity & 2D ($D_w \times \text{CTDI}_{\text{vol}}$) Phase Diagram

Sobol Sensitivity & Phase Diagram

6. Public Open-License CT Calibration, Multi-Habitus SSDE & Formal Invariant Verification

Cohort Validation & Calibration

7. Empirical Scanner Calibration, Joint Multi-Task Pareto & PCCT/DECT Spectral VMI (v0.2.0)

Multi-Task Pareto & PCCT VMI

8. Longitudinal SQLite TG-233 QA CUSUM Drift Monitor & Multi-Procedure Cranial PSD (v0.2.0)

Longitudinal QA CUSUM & Multi-Procedure PSD


Quickstart (uv + Python 3.12)

# 1. Install package and dev tools with uv
uv sync --extra dev --python 3.12

# 2. Verify public MIT CT sample + SHA-256 manifest
uv run python scripts/fetch_public_ct_sample.py

# 3. Unified CLI (`radpareto`) quick runs
uv run radpareto tg233 --recon hybrid_ir --ctdi 10
uv run radpareto pareto --dw 29 --multitask
uv run radpareto psd results/benchmark_cto_pci_rdsr.dcm --geometry torso
uv run radpareto audit
uv run radpareto qa-check --sessions 30 --drift-onset 18

# 4. Run full test suite (strict warnings + Hypothesis fuzzing) & lint
uv run pytest --cov=radpareto_engine --cov-report=term-missing
uv run ruff check src tests scripts

# 5. Reproduce all 8 publication figures & 14-check independent audit
uv run python scripts/run_benchmarks_and_figures.py
uv run python scripts/run_independent_audit.py

Collapsible Workflows (Python API & MCP Server)

from radpareto_engine.ir import ClinicalTaskSpec, CTProtocolSpec, CTVendor, ReconMode
from radpareto_engine.pareto_optimizer import invert_min_dose_for_dprime
from radpareto_engine.harness.agent_orchestrator import audit_and_optimize_protocol_fleet

protocol = CTProtocolSpec(
    protocol_id="ABD-HYBRID-IR",
    scanner_name="Siemens SOMATOM Force",
    vendor=CTVendor.SIEMENS,
    kvp=100.0,
    slice_thickness_mm=3.0,
    recon_mode=ReconMode.HYBRID_IR,
    ir_strength=0.6,
)
task = ClinicalTaskSpec(
    name="5mm_low_contrast_liver_lesion",
    diameter_mm=5.0,
    contrast_hu=25.0,
    d_prime_target=3.0,
)

# Exact minimum CTDIvol required to guarantee d' >= 3.0 at D_w = 31 cm
sol = invert_min_dose_for_dprime(protocol=protocol, d_w_cm=31.0, task=task)
print(f"Min CTDIvol = {sol.min_ctdi_vol_mgy:.2f} mGy | SSDE = {sol.min_ssde_mgy:.2f} mGy | d' = {sol.achieved_d_prime:.2f}")

# Autonomous multi-vendor fleet audit + Critic-Verifier Gate
dossier = audit_and_optimize_protocol_fleet()
print(f"Critic approved: {dossier.critic_approved_count}/{dossier.total_protocols} | Mean CTDI delta: {-dossier.fleet_mean_ctdi_reduction_pct:+.1f}%")

Start the zero-bloat stdio MCP server:

uv run radpareto-mcp   # or: uv run radpareto mcp

Exposed tools (tools/list):

  1. radpareto_measure_tg233 — Circular-edge TTF, 2D/3D Parseval-verified NPS, NPWE & CHO $d'$.

  2. radpareto_compute_ssde_and_psd — AAPM TG-204/220/293 SSDE + calibrated 3D fluoroscopy PSD.

  3. radpareto_solve_pareto_frontier — Hardware-constrained CT Dose–Detectability Pareto frontier.

  4. radpareto_invert_min_dose_for_dprime — Exact Brent inverse solve for minimum $\text{CTDI}{\text{vol}}$ guaranteeing $d' \ge d'{\text{target}}$.

  5. radpareto_audit_protocol_fleet — Multi-vendor drift audit + Critic-Verifier Gate dossier.

  6. radpareto_run_sobol_sensitivity — Saltelli–Jansen QMC global Sobol' sensitivity ($S_1, S_T, 95%\text{ CI}$).

  7. radpareto_solve_multitask_pareto — Joint multi-task Pareto optimization (Liver + CTA) with optional PCCT/DECT VMI sweep.

  8. radpareto_analyze_dicom_file — Real local CT Image (.dcm) or DICOM RDSR (.dcm) analysis with SHA-256 provenance.

Example JSON-RPC 2.0 call:

{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"radpareto_invert_min_dose_for_dprime","arguments":{"d_w_cm":30.0,"d_prime_target":3.0,"kvp":120,"recon_mode":"hybrid_ir","ir_strength":0.6}}}

Hard safety violations (e.g., uncalibrated RDSR or tube saturation) return structured MCP responses with "isError": true and machine-readable "abstention_code".


Documentation, Citations & License

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      B
      maintenance
      Exposes the six-echelon quality pipeline over stdio JSON-RPC 2.0, enabling MCP clients to manage frozen baselines, HMAC-approved gates, phase role isolation, safe rollback, independent verification, W3C PROV-DM audit chains, and CAPA consolidation.
      10
      1
      MIT
    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables MCP-compatible clients such as Claude Desktop, Cursor, and Antigravity to invoke deterministic mathematical modeling and System 2 agent capabilities through a native STDIO JSON-RPC 2.0 server with zero external dependencies.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables AI clients to perform sandboxed file-system operations, read-only SQLite querying and schema inspection, environment diagnostics, and cryptographic hashing over Stdio or HTTP using JSON-RPC.
      2
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      Enables MCP clients to verify claims against evidence, generate and validate tamper-evident receipts, and pre-filter prompt-injection attempts through stdio JSON-RPC tools.
      5
      Apache 2.0