m42 · Physics-informed machine learning: PINNs, surrogate models and uncertainty for digital twins
Education only. Not for diagnosis, treatment or any clinical decision.
In 60 seconds
A physics-informed neural network (PINN) fits measurements and a governing equation at the same time: its loss adds the equation’s residual at many points to the usual data misfit (Raissi et al. 2017). In electrophysiology, PINNs have built activation maps from sparse catheter measurements together with a conduction-velocity map and an uncertainty estimate (Sahli Costabal et al. 2020), estimated tissue parameters from action-potential recordings (Herrero Martin et al. 2022), and estimated atrial fibre orientation with an ensemble of networks (Magaña et al. 2025). The same ideas give fast surrogates for calibrating the digital twins of m33. This module writes the physics-informed loss for the eikonal equation, fits it without a deep-learning library, shows where the physics term helps and where a wrong physical assumption hides the feature you are looking for, and uses ensembles and surrogates with their limits in view.
From the field
- Activation maps from sparse points. A PINN for atrial activation mapping used two networks, one for activation time and one for conduction velocity, and added the eikonal residual and a total-variation penalty on velocity to the data misfit. An ensemble of 30 networks with randomized prior functions gave the uncertainty, and the next measurement was placed where the predictive entropy was highest. It outperformed linear interpolation and Gaussian-process regression on a benchmark, and linear interpolation at clinical point densities on a left-atrial model (Sahli Costabal et al. 2020). Ellen Kuhl of Stanford University was a co-author.
- From maps to fibres. Extending that approach, an ensemble of PINNs estimated atrial fibre orientation and conduction velocities from mapping activation times in under 7 minutes, with quantified uncertainty, and improved fibre-orientation error over the earlier method in eight atrial anatomies (Magaña et al. 2025).
- Tissue parameters. EP-PINNs estimated parameters of a two-variable cardiac model (related to action-potential duration, excitability and diffusion) from simulated data and from optical mapping with ion-channel blockers. Training took between 15 minutes and 16 hours on a GPU, depending on the problem (Herrero Martin et al. 2022).
- Physics-informed learning at NVIDIA. Hidden fluid mechanics, a physics-informed network that recovers velocity and pressure fields from flow visualizations, was published in Science by a team that included an NVIDIA author (Raissi et al. 2020). NVIDIA maintains PhysicsNeMo, an open-source (Apache-2.0) deep-learning framework for AI-driven multi-physics systems (NVIDIA PhysicsNeMo Team 2026).
- Digital twins need fast fitting. Building twins from clinical data still needs faster and more robust fitting of anatomy and parameters (Gillette et al. 2021; Corral-Acero et al. 2020); surrogates are one way to get it (lab part E).
Derivations
Symbols: activation time \(T(\mathbf x)\) (ms), slowness \(s(\mathbf x) = 1/v(\mathbf x)\) (ms/mm), measurement points \(\mathbf x_i\) with times \(t_i\) (\(i = 1 \dots N_d\)), collocation points \(\mathbf x_c\) (\(c = 1 \dots N_c\)), physics weight \(\lambda\), basis centres \(\mathbf c_k\) and width \(h\), coefficients \(\mathbf a\), Jacobian \(J\), residual vector \(\mathbf r\), damping \(\mu\), ensemble members \(T_m\).
The physics-informed loss
Activation spreading at local speed \(v\) obeys the eikonal equation \(v\,\lvert\nabla T\rvert = 1\) (m30). Its residual at a point is
\[ r(\mathbf x) = s(\mathbf x)\,\lvert \nabla T(\mathbf x) \rvert - 1 \tag{1}\]
zero wherever the map is consistent with the speed. A physics-informed fit minimizes the data misfit plus the mean squared residual at collocation points (Raissi et al. 2017):
\[ L = \frac{1}{N_d} \sum_{i=1}^{N_d} \big(T(\mathbf x_i) - t_i\big)^2 + \frac{\lambda}{N_c} \sum_{c=1}^{N_c} r(\mathbf x_c)^2 \tag{2}\]
The first term is ordinary regression. The second asks the map to behave like a propagating front between and beyond the measurements; with \(s\) unknown, the fit also estimates the speed. \(\lambda\) sets the balance and has units of ms² here, because the data term is in ms² and the residual is dimensionless. Published PINNs add further terms, such as a total-variation penalty on velocity (Sahli Costabal et al. 2020).
Fitting without a deep-learning library
A neural network is one way to represent \(T\); a sum of Gaussian radial basis functions is another, with gradients in closed form:
\[ T(\mathbf x) = a_0 + \sum_{k} a_k\, e^{-\lvert \mathbf x - \mathbf c_k\rvert^2/2h^2}, \qquad \nabla T(\mathbf x) = -\sum_k a_k\, \frac{\mathbf x - \mathbf c_k}{h^2}\, e^{-\lvert \mathbf x - \mathbf c_k\rvert^2/2h^2} \tag{3}\]
Stack the data residuals and the weighted eikonal residuals into one vector \(\mathbf r\) of the unknowns \(\mathbf p\) (the coefficients and the slowness), so that \(L = \lvert\mathbf r\rvert^2\). The Levenberg–Marquardt method linearizes \(\mathbf r\) around the current \(\mathbf p\) and takes the step
\[ \left(J^\top J + \mu\, \mathrm{diag}(J^\top J)\right) \boldsymbol\delta = -J^\top \mathbf r, \qquad J = \frac{\partial \mathbf r}{\partial \mathbf p} \tag{4}\]
raising \(\mu\) when a step fails and lowering it when one succeeds. The eikonal residual is nonlinear in \(\mathbf a\) through \(\lvert\nabla T\rvert\), which is why an iterative method is needed; with \(\lambda = 0\) the problem is linear and one step gives the least-squares fit.
Simulation
Assumptions
- Model: Equation 3 with 81 Gaussian basis functions 7.5 mm apart (width 8 mm) and one unknown slowness, fitted by Equation 4 to Equation 2 with collocation points every 3 mm. Fits are precomputed by
tools/make_m42_d1.pyfrom the course’s tested code and shipped asdemos/m42-d1-data.json. - Truth: a point source at (8, 30) mm on a 60-by-60-mm square at 1.0 m/s, the normal-tissue value used in m39 (Heil et al. 2023), measured at random points with 1 ms of noise (one fixed random draw). Values are illustrative.
- What would change the result: a different random draw (lab part B averages six), a heterogeneous speed (lab part C), curved surfaces and real measurement errors such as position error (m19).
Key takeaways
- A physics-informed loss is the data misfit plus the weighted residual of the governing equation.
- The physics term constrains the map where there are no data, and can estimate the speed.
- Too few data leave the physics ambiguous: many fronts fit a handful of points.
When the physics is wrong
The loss in Equation 2 is only as good as its equation. If the fit assumes one speed everywhere but the tissue has a slow region, the physics term pushes the map towards uniform spread. In lab part C, a homogeneous-speed prior lowered the map error overall but pulled the speed estimated inside a slow disc from close to its true 0.6 m/s towards the surrounding 1.0 m/s. Slow regions are what mapping often looks for (m25, m29), so the choice between a single speed, a speed field with smoothness penalties (Sahli Costabal et al. 2020) and a data-only fit is a design decision with clinical consequences.
Uncertainty from ensembles
Train \(M\) members, each from a different starting point, on data with fresh noise and with its own fixed random prior function (randomized priors, as in Sahli Costabal et al. (2020)). At each point,
\[ \bar T(\mathbf x) = \frac{1}{M}\sum_{m=1}^{M} T_m(\mathbf x), \qquad \sigma^2(\mathbf x) = \frac{1}{M-1}\sum_{m=1}^{M} \big(T_m(\mathbf x) - \bar T(\mathbf x)\big)^2 \tag{5}\]
Members agree where data hold them together and disagree elsewhere, so \(\sigma\) is a practical uncertainty map. It is not a guaranteed confidence interval: check how often the error falls within it (lab part D).
Simulation
Assumptions
- Model: each member is a ridge least-squares fit (Equation 3 in one dimension, 13 basis functions 5 mm apart) to the measurements plus 1 ms of fresh noise, with its own random prior function; the band is Equation 5. Random numbers come from a fixed seed, so the picture is repeatable.
- The measurements, their noise and the origin at 8 mm are illustrative; the physics term is left out here to keep the demo fast.
- What would change the result: with the eikonal term, members agree more beyond the data (lab part D); the prior scale is a modelling choice that sets how much the members can disagree.
Surrogates and where they are safe
Calibrating a twin means running its model many times (m33). A surrogate is a cheap function fitted to model runs and used in their place. Physics can guide its form: along any fixed path, activation time is a sum of path lengths times slowness, so scaling every slowness by \(k\) scales every activation time by \(k\):
\[ T\big(\mathbf x;\, k\,s(\cdot)\big) = k\, T\big(\mathbf x;\, s(\cdot)\big) \tag{6}\]
Writing the surrogate in slowness (\(1/v\)) rather than speed exploits this. A surrogate is only trustworthy inside the range of parameters it was trained on: in lab part E its error rises from under 0.1 ms inside the range to several milliseconds outside it.
Key takeaways
- Ensemble spread tracks error but must be checked for coverage.
- Physics can shape a surrogate (Equation 6) and makes it cheaper to train.
- Never use a surrogate outside its training range without checking it against the full model.
Clinical correlate
This section describes published findings only. It is not guidance for patient care, and it has not yet been reviewed by an EP physician.
Where physics-informed methods could enter EP practice. Electroanatomic activation maps are interpolated from a limited number of catheter points (m24); conduction-velocity maps are derived from them (m25); and digital twins of a patient’s atria are calibrated to such maps (m33). The studies in this module address each step: activation and velocity maps with uncertainty (Sahli Costabal et al. 2020), tissue parameters (Herrero Martin et al. 2022), and fibre orientation for twin personalization (Magaña et al. 2025).
What the evidence is. The cited studies are method studies: synthetic benchmarks and simulated atria (Sahli Costabal et al. 2020; Magaña et al. 2025), simulations and ex vivo optical mapping (Herrero Martin et al. 2022). We found no clinical outcome study among them. Their contribution is methodological, and their results are reported in the units of the methods: activation-time and fibre-angle errors, parameter errors, computing time.
In the terms of this module and m45:
- Check the physics assumed. A homogeneous-speed prior can hide a slow region; a speed field needs enough data and a sensible penalty (lab part C).
- Check the uncertainty. Ensemble spread is useful if it covers the error at the stated rate (lab part D).
- Check the range. Surrogates and learned solvers are validated only where they were trained (lab part E).
Visual summary
Schematic
Assumptions
- Schematic: no quantitative claim. Stages follow Equation 2, Equation 5 and the scaling of Equation 6.
How experts think
Before trusting a physics-informed result, ask:
- Which equation, with which assumptions? One speed or a speed field, isotropic or with fibres, eikonal or a reaction–diffusion model (Sahli Costabal et al. 2020; Herrero Martin et al. 2022).
- How were the terms weighted? \(\lambda\) and any penalties change the answer (Equation 2; demo m42-d1).
- Where were the data? Physics extrapolates from them; far from data, check the uncertainty (Equation 5).
- What was the ground truth? Simulation, optical mapping or clinical maps; method studies report method errors, not patient outcomes.
- How fast, on what hardware? Training times range from minutes to hours (Herrero Martin et al. 2022; Magaña et al. 2025); a clinical workflow needs answers within the procedure.
One sentence to keep: a physics prior is a strong assumption; it helps where it is right and hides what it does not describe.
Cheat sheet
| Quantity | Result |
|---|---|
| Eikonal residual (Equation 1) | \(r = s\lvert\nabla T\rvert - 1\) |
| Physics-informed loss (Equation 2) | \(\frac{1}{N_d}\sum(T(\mathbf x_i) - t_i)^2 + \frac{\lambda}{N_c}\sum r(\mathbf x_c)^2\) |
| Radial-basis map (Equation 3) | \(T = a_0 + \sum a_k e^{-\lvert\mathbf x - \mathbf c_k\rvert^2/2h^2}\), gradient in closed form |
| Levenberg–Marquardt (Equation 4) | \((J^\top J + \mu\,\mathrm{diag}\,J^\top J)\boldsymbol\delta = -J^\top\mathbf r\) |
| Ensemble (Equation 5) | Mean and sample standard deviation across members |
| Slowness scaling (Equation 6) | \(T(k s) = k\,T(s)\) |
Studies in this module
| Study | What was done | Evidence |
|---|---|---|
| Sahli Costabal et al. (2020) | PINN activation and velocity maps, uncertainty, active learning | Synthetic benchmark and simulated left atrium |
| Herrero Martin et al. (2022) | Tissue parameters from action potentials | Simulation and ex vivo optical mapping |
| Magaña et al. (2025) | Fibre orientation with an ensemble of PINNs | Method study, eight atrial anatomies |
| Raissi et al. (2020) | Velocity and pressure from flow visualizations | Physical and biomedical examples |
Rules of thumb
- Scale the data and physics terms so that \(\lambda\) means something; report it.
- Pair every map with an uncertainty map, and check its coverage.
- Keep surrogates inside the parameter range they were trained on.
Interview questions
Try each question before you open its model answer. In a real interview, say which assumptions you are making.
Q1. Write the loss of a physics-informed fit of an activation map and explain each term.
Model answer
The loss is \(L = \frac{1}{N_d}\sum (T(\mathbf x_i) - t_i)^2 + \frac{\lambda}{N_c}\sum (s\lvert\nabla T\rvert - 1)^2\), as in Equation 2 and Equation 1. The first term fits the measured times; the second makes the map behave like a front moving at slowness \(s\) at collocation points, which need no measurements; \(\lambda\) balances them. Published versions add penalties, such as total variation on velocity (Sahli Costabal et al. 2020).
Q2. Why can the physics term help most at intermediate data density, and not at very low density?
Model answer
With very few points, many fronts (different sources and speeds) fit the data equally well, so the physics cannot decide among them. With a moderate number, the data pin down the source and the physics fills the gaps and controls extrapolation. With dense data, the data alone already fix the map. Lab part B shows the middle case clearly.
Q3. How can a physics term make a conduction-velocity map worse?
Model answer
If the equation assumes something false, such as one speed everywhere, the fit is pushed towards it. In lab part C the map error fell, but the speed inside a slow region moved towards the surrounding value. Use a speed field with a penalty that allows jumps, and check against data-only estimates.
Q4. Why fit radial-basis coefficients with Levenberg–Marquardt rather than plain least squares?
Model answer
The data term is linear in the coefficients but the eikonal residual is not, because of \(\lvert\nabla T\rvert\) (Equation 1). Levenberg–Marquardt solves nonlinear least squares by repeated linearization (Equation 4), with damping that keeps steps safe. With \(\lambda = 0\) it reduces to one least-squares solve.
Q5. What is the advantage of a radial-basis representation over a neural network here, and the cost?
Model answer
Gradients are analytic (Equation 3), the problem is small, and a second-order method converges in tens of iterations without a deep-learning library. The cost is flexibility: a fixed basis width limits how sharp a feature, such as a kink near the source or a slow-region boundary, the map can represent, and the number of basis functions grows quickly in three dimensions.
Q6. How does an ensemble give uncertainty, and how would you check it?
Model answer
Members trained with different noise, starts and random priors agree where data constrain them and disagree elsewhere; their spread is the uncertainty (Equation 5). Check it: rank correlation with the actual error, and coverage, the share of points whose error lies within, say, two spreads (lab part D).
Q7. Why are randomized prior functions added to ensemble members?
Model answer
Without them, members trained on the same data with small noise can agree even far from the data, underestimating uncertainty. A fixed random function added to each member makes them differ where the data cannot pull them together (Sahli Costabal et al. 2020); its scale is a modelling choice (demo m42-d2).
Q8. Where would you place the next mapping point, given an ensemble?
Model answer
Where the predictive uncertainty is largest, if the goal is a uniformly good map; Sahli Costabal and colleagues (Sahli Costabal et al. 2020) placed it at the maximum of the predictive entropy. If the goal is a specific feature, such as the earliest site, use a criterion aimed at it, like expected improvement in m41. The clinician decides where the catheter goes.
Q9. Why write a surrogate of the eikonal model in terms of slowness?
Model answer
Along a fixed path, activation time is a sum of length times slowness, so it is linear in slowness, and scaling all slowness scales all times (Equation 6). A surrogate built on slowness features matches that structure and needs fewer training runs.
Q10. A surrogate is accurate to 0.1 ms in testing. Can you use it for any patient?
Model answer
Only for parameters inside its training range and for the same model settings. Outside, errors can grow by orders of magnitude (lab part E). Record the range with the surrogate and check new cases against the full model.
Q11. EP-PINNs took up to 16 hours to train on a GPU for some problems. What does that imply?
Model answer
That some PINN problems are still too slow for use during a procedure (Herrero Martin et al. 2022). Options are simpler models (eikonal rather than reaction–diffusion), smaller representations, pretrained surrogates, or running before the procedure. Methods that report minutes, such as the fibre ensemble in under 7 minutes (Magaña et al. 2025), are closer to workflow time.
Q12. What evidence would you want before a PINN-based velocity map changes a clinical decision?
Model answer
Validation against independent ground truth in patients (for example, high-density maps or other modalities), calibration of its uncertainty, robustness to catheter position error and to the physics assumed, and then a study of the decision itself (m45). The method studies in this module are earlier steps.
Code lab
The lab fits activation maps with and without the eikonal term, shows where physics helps and where it misleads, estimates uncertainty with an ensemble, and builds a surrogate of the eikonal model for calibration. It runs in under a minute and needs no deep-learning library.
| Part | What you do | Data |
|---|---|---|
| A | Radial-basis maps: analytic gradients and the eikonal residual (Equation 3, Equation 1) | synthetic |
| B | Homogeneous tissue: data-only against physics-informed fits (Equation 2, Equation 4) | synthetic |
| C | A slow region: lower map error, biased speed estimate | synthetic |
| D | Ensemble uncertainty against the actual error (Equation 5) | synthetic |
| E | A surrogate for calibration, inside and outside its range (Equation 6) | synthetic |
| F | Optional: a physics-informed neural network in PyTorch | synthetic |
- Python notebook: labs/python/m42_lab.ipynb. Run it from the course repository after
pip install -r requirements.txt, or open it in Google Colab. - Data: synthetic, from the course’s eikonal solver (m30). No real data are needed to show the methods; clinical activation maps with independent ground truth are not openly available to us.
- Part F runs only if PyTorch is installed. NVIDIA’s open-source PhysicsNeMo framework is aimed at larger multi-physics problems than this lab (NVIDIA PhysicsNeMo Team 2026).
Each part ends with checks: lines that pass with the code as given. If you change something and a check fails, that is information, not an error to hide.
Self-check
Short checks you can do in your head. Open each answer after you have tried it.
S1. A map has \(\lvert\nabla T\rvert = 2\) ms/mm where the assumed speed is 1 m/s. What is the eikonal residual?
Answer
\(s = 1\) ms/mm, so \(r = 1 \times 2 - 1 = 1\) (Equation 1): the map is twice as steep as the speed allows.
S2. With \(\lambda = 0\), what does the physics-informed fit become?
Answer
An ordinary least-squares fit of the map to the data (Equation 2); the speed is not estimated.
S3. Every slowness in a model is doubled. What happens to the activation times?
Answer
They double (Equation 6).
S4. Five ensemble members predict 10, 12, 11, 9 and 13 ms at a point. Mean and sample SD?
Answer
Mean 11 ms; SD \(\sqrt{(1+1+0+4+4)/4} = \sqrt{2.5} \approx 1.6\) ms (Equation 5).
S5. In Levenberg–Marquardt, what happens to the step when the damping \(\mu\) is very large?
Answer
It becomes a small step along the negative gradient, scaled per parameter (Equation 4): safe but slow. Small \(\mu\) gives the Gauss–Newton step.
S6. True or false: a physics-informed fit is always more accurate than a data-only fit.
Answer
False. It helps when the physics is right and the data are moderately sparse; with very few points or a wrong assumption (one speed in heterogeneous tissue) it can be no better or misleading (lab parts B and C).
Literature figures
These figures are worth looking at alongside this module. We link to them instead of copying them: some licenses do not allow reuse here, and others we could not confirm. Each entry says what to look for and where this module explains it.
- Two networks, one loss. Sahli Costabal and colleagues, Figure 1, the two networks that represent activation time and conduction velocity and the loss that couples them [Sahli Costabal et al. (2020); open access]. Compare with Equation 2.
- Network architectures and training schemes. Herrero Martin and colleagues, Figure 2, and Figure 3 for the effect of the number of sampled points and of noise on parameter estimates [Herrero Martin et al. (2022); free full text]. Compare with lab part B.
- Drug effects in optical mapping. The same paper, Figure 9, parameters estimated from optical mapping data under ion-channel blockers [Herrero Martin et al. (2022); free full text]. This module: clinical correlate.
Further reading
- Physics-informed learning. Raissi et al. (2017), Raissi et al. (2020); NVIDIA PhysicsNeMo (NVIDIA PhysicsNeMo Team 2026).
- In electrophysiology. Sahli Costabal et al. (2020), Herrero Martin et al. (2022), Magaña et al. (2025).
- Digital twins. Corral-Acero et al. (2020), Gillette et al. (2021) (m33).
- AI competency areas. Machine learning (physics-informed networks and surrogates). See the AI competency map.