Home / Guides

The Guyot algorithm (2012), explained

Updated 2026-11-03 · TrialCurve

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

The algorithm, step by step

  1. 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.
  2. First guess of censorings: nci = round(ni × S(ti+1)/S(ti) − ni+1).
  3. Distribute censorings evenly across the interval (the key assumption), giving the censorings between consecutive digitised points.
  4. 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.
  5. 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.
  6. Final interval: use the average censoring rate from earlier intervals, or adjust censoring so the total events match the reported count.
  7. 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.

Digitised Kaplan-Meier points and the curve rebuilt from the reconstructed patients, with the numbers at risk below
IntervalFirst guess of censoringsAfter adjustingEventsCheck
0–6round(100 × 0.85/1.00 − 72) = 131414100 − 14 − 14 = 72
6–12round(72 × 0.70/0.85 − 48) = 11121272 − 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

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