Stain Normalisation, Foundation Encoders and Centre Shift: A Reproducible Cloud-Based Pipeline for Gigapixel Histopathology Analysis in Google Colab
Year: 2025
Type: article
Abstract: Background: Deep learning on whole slide images (WSIs) is usually developed on dedicated GPU servers with terabytes of local storage, and the preprocessing choices that shape the data a model sees are rarely reported in detail. Stain variation between laboratories is a known source of domain shift, but its effect on frozen foundation-model features has seldom been measured directly. Methods: We built a notebook-based pipeline that runs entirely in Google Colab with Google Drive as the only persistent store. Raw slides are downloaded in batches, segmented by Otsu thresholding of the saturation channel, tiled at twenty times magnification, filtered for blur by the variance of the Laplacian, stain-normalised and encoded once by a frozen encoder, after which only coordinates and features are kept. The pipeline was applied to 13,615 slides from CAMELYON16, CAMELYON17, TCGA-NSCLC, PANDA and BCNB. Three stain conditions (none, Macenko, Vahadane) and two encoders (CTransPath, UNI) were compared through linear probes and through downstream weakly supervised models under cross-validation and leave-one-centre-out evaluation. Results: Tiling produced 35.66 million patches, of which 4.1 per cent were removed as out of focus, leaving 34.2 million. Validation AUC was flat for minimum tissue fractions between 0.40 and 0.60. Vahadane normalisation raised the leave-one-centre-out AUC on CAMELYON17 from 0.874 to 0.911 and the worst centre from 0.829 to 0.889. A linear probe identified the source centre from unnormalised CTransPath features with 88.6 per cent accuracy, falling to 41.3 per cent after normalisation against a chance level of 20 per cent. UNI features improved downstream performance on all five datasets by 0.009 to 0.017. Features for both encoders occupied 122.6 GB, and the full model trained within the memory of a free T4 runtime. Conclusion: Careful preprocessing and stain normalisation remain necessary with foundation encoders, centre information persists after normalisation, and gigapixel pathology studies can be run reproducibly on hosted notebooks.
Author: Puneeta Rosmin , Dr.Ajay Agarwal
Language: English
Topic: AI in cancer detection
Subfield: Artificial Intelligence
Field: Computer Science
Domain: Physical Sciences
Open Access status: hybrid
OpenAlex ID: W7221378980
