quantnuc-inverse MCP Server
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@quantnuc-inverse MCP Server Run a NEMA PET phantom simulation with partial-volume correction."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
quantnuc-inverse
Quantitative PET/SPECT Image-Formation, Partial-Volume (PVE), PSF-Gibbs & Cross-Scanner Harmonization Inverse Engine with Frontier Agent Harness & MCP Server
Research Software — NOT A MEDICAL DEVICE. This repository is strictly for nuclear medicine physics research, phantom benchmarking, method development, and educational exploration. It is not FDA-cleared, CE-marked, or validated for clinical diagnosis, patient staging, or therapeutic dosimetry prescription.
Why quantnuc-inverse?
General-purpose AI chat tools cannot run 3D spatially variant image-formation physics, invert ill-conditioned Geometric Transfer Matrices to machine precision, or synthesize EARL2/MIRD-23 harmonization filters under cryptographic provenance. quantnuc-inverse solves five high-stakes quantitative nuclear medicine physics problems in one auditable Python 3.12 + MCP engine:
3D Forward Image Formation & PSF-Gibbs Ringing: Spatially variant PET/SPECT PSF & collimator-detector response (CDR), OSEM/BSREM iteration convergence, and activity-conserving Difference-of-Gaussians Gibbs edge overshoot ("SUVmax inflation").
Exact & Regularized Partial-Volume Correction (PVC): Multi-region Rousset Geometric Transfer Matrix (GTM, forward re-projection residual $\le 10^{-6}$), voxel-wise Müller–Gärtner PVC, and Bayesian regularized recovery with calibrated
[SUV_p05, nominal, SUV_p95]bias–variance intervals.EARL1 / EARL2 / QIBA / MIRD-23 Harmonization Filter Synthesis: Bounded nonlinear optimization synthesizing the minimal Gaussian or Butterworth post-reconstruction filter (FWHM in mm) and iteration/BSREM-$\beta$ guidance across multi-vendor SiPM PET, PMT PET, TOF-PSF PET, and CZT SPECT/CT fleets.
CT-AC Respiratory Mismatch Forensics: Exact line-integral attenuation bias $\exp!\left(\int \Delta\mu,ds\right)$ at the lung–diaphragm / liver-dome boundary separating false-cold liver dome vs. false-hot basal lung artifacts, gated by hard
SEVERE_CT_AC_MISMATCHabstention.Frontier Agent Forensics Physicist & MCP Server: Hypothesis-falsifying longitudinal $\Delta\text{SUV}$ attribution, Saltelli–Jansen QMC global Sobol' variance decomposition, independent Critic-Verifier Audit, SHA-256 provenance ledgers, and 6 JSON-RPC 2.0 MCP tools.
Related MCP server: Auditory Binaural Masking Level Difference (BMLD) MCP Server
System Architecture
flowchart LR
subgraph Input["Validated Physics IR & DICOM I/O"]
IR["ir.py<br/>ScannerSpec, ReconConfig,<br/>LesionROI, EARLCorridorSpec"]
DCM["dicom_io.py<br/>pydicom PT/NM/CT Loader<br/>SUVbw / SUVlbm + Decay Gates"]
end
subgraph Core["Quantitative Nuclear Physics Engine"]
FWD["forward_image_formation.py<br/>3D PSF/CDR + Gibbs DoG +<br/>NEMA DRO + CT-AC exp(∫Δμ ds)"]
PVC["pve_inverse_solver.py<br/>Rousset GTM (res ≤ 1e-6),<br/>Müller–Gärtner, Bayesian CI"]
EARL["earl_harmonizer.py<br/>EARL1/EARL2/QIBA/MIRD-23<br/>Minimal Filter Optimizer"]
SOBOL["sobol_sensitivity.py<br/>Saltelli–Jansen QMC<br/>S1, ST & Interactions"]
end
subgraph Audit["Provenance, Agent Harness & MCP"]
PROV["provenance.py<br/>SHA-256 Chain Ledger &<br/>5 Hard Abstention Gates"]
AGENT["agent_orchestrator.py<br/>ΔSUV Forensics Physicist +<br/>Critic-Verifier Audit Dossier"]
MCP["mcp_server.py<br/>JSON-RPC 2.0 stdio<br/>6 Provenance-Gated Tools"]
end
IR --> FWD & PVC & EARL & SOBOL
DCM --> PROV --> PVC & AGENT
FWD --> PVC & EARL & AGENT
PVC & EARL & SOBOL --> AGENT --> PROV
AGENT --> MCPQuantitative Benchmark Dashboard
Metric / Verification Gate | Target / Standard | Verified Engine Performance |
Rousset GTM Re-Projection Residual (6-sphere 3D NEMA DRO) |
|
|
Total Activity Conservation Error (closed partition & Gibbs DoG) |
|
|
Multi-Vendor Fleet Corridor Violation ( |
| 4 / 4 feasible, max violation |
PET DICOM SUVbw / SUVlbm Round-Trip Fidelity ( |
|
|
CT-AC +10 mm / −10 mm Shift (511 keV PET) | Physical exponential bias |
|
ΔSUV Attribution Conservation Error (4 clinical scenarios) |
|
|
Test Suite, Coverage & Static Analysis |
| 38 passed, |
Publication-Grade Visual Benchmarks (300-DPI PNG + Vector PDF)
All six figures are reproducibly generated via scripts/generate_figures.py and audited visually for publication clarity.
1. NEMA NU 2-2018 6-Sphere Image Formation, PSF-Gibbs Overshoot & Rousset GTM Recovery

2. Multi-Scanner EARL1 / EARL2 / MIRD-23 Recovery Coefficient Corridors (Pre vs. Post Harmonization)

3. Partial-Volume Bias vs. Inverse Recovery & 90% Bias–Variance Uncertainty Ribbons

4. CT-PET/SPECT Lung–Liver Dome Respiratory AC Mismatch Forensics & Hard Abstention Gate

5. Frontier Agent Longitudinal ΔSUV Forensics Attribution Waterfall

6. Saltelli–Jansen QMC Global Sobol' Sensitivity (Small vs. Large Lesion Regime Crossover)

7. MIRD-26 $^{177}\text{Lu}$ PVE-Propagated Theranostic Absorbed Dose & PET Positron-Range Loss (v0.2.0)

8. Noise-Constrained EARL2 Pareto Frontier ($\text{COV} \le 15%$) & Necrotic-Core RBV PVC (v0.2.0)

Quick Start
# Install with uv (Python 3.12 recommended)
uv sync --python 3.12 --extra dev
# Stage NEMA NU 2-2018 DRO DICOMs + SHA-256 manifest
uv run python scripts/fetch_public_nucmed_sample.py
# Regenerate all 6 publication-grade figures (PNG + PDF)
uv run python scripts/generate_figures.py
# Run test suite, coverage, and linter
uv run pytest --cov=quantnuc_inverse --cov-report=term-missing
uv run ruff check src tests scriptsAPI, Agent Harness & MCP Workflows
from quantnuc_inverse import (
LesionROI,
build_reference_scanner_fleet,
get_corridor_spec,
invert_lesion_activity,
synthesize_harmonization_filter,
)
# 1. Synthesize minimal Gaussian EARL2 filter for a Digital SiPM TOF-PSF PET scanner
sipm_scanner, sipm_recon = build_reference_scanner_fleet()[0]
harm = synthesize_harmonization_filter(sipm_scanner, sipm_recon, get_corridor_spec("EARL2"))
print(f"Optimal FWHM: {harm.optimal_post_filter_fwhm_mm:.2f} mm | Post violation: {harm.max_corridor_violation_after:.4f}")
# 2. Invert true lesion SUV from observed partial-volume-corrupted ROI mean
harm_recon = sipm_recon.model_copy(update={"post_filter_fwhm_mm": harm.optimal_post_filter_fwhm_mm})
roi = LesionROI(lesion_id="L_12mm", diameter_mm=12.0, observed_suv_mean=5.1, background_suv=2.0)
result = invert_lesion_activity(roi, sipm_scanner, harm_recon, method="GTM_EXACT")
print(
f"Recovered SUV: {result.recovered_activity_nominal:.2f} "
f"[p05={result.recovered_activity_p05:.2f}, p95={result.recovered_activity_p95:.2f}] "
f"| Re-proj residual={result.forward_reprojection_residual:.2e}"
)from quantnuc_inverse.harness.agent_orchestrator import QuantitativeImagingForensicsAgent
agent = QuantitativeImagingForensicsAgent()
dossier = agent.build_complete_dossier()
md_path, json_path = dossier.write_bundle("outputs/dossier")
print(f"Audit Passed: {dossier.audit_report.overall_passed} | Gate: {dossier.audit_report.quantifiability_gate}")
print(f"Dossier: {md_path} | SHA-256 Ledger: {json_path}")Start the stdio MCP server via:
uv run quantnuc-mcpOr register in an MCP client configuration:
{
"mcpServers": {
"quantnuc-inverse": {
"command": "uv",
"args": ["run", "--directory", "/path/to/quantnuc-inverse", "quantnuc-mcp"]
}
}
}Exposed Provenance-Gated Tools (9):
quantnuc_forward_nema_rc— 3D NEMA NU 2-2018 6-sphere RCmean / RCmax / RCpeak simulation.quantnuc_invert_pve_activity— Rousset GTM, Müller–Gärtner, or Bayesian PVC inversion with 90% CI.quantnuc_synthesize_earl_filter— Minimal Gaussian/Butterworth EARL1/EARL2/QIBA/MIRD-23 filter synthesizer.quantnuc_audit_ct_ac_mismatch— Exact $\exp(\int \Delta\mu,ds)$ CT-AC respiratory bias & abstention audit.quantnuc_diagnose_suv_shift— Longitudinal $\Delta\text{SUV}$ hypothesis falsification & attribution.quantnuc_run_sobol_sensitivity— Saltelli–Jansen QMC global Sobol' sensitivity ($S_1, S_T$, bootstrap CIs).quantnuc_compute_theranostic_dose— MIRD-23/26 PVE-propagated multi-timepoint tumor absorbed dose (Gy).quantnuc_audit_3d_ct_ac_volume— 3D bilinear HU-to-$\mu(E)$ volumetric CT-AC respiratory bias audit.quantnuc_generate_physics_dossier— Autonomous Forensics Physicist + Critic-Verifier Audit dossier.
CLI Subcommands (uv run quantnuc ...):
uv run quantnuc harmonize --pet-standard EARL2 --noise-constrained
uv run quantnuc pvc --diameter 12 --observed-suv 5.1 --background-suv 2.0
uv run quantnuc audit-ac --shift-mm 10.0 --energy-kev 511.0
uv run quantnuc dose --diameter 14 --isotope Lu-177
uv run quantnuc dossier --output-dir outputs/dossierDocumentation & Provenance
Available Tools
9 toolsquantnuc_audit_3d_ct_ac_volumeC
Compute 3D bilinear HU-to-mu(E) ray-traced CT-AC respiratory mismatch bias across a lung-liver dome volume.
Inputs: breathing_shift_mm (required), raise_on_severe, photon_energy_kev.
quantnuc_audit_ct_ac_mismatchC
Compute exact CT-PET/SPECT respiratory attenuation-correction line-integral bias exp(int delta_mu ds) and abstention status.
Inputs: breathing_shift_mm (required), raise_on_severe, photon_energy_kev.
quantnuc_compute_theranostic_doseC
Propagate Rousset GTM partial-volume recovery into MIRD-23/26 multi-timepoint tumor absorbed dose (Gy) with 90% uncertainty interval.
Inputs: recon (required), scanner (required), timepoints (required), lesion_diameter_mm (required), +2 more.
quantnuc_diagnose_suv_shiftC
Decompose a longitudinal delta-SUV shift into PSF-Gibbs, PVE resolution, CT-AC respiratory artifact, and true biological change.
Inputs: baseline_recon (required), followup_recon (required), baseline_lesion (required), followup_lesion (required), +3 more.
quantnuc_forward_nema_rcC
Simulate 3D NEMA NU 2-2018 6-sphere Recovery Coefficients (RCmean, RCmax, RCpeak) including PSF-Gibbs ringing.
Inputs: recon (required), scanner (required), sphere_to_bg_ratio.
quantnuc_generate_physics_dossierC
Run the end-to-end Frontier Agent Forensics Physicist (4-scanner EARL2/MIRD-23 harmonization, longitudinal attribution, Critic-Verifier Audit).
Inputs: title.
quantnuc_invert_pve_activityC
Invert true lesion activity from observed SUV using Rousset GTM, Muller-Gartner, or Bayesian PVC with p05/nominal/p95 CI.
Inputs: recon (required), lesion (required), scanner (required), method.
quantnuc_run_sobol_sensitivityC
Run Saltelli-Jansen QMC global Sobol' sensitivity analysis (S1, ST, interactions) on quantitative SUV variance.
Inputs: lesion_diameter_mm (required), true_suv, background_suv, n_base_samples.
quantnuc_synthesize_earl_filterC
Synthesize minimal post-reconstruction Gaussian/Butterworth harmonization filter for EARL1, EARL2, QIBA, or MIRD23_SPECT.
Inputs: recon (required), scanner (required), filter_type, standard_name, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool maps to a distinct computational step (forward RC simulation, inverse PVC, filter synthesis, CT-AC bias, SUV decomposition, Sobol, dosimetry, dossier), but `quantnuc_audit_ct_ac_mismatch` and `quantnuc_audit_3d_ct_ac_volume` are close cousins distinguished only by 'line-integral' vs '3D ray-traced volume', and the end-to-end dossier overlaps conceptually with chaining the individual tools. Descriptions do resolve the ambiguity for a careful agent.
All tools share a `quantnuc_` prefix plus snake_case verb_noun structure (invert_pve_activity, synthesize_earl_filter, compute_theranostic_dose), which is predictable. Minor deviations: `quantnuc_forward_nema_rc` uses 'forward' as a verb and several names are heavy abbreviation strings (nema_rc, ct_ac, suv_shift) that read more like jargon than a clean pattern.
Nine tools is well within the sweet spot and each corresponds to a real, non-redundant step in the quantitative nuclear-medicine workflow. The dossier tool acts as an orchestrator rather than an inflated duplicate, so nothing feels padded.
The surface covers the domain lifecycle end to end: forward simulation, inversion/PVC, harmonization filter synthesis, CT-AC auditing (2D and 3D), longitudinal attribution, global sensitivity, and dosimetry with uncertainty plus a final dossier. Gaps are minor—no way to enumerate/validate supported scanners, phantoms, or reconstruction protocols, and no plotting/export of intermediate results for inspection.
Maintenance
Related MCP Connectors
Workflow diagnostics, capability routing, and x402 settlement for MCP-compatible agents.
Physics-based validation of simulation results: receipts with per-check verdicts, via MCP.
QuLab MCP remote server (Streamable HTTP) for computational science and lab tools.
MCP protocol requiring task acceptance and provenance tags. Self-hosted only - see README.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables MCP hosts to run provenance-aware computational epitope research workflows, including sequence and immune-evidence analysis, structure and chemistry calculations, molecular docking, and checksummed 3D artifact exports.46MIT
- AlicenseNot gradedqualityNot gradedmaintenanceEnables deterministic psychoacoustic modeling of dichotic hearing thresholds, interaural phase differences, brainstem processing scores, and cocktail-party speech-in-noise intelligibility through JSON-RPC tools.MIT
- AlicenseNot gradedqualityNot gradedmaintenanceEnables agents to deterministically calculate Pelli-Robson log contrast sensitivity scores, Weber contrast thresholds, visual functional acuity, and photopic glare recovery metrics through JSON-RPC tooling.MIT
- AlicenseNot gradedqualityNot gradedmaintenanceEnables agents to compute single-breath nitrogen washout closing volume, closing capacity, age-predicted reference intervals, and peripheral small airway patency through deterministic JSON-RPC tools.MIT