Lorenzo Olmo Marchal

A Modular Framework for Preprocessing and Interpretable Multi-Instance Learning in Cancer Whole Slide Image Analysis

M.S. Thesis by Lorenzo Olmo Marchal | University of California San Diego, 2025

Advisor: Prof. Ludmil B. Alexandrov | Alexandrov Lab

Abstract

Computational pathology has emerged as a rapidly advancing subspecialty focused on the quantitative, large-scale analysis of pathological data like Whole Slide Images (WSIs). As high-resolution digitized representations of histology slides, WSIs contain diagnostically relevant features that can be leveraged by computational methods such as deep learning. This thesis addresses significant challenges in preprocessing and model interpretability within computational pathology. The core contributions are twofold: first, the development of SlideLab, a novel and robust preprocessing module designed to optimize the creation of high-quality WSI datasets; second, the introduction of a new interpretability method, Polarized Attentional Certainty (PAC), with an exploration of its applications in attention-based models to enhance the transparency and trustworthiness of AI systems in pathology.

Project Highlights

Project Analysis 🧠

This thesis effectively tackles two of the most significant hurdles in computational pathology: the lack of standardized preprocessing and the interpretability of "black box" AI models. The project is logically divided into two main contributions:

  • SlideLab (The Preprocessing Framework): A modular and comprehensive solution to the rigid and irreproducible nature of existing tools. It addresses key WSI challenges like computational cost, stain variability, and artifacts through a sophisticated, GPU-accelerated architecture.
  • Polarized Attentional Certainty (PAC) (The Interpretability Method): An intelligent approach to address clinical trust in AI. By combining a model's attention (importance) and probability (certainty), PAC creates a robust metric to validate that models are learning biologically relevant features.

Key Achievements 🏆

  • Development of a Novel and Complete Tool: Built a functional, end-to-end software pipeline, `SlideLab`, a significant engineering accomplishment.
  • Superior Performance Through Benchmarking: Rigorously tested `SlideLab` against five other state-of-the-art pipelines, achieving the highest Dice score (0.741) for tissue segmentation.
  • Improved Downstream Model Performance: Demonstrated that better preprocessing leads to better science, as the model trained on `SlideLab`-processed data outperformed others.
  • Innovation in Model Interpretability: Proposed PAC as a new method tailored to the specific challenges of multi-instance learning in pathology.
  • Validation with Real-World Case Studies: Successfully applied PAC to clinically relevant problems in colorectal cancer and leukemia, demonstrating its versatility.

Summary of Results 📊

  • SlideLab is Quantifiably Better: The framework produces higher-quality data, evidenced by superior Dice scores and improved downstream model performance.
  • PAC Provides Deeper Biological Insight: Case studies in MSI and B-ALL demonstrated that PAC can validate a model's reasoning by correctly identifying biologically and clinically relevant features.

Thesis Presentation

Thesis Infographic

A New Era in Computational Pathology

  • The Challenge with Whole Slide Images (WSIs)
  • Solution 1: SlideLab - A Flexible Preprocessing Pipeline
  • SlideLab Outperforms Existing Tools
  • Solution 2: Polarized Attentional Certainty (PAC)
  • PAC in Action: Real-World Case Studies

Thesis Document

Read the full thesis for a detailed understanding of the research, methodology, and findings.

Download Thesis PDF

Article in Preparation (Draft)

A research article based on this thesis is currently in preparation. A link to the publication will be available here soon.

Download Article Draft

Project Code: SlideLab

SlideLab Workflow

The complete source code for the SlideLab preprocessing pipeline is available on GitHub. Explore the repository to understand the implementation details and contribute to the project.

View on GitHub

SlideLab Tutorial

Installation

First, clone the repository and navigate into the directory:

git clone https://github.com/lolmomarchal/SlideLab.git
cd SlideLab

To install the required dependencies, create and activate the Conda environment:

conda env create -f environment.yml
conda activate slidelab

Usage

Below is an example command to run the preprocessing pipeline:

python SlidePreprocessing.py -i /path/to/input/ -o /path/to/output/ \
-s 512 -m 40 --remove_blurry_tiles --normalize_staining --encode \
-th 0.8 -bh 0.02 --device cuda --batch_size 256

Arguments

The pipeline behavior can be customized with the following arguments:

Argument Description Default
Input/Output (Required)
-i, --input_pathPath to the input WSI file(s)None
-o, --output_pathPath to save the output tilesNone
Tile Customization
-s, --desired_sizeDesired size of tiles in pixels256
-m, --desired_magnificationDesired magnification level (e.g., 20)20
-ov, --overlapFactor of overlap between tiles (1 = no overlap)1
Preprocessing Options
-rb, --remove_blurry_tilesRemove blurry tiles using a Laplacian filterFalse
-n, --normalize_stainingNormalize staining of the tilesFalse
-e, --encodeEncode tiles into an .h5 fileFalse

License

MIT License

Copyright (c) 2025 Lorenzo Olmo Marchal

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contact

For questions or inquiries, please contact Lorenzo Olmo Marchal at aolmomarchal@ucsd.edu or connect on LinkedIn.

References

  1. M. Macenko et al., "A method for normalizing histology slides for quantitative analysis," 2009 IEEE International Symposium on Biomedical Imaging: From Nano to Macro, Boston, MA, USA, 2009, pp. 1107-1110, doi: 10.1109/ISBI.2009.5193250.
  2. Barbano, C. A., & Pedersen, A. (2022, August). EIDOSLAB/torchstain: v1.2.0-stable (Version v1.2.0-stable) [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.6979540
  3. Chen, R.J., Ding, T., Lu, M.Y., Williamson, D.F.K., et al. Towards a general-purpose foundation model for computational pathology. Nat Med (2024). https://doi.org/10.1038/s41591-024-02857-3
  4. B. A. Schreiber, J. Denholm, F. Jaeckle, M. J. Arends, K. M. Branson, C.-B.Schönlieb, and E. J. Soilleux. Bang and the artefacts are gone! Rapid artefact removal and tissue segmentation in haematoxylin and eosin stained biopsies, 2023. URL http://arxiv.org/abs/2308.13304.