Evidence-based master deck · 19 July 2026

HeartGCN: paper → Mathematica → C++

The actual end-to-end story of turning cardiac graph mathematics into executable contracts, differential tests, and a deployable Qt application.

ACTUAL EVIDENCEASSUMED TEACHING GATELIMITATIONS VISIBLE

Meister et al., “Graph convolutional regression of cardiac depolarization from sparse endocardial maps,” arXiv:2009.14068v1

Original verification workflow

Research paper to verified C++

Original ten-stage workflow from research paper to traceable C++ release
1Paper claims
2Normalized specification
3Mathematica reference
4Lean lane (selective / optional)NOT PERFORMED
5Freeze baseline
6C++ implementation
7Test assets
8Parasoft C/C++testILLUSTRATIVE NOT RUN
9Cross-language audit
10Traceable release

This master deck applies the workflow to the HeartGCN case and distinguishes actual, illustrative, and blocked stages.

Executive result

What was actually achieved

12 / 12

Mathematica audit

12 / 12

C++ CLI validation

1 / 1

CTest

108

Manhattan values

Delivered

Wolfram package/notebook, audit and exports, C++20 core, CLI, Qt 6 GUI, four export files, deployed app.

Not claimed

No trained GCN reproduction, clinical validation, Lean proof, Parasoft run, or measured coverage.

Truth before theater

Evidence legend

ACTUAL PASS

Executed

Local artifacts, results, build, or smoke-run evidence.

ILLUSTRATIVE NOT RUN

Production method

Target workflow, never presented as measured.

BLOCKED BY DATA

Cannot reproduce

Inputs, weights, or clinical data unavailable.

Why Amp

Why Amp was the most suitable tool for this project

  • Long paper → spec → Wolfram → C++ → test orchestration.
  • Read PDF, code, notebooks, ledgers, build files, and reports.
  • Used specialized skills and local Mathematica/CMake/CTest/Qt tools.
  • Created and verified artifacts with claim-level traceability.
  • Continued context through referenced threads.
  • Handled user feedback mid-flight.
  • Depends on available tools and data.
  • Requires evidence discipline and user review.

Amp cannot replace clinical validation or formal assurance.

Paper choice

Why HeartGCN fit—and where it stops

Pros

  • Graph-native physical system; sparse-to-dense task.
  • Explicit GraphSAGE aggregation/update equations.
  • Weighted LAT/QRS loss.
  • Anisotropy and travel time.
  • Synthetic workflow supports numerical contracts.

Limits

  • No code, weights, raw meshes, fibers, preprocessing bounds, data, or splits.
  • Cannot reproduce the trained 20-layer GCN, figures, 8 ms / 7 ms MAE, or clinical claims.
  • Harmonic rectangular grid ≠ cardiac anatomy or learned GCN.
Workflow

One chain, explicit gates

Paper claims → normalized specification → Mathematica oracle → reference exports → C++20 core → CLI / Qt GUI → tests / evidence

Claim gate

What is specified?

Numerical gate

Do implementations agree?

Release gate

What ran, did not run, or is blocked?

Paper → normalized claims

Contracts that cross languages

IDContractWolframC++
GCN-AGG-01Neighbor mean, stable shapeMeanSAGEAggregatemeanSAGEAggregate
GCN-UPD-01Self + neighbor affine terms + activationGraphSAGEUpdategraphSAGEUpdate
LOSS-LAT-01Weighted LAT residualWeightedLATMSEweightedLatMSE
PHYS-ANISO-01Tensor → length → timeAnisotropyTensoredgeTravelTime
WAVE-01Seeded shortest pathSyntheticWavefrontDijkstra wavefront

demo1-results/docs/claim_ledger.md · normalized_specification.md

Mathematica reference

Executable equations, honest scope

MeanSAGEAggregate = Mean[neighbors]
GraphSAGEUpdate = sigma(Wself.self + bself + Wnbr.mean + bnbr)
WeightedLATMSE = (1/N) Sum[alpha_i (prediction_i-truth_i)^2], alpha_i = 2 if measured, 1 otherwise
EdgeTravelTime = virtualLength / speed
MeanSAGEAggregate[x_List, OptionsPattern[]] :=
 If[x === {}, zeroOrMissing, Mean[x]]

