Multi-Site and Multi-Device Data: The Generalization Challenge
Why models trained on data from one scanner, hospital, or population often fail on another. Strategies for building generalizable datasets, including domain adaptation and harmonization.
The standard story of a medical AI project goes like this. A team collects data at their own institution, trains a model, tests it on held-out cases from the same institution and reports an AUC of 0.95. Then someone tries it at another hospital and gets 0.80.
Nothing was done wrong in the usual sense, and the test was fair as far as it went. It answered the question "how does this model do on more patients from here?", and the question the world cares about is how it does elsewhere. 1.6 What AI Cannot Do gives examples of the drop. This article is about what you can do about it while you are still assembling the dataset, which is the stage at which it can be fixed cheaply.
Why do site changes matter so much?
A radiologist who moves hospitals takes a week or two to adjust to the new images. A model has no such ability, and things a human barely notices can be large changes in the numbers.
First, the equipment. Scanner vendors differ in detectors, reconstruction algorithms and post-processing. A chest radiograph from one vendor has visibly different contrast and edge enhancement from another's. CT reconstruction kernels change the noise texture. MRI field strength and coil change everything. In ultrasound the machine, the probe and the operator all vary. In digital pathology the slide scanner and, even more, the lab's staining differ.
The protocols also change. Slice thickness, contrast timing, sequence parameters, patient positioning, portable or fixed. Two hospitals with identical scanners can produce different-looking studies.
Differences in the patients depend on location. Age, sex, ancestry and body habitus, and also how sick they are. A tertiary referral center sees advanced and unusual disease. A community screening program sees early disease and a great many normals. Prevalence differs, and so does the range of other conditions that the finding has to be told apart from.
The umbrella term for all of this is distribution shift, or domain shift. The clinical and fairness consequences are covered in 7.3 Generalization Across Devices, Sites, and Geographies.
The worst case: when the site predicts the label
Variation between sites is a detail that needs attention. Variation that lines up with the label will screw up your training.
Suppose your positive cases come mainly from the cancer center and your negatives from a community hospital. Every difference between the two hospitals' images is now a perfectly good predictor of cancer, and the model will find it, since that is far easier to learn than the disease. Your internal test set has the same arrangement, so the result looks excellent, but all you're really learning is how to guess what hospital a scan was taken at.
The study by John Zech and colleagues described in 1.6 found this in pneumonia detection. Marcus Badgeley and colleagues found it in hip fractures in 2019: their model predicted fracture from radiographs well, and much of its performance came from being able to tell which scanner had been used and from other variables to do with how the patient was handled, since fracture patients get imaged on different equipment and under different circumstances from routine outpatients. When they tested it on fracture and non-fracture cases matched on both the patient variables and the hospital process variables, the model did no better than chance (an AUC of 0.52). And in 2021 Alex DeGrave and colleagues took apart models for detecting COVID-19 on chest radiographs, many of which had been trained with positive films from one source and negative films from another, and showed that they relied on features such as text markers and patient positioning.
This is confounding, the same thing it is in epidemiology. Cross-tabulate the label against site, scanner model, year and care setting before training. If the positives and negatives don't come from the same places in similar proportions, fix the sampling.
Build the dataset for it
The single most effective thing you can do is Get more than one site into the training data. A model that has seen three vendors learns that vendor differences are not the disease. The gain from the second and third site is far larger than from making the first site bigger. If you can't get another site, get variety within yours. Most hospitals have more than one scanner model, and inpatient, outpatient and emergency pathways. Try to sample across all of them and across several years.
Also, keep the metadata. For every study, record the site, scanner manufacturer and model, software version, acquisition parameters and date. Most of this information is in the DICOM header, and de-identification tends to strip it out unless you tell it not to (see 2.7 De-Identification, Privacy, and Regulatory Compliance for Research Data). Without it you can't check for confounding, can't report performance by scanner, and can't diagnose a failure later.
Balance labels within sites. Each site should contribute both positives and negatives, in as similar a proportion as you can manage.
Make the labeling uniform. If sites labeled their own cases, have a sample relabeled centrally under one protocol and measure how far the sites disagree (see 2.3 Data Annotation and Labeling for Clinical AI).
Test it properly
Have at least one site that put nothing into training set in your test set.
A random split of pooled multi-site data doesn't do this. Every site is then on both sides, and the test measures performance on new patients from familiar sites. That is an internal test however many hospitals are in the pool.
With several sites, the thorough version is leave-one-site-out: train on all but one, test on the one left out, and rotate. The spread of results across the held-out sites is the best estimate you will get of what happens at a hospital you've never seen (see 4.6 Cross-Validation Strategies for Medical Data). Report each site's result, since an average can hide one site where the model fell over.
Report by scanner vendor and model as well. And if you have data from a later period than the training data, test on it. A model trained on 2018 to 2021 and tested on 2023 is facing a mild version of the same problem, since equipment and practice move on at a single site too.
Very few studies do this. In 2021 Eric Wu and colleagues examined the evidence behind 130 AI devices the FDA had authorized. For 93 of them, no multi-site evaluation was publicly reported, and 126 had been evaluated only on retrospective data. Meeting the standard puts your study ahead of a good share of products on the market. 5.4 Multi-Site External Validation covers the design of an external validation study.
Technical fixes, and how far to trust them
There are methods for reducing site differences after the fact. They help but they don't replace varied data.
Harmonization tries to remove the site effect from the data. For pathology, stain normalization adjusts every slide's colours toward a reference. For features measured from images, there is ComBat, a statistical method that came from genomics, where it was built to remove batch effects between labs, and that Jean-Philippe Fortin and colleagues adapted to multi-scanner brain imaging. For images themselves there are intensity standardization methods and, more ambitiously, networks that translate images from one scanner's style to another's. Harmonization has a known hazard: if the sites differ in their real patient mix, removing "the site effect" removes some biology with it. Image translation networks can also add or remove structures (see 2.8 Synthetic Data and Data Simulation).
Augmentation can simulate some scanner variation: contrast, noise, blur, resolution, stain colour. It is cheap and usually worth doing (see 2.5 Data Preprocessing and Augmentation).
Domain adaptation covers a family of training methods that push a model to perform on a new site, often using unlabeled images from it. Fine-tuning on a small labeled sample from the new site is the simplest and most reliable version, and it means the model needs a local calibration step at each site, which has regulatory consequences if the model is a product (see 6.8 Predetermined Change Control Plans).
Pretraining on large and varied collections tends to give models that travel better than those trained from scratch on one site's data.
Whatever combination is used, the proof is the same: performance on a site held out of everything.
When the data can't leave the building
The usual obstacle to multi-site data is not technical. Hospitals are reluctant to send patient data elsewhere, and each transfer needs ethics approval and a data sharing agreement that can take longer to negotiate than the model takes to build. Start that paperwork early. It is the slowest item in the plan.
Federated learning is the alternative for when data can't move. Each site trains the model on its own data behind its own firewall, and only the model updates are sent to a coordinator and combined. The approach was introduced by Brendan McMahan and colleagues at Google in 2017. In medicine the best-known demonstration is the EXAM study, published in 2021, in which twenty institutions around the world trained a model to predict the oxygen needs of COVID-19 patients from chest radiographs and clinical data without pooling any of it. The federated model did better at each site than that site's own model.
It solves the data-movement problem and keeps the others. Every site still has to prepare and label its data to a common protocol, nobody can inspect the pooled data for errors, and the engineering is considerable.
Public datasets are worth a look as well. They are a cheap source of images from other scanners and populations, and a reasonable external test set so long as you check how they were labeled and make sure none of the same patients are in your training data.
Key takeaways
- A model tested only on data from the sites it trained on has not been tested for generalization, however large the test set.
- Sites differ in equipment, protocol, patient mix and labeling practice. A model can be thrown by differences a clinician wouldn't notice.
- The dangerous case is when site or scanner is correlated with the label. Cross-tabulate before training and sample positives and negatives from the same sources.
- Data from a second and third site improves generalization more than a larger sample from the first.
- Keep scanner and site metadata through de-identification.
- Hold out at least one whole site for testing, use leave-one-site-out when you have several, and report results per site and per scanner.
- Harmonization, augmentation and domain adaptation reduce site effects without removing the need for varied data and an external test.
- Federated learning lets sites train a shared model without moving data, at a cost in engineering and visibility.
What to read next
- 2.7 De-Identification, Privacy, and Regulatory Compliance for Research Data: what has to happen before data leaves a site
- 4.6 Cross-Validation Strategies for Medical Data: grouping by patient and by site
- 5.4 Multi-Site External Validation: designing the external study
- 7.3 Generalization Across Devices, Sites, and Geographies: the consequences for fairness
- 8.6 Monitoring AI Performance in Production: watching for shift after deployment
This article is part of the AI in Clinical Research Knowledge Base.