Pathology Foundation Models are Scanner Sensitive: Benchmark and Mitigation with Contrastive ScanGen Loss
Gianluca Carloni, Biagio Brattoli 0, Seongho Keum, Jongchan Park, Taebum Lee, Chang Ho Ahn, Sergio Pereira · 2025
Read Pathology Foundation Models are Scanner Sensitive: Benchmark and Mitigation with Contrastive ScanGen Loss by Gianluca Carloni, Biagio Brattoli 0, Seongho Keum, Jongchan Park, Taebum Lee, Chang Ho Ahn, Sergio Pereira (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2507-22092.txt.
Introduction
Gianluca Carloni and co-authors show that even large pathology models bend with the scanner that took the picture, in a 2025 paper. Digital pathology reads whole slide images with deep learning, but each scanner brand leaves its own marks. The same tissue can then earn different outputs, which erodes trust in clinics. New foundation models promised better robustness across settings.
The team benchmarked such models on slides from many scanners and still found bias. Their fix, ScanGen, is a training loss used while fine-tuning that pushes the model to ignore scanner traits. On a lung cancer task, predicting a gene change from stained slides, the fix improved cross-scanner stability while holding or raising accuracy.
Catalog record
| CREATOR | Gianluca Carloni, Biagio Brattoli 0, Seongho Keum, Jongchan Park, Taebum Lee, Chang Ho Ahn, Sergio Pereira |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 20 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2507-22092
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Pathology Foundation Models are Scanner Sensitive: Benchmark and Mitigation with Contrastive ScanGen Loss Gianluca Carloni, Biagio Brattoli 0, Seongho Keum, Jongchan Park, Taebum Lee, Chang Ho Ahn, Sergio Pereira Abstract Computational pathology (CPath) has shown great potential in mining actionable insights from Whole Slide Images (WSIs). Deep Learning (DL) has been at the center of modern CPath, and while it delivers unprecedented performance, it is also known that DL may be affected by irrelevant details, such as those introduced during scanning by different commercially available scanners. This may lead to scanner bias , where the model outputs for the same tissue acquired by different scanners may vary. In turn, it hinders the trust of clinicians in CPath-based tools and their deployment in real-world clinical practices. Recent pathology Foundation Models (FMs) promise to provide better domain generalization capabilities. In this paper, we benchmark FMs using a multi-scanner dataset and show that FMs still suffer from scanner bias. Following this observation, we propose ScanGen , a contrastive loss function applied during task-specific fine-tuning that mitigates scanner bias, thereby enhancing the models’ robustness to scanner variations. Our approach is applied to the Multiple Instance Learning task of Epidermal Growth Factor Receptor (EGFR) mutation prediction from H&E-stained WSIs in lung cancer. We observe that ScanGen notably enhances the ability to generalize across scanners, while retaining or improving the performance of EGFR mutation prediction. 1 Introduction Figure 1: Left: Existing pathology Foundation Models suffer from scanner bias. We show a 2D projection of WSIs (dots) from 4 scanners (colors) using UMAP based on H-Optimus-0 embeddings before and after ScanGen . "SLIDE \xrightarrow{} " indicates the slides of the same specimen from different scanners. Right: ScanGen improves both generalization and performance. Digital pathology is catalyzing a new era in the field of histopathology by transforming how clinicians interact with and analyze tissue samples. Furthermore, it enables computational pathology (CPath) over whole slide images (WSIs), a key component for deriving novel and quantitative insights from WSIs. This brings new capabilities to clinical practice, such as prediction of genetic alterations [ 11 , 22 ] , tumor micro-environment analysis [ 16 ] , or survival prediction [ 18 ] . Digital pathology requires the digitization of tissue slides into WSIs using slide scanners. While these scanners must capture the underlying tissue accurately, different devices may result in differences in image characteristics [ 5 ] . For example, differences in optical systems may impact image sharpness, variations in light sources can affect contrast and introduce artifacts, and proprietary software (e.g. for data compression) can affect image processing. To implement CPath-based tools in clinical settings, it is crucial to address the constraints specific to different scanners. Since different scanners are used worldwide, with some being predominant in certain regions (e.g., Hamamatsu in Asia [ 17 ] ), any performance issues associated with a particular scanner could lead to regional disparities in patient care. Recently, the introduction of foundation models (FMs) provides a base upon which CPath tools are developed. However, while FMs promise better generalization capabilities, they may still encode several biases, such as the slide identity [ 24 ] and hospital environments [ 9 ] . The present paper delves into another crucial aspect of CPath, the digital scanners used during image acquisition, offering empirical evidence that FMs are sensitive to the type of digital scanner employed for reading tissue specimens. Since CPath FMs are typically used as frozen extractors with no access to the input images, alleviating this bias with traditional stain normalization methods (e.g., Reinhard [ 19 ] , Macenko [ 14 ] ) or DL ones (e.g., StainGAN [ 21 ] , StainNet [ 10 ] ) is not trivial. Scanner bias results in weakened generalization capabilities for FM-based CPath models, posing challenges in their broader application. In particular, scanner bias means that the model output will change based on which scanner has been used to read the specimen despite the content being the same, which can significantly hinder trust in CPath-based tools and, consequently, slower clinical adoption. To address this shortcoming, we propose ScanGen , a contrastive loss function that mitigates scanner bias, thereby enhancing the model’s robustness across different scanners. Our evaluation involves testing various state-of-the-art FMs using a benchmark set that comprises images of the same specimen captured from six commercially available scanners at 40 \times magnification and one scanner at 20 \times magnification. Additionally, our approach is applied to the task of detecting Epidermal Growth Factor Receptor (EGFR) mutations in lung cancer, a prevalent and clinically significant endeavor in the CPath space [ 2 , 25 ] . In summary, this paper introduces three contributions: 1) a contrastive loss function aimed at reducing scanner bias in Multiple Instance Learning (MIL), 2) an assessment of FMs in relation to scanner generalization, and 3) application of the proposed method to EGFR mutation prediction in lung cancer, a clinically relevant task. The results demonstrate promising improvements in predictive performance and generalization (Fig. 1 ), underscoring the potential of our methodologies in clinical settings. 2 Method Figure 2: Our method. Left: Data are projected to a new embedding space where scanner bias is removed via our contrastive ScanGen loss. ScanGen is trained on paired WSIs of the same specimen acquired with different scanners and can be easily integrated with any existing method by acting before the MIL aggregator. Right: ScanGen attracts the representations of same-specimen different-scanner pairs, while repelling same-scanner different-specimen ones. This favors specimen-based clusters to scanner-based ones, thus fostering generalization across scanners in downstream applications. 2.1 Scanner Generalization Metric for MIL Due to the extremely large size of WSIs, MIL is usually employed for classification or regression tasks. In MIL, WSIs are partitioned into P patches and the FM(\cdot) is used as a pretrained, frozen feature extractor to obtain an embedding vector x_{i}=FM(p_{i}) per each patch p_{i} . Finally, an aggregator function g(\cdot) combines all patches and a classifier f(\cdot) produces the final prediction (e.g., EGFR mutation) as \hat{y}=f(g(x_{1},\dots,x_{P})) . In this context, the scanner bias relates to how different two predictions \hat{y}^{s_{1}}_{m} and \hat{y}^{s_{2}}_{m} are from the same specimen m but different scanners s_{1} and s_{2} . For this reason, we measure the intensity of scanner bias as the average coefficient of variation (CoV) between predictions of the same specimen m across S multiple scanners, defined as \mathrm{CoV}=\frac{1}{M}\sum_{m=1}^{M}\left(\frac{\sigma\bigl(\hat{y}_{m}^{s_{1}},\hat{y}_{m}^{s_{2}},\dots,\hat{y}_{m}^{s_{S}}\bigr)}{\left|\mu\bigl(\hat{y}_{m}^{s_{1}},\hat{y}_{m}^{s_{2}},\dots,\hat{y}_{m}^{s_{S}}\bigr)\right|}\right), (1) with M number of specimens, where \sigma and \mu are, respectively, the standard deviation and average across the logit predictions of the same specimen acquired with different scanner hardware. CoV is more appropriate than simple standard deviation because it allows for meaningful comparisons across sources with different scales. Lower \mathrm{CoV} means better agreement in predictions, indicating the model is less scanner-sensitive. 2.2 Proposed Framework and ScanGen Loss As Figure 2 illustrates, to reduce the scanner bias in the embedding space, we first map the patch embeddings x to a new scanner-unbiased embedding space using a projection network h(\cdot) , which is trained as follows. Given two specimens m and n and two scanners s_{1} and s_{2} , we rework the contrastive loss function [ 7 ] and define our ScanGen loss as \mathcal{L}_{ScanGen}=(1-\alpha)\underbrace{\left(d(h(x_{m}^{s_{1}}),h(x_{m}^{s_{2}}))\right)^{2}}_{\text{$\mathcal{L}^{Attract}$}}+\alpha\underbrace{\left(\max(0,r-d(h(x_{m}^{s_{1}}),h(x_{n}^{s_{1}}))\right)^{2}}_{\text{$\mathcal{L}^{Repel}$}} (2) where d(a,b)=1-\frac{a\cdot b}{|a|\cdot|b|} is the cosine distance function, \mathcal{L}^{Attract} is