WeightedLATMSE[p_, y_, mask_] :=
 Total[MapThread[
   If[#3, 2, 1] (#1-#2)^2 &,
   {p, y, mask}]] / Length[p]

SparseReconstruction is a harmonic demonstrator—not the paper's trained GCN.

Synthetic evidence

Behavioral plots—not clinical efficacy

Sparse wavefront
Harmonic reconstruction
Sampling / noise
Stability boundary

Actual local Mathematica exports under demo1-results/exports/.

Mathematica audit

12 / 12 actual checks passed

ACTUAL PASS

Mean aggregation, update, weighted LAT/QRS losses, anisotropy tensor, virtual length, travel time, shortest path, harmonic reconstruction.

Evidence

HeartGCNModel.wl · HeartGCNNotebook.nb · audit_report.txt · validation_results.json · vectors · plots

The comments thread did not rerun it; the source project thread ran and verified the current audit and validation results.

Amp adapts during execution

Notebook feedback, BOM failure, recovery

Feedback

Inputs lacked explanation. The first Text-cell insertion introduced a UTF-8 BOM and made the notebook unreadable.

Correction

Preserve every original Input/Section cell, add only explanatory Text cells, remove BOM, verify structure. Later, source documentation around MeanSAGEAggregate improved clarity.

(* Mean neighbor features for one node.
   Empty neighborhoods preserve output dimensionality. *)
MeanSAGEAggregate[features_, neighbors_] := ...

https://ampcode.com/threads/T-019f7984-9c6a-7201-a007-43930c3f6c63

C++ architecture

Portable core, CLI, and deployable Qt GUI

C++20 core

Framework-independent std::vector functions matching Wolfram contracts.

Numerics

Dijkstra grid wavefront, harmonic reconstruction, seed 42, Gaussian elimination with pivoting.

Qt 6

GUI + CLI. Qt Charts unavailable; QPainter used instead.

demo1-results/CPP · https://ampcode.com/threads/T-019f798a-645f-715d-bbcc-ee0caaec5010

Wolfram → C++

Same contract, different runtime semantics

(* Wolfram *)
VirtualEdgeLength[d_, tensor_] :=
 Sqrt[d . tensor . d]
EdgeTravelTime[d_, tensor_, speed_] :=
 If[speed <= 0, Infinity,
  VirtualEdgeLength[d,tensor]/speed]
// C++
double virtualEdgeLength(const Vec& d,
                         const Matrix& tensor);
double edgeTravelTime(const Vec& d,
                      const Matrix& tensor,
                      double speed);

Shapes

Validate before indexing.

Non-finite

Define NaN and infinity.

Tolerance

Scale and conditioning matter.

Actual C++ verification

Build, tests, exports, deployment, launch

PASS

CMake

C++20 / Qt 6 build.

PASS

Tests

CTest 1/1; CLI 12/12; 108 grid values.

PASS

Exports

Four files non-empty.

PASS

App

windeployqt + GUI smoke.

Actual Qt application

The C++ demonstrator running ACTUAL PASS

HeartGCN C++ Qt demonstrator main window showing controls, heatmaps, status, MAE, and sampling curve
Controls: NX, NY, source, speed, sampling, and noiseDeterministic seed 42Status and MAESynthetic truth, harmonic reconstruction, and absolute errorSampling-vs-MAE curve
Synthetic demonstrator—not the trained clinical HeartGCN.
Tap image for full resolution
Actual validation dialog

12 / 12 checks visible in the app ACTUAL PASS

HeartGCN C++ Qt validation dialog showing all twelve named checks passing over the visible application heatmaps
The application dialog shows all 12 named checks; the heatmaps remain visible behind it.
Tap image for full resolution
Cross-language defect

The oracle export was wrong

Wolfram boundary_vectors.csv

transverse value: "-Power-"

Malformed serialization escaped the oracle layer.

C++ corrected export

sqrt(3) = 1.7320508075688772

Differential comparison exposed and corrected it.

Oracles are evidence—not infallibility.

Parasoft methodology

What a production C/C++test gate would do

Static analysis

CWE/CERT/MISRA/AUTOSAR configuration and disposition.

Tests + runtime

Claim-linked tests, memory, UB, and robustness checks.

Coverage

Statement, branch, condition, and required MC/DC evidence.

Expected targets: configuration, findings, dispositions, test log, coverage report, trace links. Teaching narrative assumes the gate; evidence status remains NOT RUN. No counts or percentages fabricated.

Parasoft bug examples

Bounds and graph-size safety

// BUG: CWE-125 / ARR30-C style
for (size_t i=0; i<weights.size(); ++i)
 out[i]=weights[i]*joined[i];
// FIX
if (weights.size()!=joined.size())
 throw std::invalid_argument("dimension mismatch");
out.at(i)=weights[i]*joined[i];
// BUG: CWE-190 / 681
int count = nx * ny;
vector<Node> graph(count);
// FIX
if (nx==0 || ny>max_size/nx)
 throw std::length_error("grid too large");
size_t count=nx*ny;
Parasoft bug examples

Travel time and floating point

// BUG: CWE-369
double edgeTravelTime(double l,double s) {
 return l/s;
}
// FIX
if (!isfinite(l)||l<0) throw invalid_argument("length");
if (!isfinite(s)) throw invalid_argument("speed");
if (s<=0) return numeric_limits<double>::infinity();
return l/s;

Do not compare approximate floats with equality. Define NaN/infinity policy first, then use justified absolute/relative tolerances.

Claim-linked unit tests

Simple no-framework style

// LOSS-LAT-01 / WL-WeightedLATMSE
check(near(weightedLatMSE({1,3},{0,2},{1,3}),1.0),
 "TC-LAT-01");
// PHYS-TIME-02
check(isinf(edgeTravelTime(2.0,0.0)),
 "TC-TIME-ZERO");
// PHYS-LEN-01
check(near(virtualEdgeLength(transverse),sqrt(3.0)),
 "TC-LEN-SQRT3");
// GCN-UPD-01
check(throwsInvalidArgument(badDimensions),
 "TC-UPD-DIM");

Representative production additions/pseudocode; no Catch2 or GTest claim.

Coverage / MC/DC plan

Decision evidence for edgeTravelTime

Statement: each executable statement
Branch: true/false outcomes
Condition: atomic Boolean outcomes
MC/DC: each condition independently changes the decision

Testfinite LL ≥ 0finite SS>0Expected
nominalTTTTL/S
NaN lengthFTTthrow
negativeTFTTthrow
NaN speedTTFthrow
zero speedTTTFInfinity

Target / expected evidence only; no measured coverage.

Final evidence matrix

What the evidence supports

StageStatusEvidence / reason
Claims + normalized specACTUAL PASSLedgers and specification
MathematicaACTUAL PASS12/12, vectors, plots
C++ core / CLI / GUIACTUAL PASSBuild, CTest, CLI, deploy, smoke
Differential workflowACTUAL PASSFound “-Power-”; corrected sqrt(3)
ParasoftILLUSTRATIVE NOT RUNMethodology only
LeanNOT PERFORMEDNo artifact/build evidence
Trained GCN / clinical claimsBLOCKED BY DATAWeights, meshes, fibers, data absent
Lessons and next steps

Reproducibility starts with honest boundaries

Lessons

  • Normalize before translating.
  • Separate demonstrator from clinical model.
  • Audit both sides of differential tests.
  • Recheck structure and encoding after feedback.

Next

  • Acquire author code/data/weights/meshes/fibers.
  • Harden dimension and non-finite contracts.
  • Run real Parasoft and measured coverage.
  • Formalize only justified Lean targets.
  • Perform approved clinical validation.

Notebook thread: https://ampcode.com/threads/T-019f7984-9c6a-7201-a007-43930c3f6c63
C++ thread: https://ampcode.com/threads/T-019f798a-645f-715d-bbcc-ee0caaec5010

← Swipe to navigate →