Medical AI lab · Dice vs clinical error
Dice score vs clinical error: interactive demo
The Dice score measures the pixel overlap between a predicted segmentation and the ground truth, from 0 to 1. Because it counts pixels, it is dominated by the largest structure, so a model can reach a high Dice while missing a small lesion completely. This demo puts a large and a small synthetic lesion in one image and reports Dice, boundary distances and the number of lesions detected as you change the prediction.
These demos are illustrative. Every signal, image, patient and note is synthetic and fictional, generated and scored in your browser, and every number shown is computed from that synthetic data. They show general principles, not the performance of any real model, product or project, and none of them is a medical device.
Nothing is uploaded. No patient data is used.
Medical imaging AI / evaluation metrics
A high Dice. A missed lesion.
What this shows: Dice is dominated by the largest structure, so missing a small lesion barely moves it. A boundary distance and a simple count of lesions found tell a different story.
Change the prediction
Two true lesions: one about 68 mm across and one small. Shrink the small lesion below about 5 mm and even the 95th-percentile distance stops noticing that it was missed.
Ground truth and prediction
160 × 160 mm · 1 mm pixelsBlue: predicted and trueAmber: missedRed: predicted, not true
Synthetic data · illustrative · not a medical device
Segmentation and detection where small findings change the clinical decision: metastases, small nodules, early lesions. Report per-lesion detection and a boundary metric next to Dice, and choose metrics for the clinical question.
What this experiment models
Binary masks on a 160 × 160 grid with 1 mm pixels. The large true lesion is a slightly irregular disc; the prediction follows its boundary with a fixed wobble scaled by the roughness slider. Dice is 2|A∩B| / (|A| + |B|) over all pixels. Boundary distances are measured between the boundary pixels of the two masks in both directions; HD95 is the larger of the two directed 95th percentiles, and the maximum is the Hausdorff distance. A lesion counts as detected if any predicted pixel overlaps it.
The principle
How it works
The ground truth has one lesion about 68 mm across and one small lesion whose diameter you set. The prediction follows the large lesion with an adjustable boundary wobble, and either finds the small lesion or misses it. With an 8 mm lesion missed, Dice stays near 0.98, because the missing pixels are about 1% of the total.
Boundary metrics measure distance instead of overlap. For each boundary pixel of one mask, the demo finds the nearest boundary pixel of the other, in both directions. The Hausdorff distance is the largest of these distances, and HD95 is the larger of the two 95th percentiles, which ignores a few outlying pixels. A missed lesion far from the prediction produces large distances, but if its boundary is less than 5% of the total, HD95 ignores it too, while the maximum distance does not.
The clinical question is often simpler: was each lesion found? Counting detected lesions, and reporting per-lesion results next to Dice and a boundary metric, catches what a single overlap score hides. See medical imaging AI.
Medical AI lab
More demos
All six demos on one page: the medical AI labMedical imaging AI →