The Guyot algorithm (2012), explained
What it is: the Guyot, Ades, Ouwens & Welton (2012) algorithm reconstructs individual patient data from two inputs: the digitised coordinates of a Kaplan–Meier curve and the published numbers at risk. It is the standard method for creating pseudo-IPD in meta-analyses and HTA submissions. OpenAlex counts about 2,550 citations.
Used for: reconstructing IPD from a figure, survival extrapolation and MAIC. Tools: IPDfromKM and alternatives.
Inputs
- Digitised step points (tk, Sk) along the curve, starting at (0, 1).
- Times ti of the numbers-at-risk table and the counts ni.
- Optionally, the total number of events, which fixes the final interval.
The algorithm, step by step
- Split the curve into intervals at the at-risk table times. Each interval i runs from ti to ti+1 and contains the digitised points in between.
- First guess of censorings: nci = round(ni × S(ti+1)/S(ti) − ni+1).
- Distribute censorings evenly across the interval (the key assumption), giving the censorings between consecutive digitised points.
- Derive events at each point so that the KM estimate reproduces the digitised drop: dk = round(n̂k × (1 − Sk/Ŝlast)), then update the number at risk n̂k+1 = n̂k − dk − ck.
- Adjust and repeat: if the implied n̂ at ti+1 differs from the published ni+1, shift the censoring count by the difference and recompute until they agree.
- Final interval: use the average censoring rate from earlier intervals, or adjust censoring so the total events match the reported count.
- Write out IPD: events at the digitised step times, censorings at the midpoints between points, and anyone still at risk censored at the last time.
Worked example
Digitised curve: (0, 1.00), (2, 0.92), (4, 0.85), (6, 0.85), (8, 0.76), (10, 0.70), (12, 0.70). At risk: 100 at month 0, 72 at month 6, 48 at month 12.
| Interval | First guess of censorings | After adjusting | Events | Check |
|---|---|---|---|---|
| 0–6 | round(100 × 0.85/1.00 − 72) = 13 | 14 | 14 | 100 − 14 − 14 = 72 |
| 6–12 | round(72 × 0.70/0.85 − 48) = 11 | 12 | 12 | 72 − 12 − 12 = 48 |
Reconstructed curve: 0.916, 0.849, 0.761, 0.695, against 0.92, 0.85, 0.76, 0.70. The 48 still at risk at month 12 are censored there.
Code
In R
The IPDfromKM package (Liu et al. 2021) implements a modified version of the algorithm on coordinates you have already digitised. reconstructKM is another option.
library(IPDfromKM)
pts <- data.frame(time = c(0, 2, 4, 6, 8, 10, 12),
surv = c(100, 92, 85, 85, 76, 70, 70))
pre <- preprocess(dat = pts, trisk = c(0, 6, 12), nrisk = c(100, 72, 48),
maxy = 100)
est <- getIPD(prep = pre, armID = 1, tot.events = NULL)
head(est$IPD) # time, status, treat
est$precision # how closely it reproduces your curve
On these points it reports a maximum error of 0.005 and returns 24 events, where the original steps above give 26, because it is a modified version. Run with IPDfromKM 0.1.10 in R 4.5.1.
In Python
A teaching version. On the worked example it gives the same rows as the port we run in production. It has no guards for degenerate input.
import numpy as np
def guyot(t, S, tr, nr):
t, S = np.asarray(t, float), np.asarray(S, float)
# the first and last curve point of each at-risk interval
lo = [int(np.searchsorted(t, x)) for x in tr]
hi = [l - 1 for l in lo[1:]] + [len(t) - 1]
# events and censorings at each point
d, c = np.zeros(len(t), int), np.zeros(len(t), int)
n_hat, km = np.zeros(len(t) + 1), np.ones(len(t))
last = 0
def spread(i, m, end): # step 3: censor m patients evenly over the interval
c[lo[i]:hi[i] + 1] = 0
for j in range(1, m + 1):
c[np.searchsorted(t, t[lo[i]] + j * (end - t[lo[i]]) / (m + 1)) - 1] += 1
def walk(i): # step 4: events that reproduce each drop in the curve
nonlocal last
n_hat[lo[i]] = nr[i]
for k in range(lo[i], hi[i] + 1):
if k > 0 and n_hat[k] > 0 and km[last] > 0:
d[k] = min(round(n_hat[k] * (1 - S[k] / km[last])), n_hat[k])
km[k] = km[last] * (1 - d[k] / n_hat[k])
n_hat[k + 1] = max(n_hat[k] - d[k] - c[k], 0)
if d[k]:
last = k
censored = 0
for i in range(len(tr) - 1):
nxt, start = lo[i + 1], last
# step 2: first guess of the censorings
m = round(nr[i] * S[nxt] / S[lo[i]] - nr[i + 1])
# step 5: adjust until the next at-risk count matches
for _ in range(500):
last = start
spread(i, max(m, 0), t[nxt])
walk(i)
gap = int(n_hat[nxt]) - nr[i + 1]
m += gap
if gap == 0 or (gap < 0 and m <= 0):
break
censored += max(m, 0)
# step 6: the last interval takes the average censoring rate
i = len(tr) - 1
span = t[hi[i - 1]] - t[lo[0]] if i else 0
m = round(censored * (t[hi[i]] - t[lo[i]]) / span) if span > 0 else 0
spread(i, min(m, nr[i]), t[hi[i]])
walk(i)
# step 7: write out the IPD
rows = [(float(t[k]), 1) for k in range(len(t)) for _ in range(d[k])]
rows += [(float(t[k] + t[k + 1]) / 2, 0)
for k in range(len(t) - 1) for _ in range(c[k])]
rows += [(float(t[-1]), 0)] * max(nr[0] - len(rows), 0)
return sorted(rows)
rows = guyot([0, 2, 4, 6, 8, 10, 12], [1, .92, .85, .85, .76, .70, .70],
[0, 6, 12], [100, 72, 48])
print(len(rows), sum(e for _, e in rows)) # 100 patients, 26 events
In production, TrialCurve runs a port of the original algorithm with guards for degenerate input, and returns the IPD directly from an image.
Once you have IPD
library(survival)
# columns: panel, endpoint, population, arm, time, event
ipd <- read.csv("trialcurve_ipd.csv")
ipd <- subset(ipd, panel == "A") # a multi-panel figure: keep one panel
fit <- coxph(Surv(time, event) ~ arm, data = ipd)
summary(fit) # HR, 95% CI
survfit(Surv(time, event) ~ arm, data = ipd) # medians
In Python, lifelines gives the same (CoxPHFitter, KaplanMeierFitter). Other implementations of the reconstruction include survHE::digitise() in R and ipdfc in Stata.
Assumptions and limitations
- Censoring is uniform within each at-risk interval. This is fine when table times are close together and weaker when they are years apart.
- Events happen exactly at digitised step times, so digitisation precision limits event-time precision.
- With no at-risk table, only the initial N constrains the result and the tail becomes uncertain.
- With full information, Guyot et al. report a mean absolute error of 0.017 on the log hazard ratio, rising to 0.036 without numbers at risk and 0.198 with neither the table nor total events. Saluja et al. 2019 found Guyot the least biased of four methods (mean error 0.0094, CI −0.0012 to 0.020).
Newer methods
Recent work automates the digitisation step. SurvdigitizeR (2024) traces curves automatically. KM-GPT (2025) and KMGen (2026) combine language models with computer vision. RESOLVE-IPD (2025) extracts from vector PDFs and models censor marks. retroglyph (2026) is an R package that wraps a language model around pixel tracing. They all feed a Guyot-style reconstruction; the tool comparison summarises how they differ.
FAQ
Is the Guyot algorithm accepted by NICE and the EU JCA?
NICE DSU TSD 14 tells analysts to consider it when only summary statistics exist, and the EU practical guideline on direct and indirect comparisons names it. We know of no HTA guidance that sets a standard for digitisation, so report your method and compare with the published statistics.
Why do I get slightly different results each time I digitise by hand?
Click positions vary by a pixel or two, which moves step times and heights. A second person's extraction and comparison with published statistics are the usual safeguards.
Have a KM figure from a paper? Get its data in a minute.
Upload a figure