Fast and Scalable Image Search For Histology

Chengkuan Chen, Ming Y. Lu, Drew F. K. Williamson, Tiffany Chen, Andrew J. Schaumberg, Faisal Mahmood · DOI

Abstract

The expanding adoption of digital pathology has enabled the curation of large repositories of histology whole slide images (WSIs), which contain a wealth of information. Similar pathology image search offers the opportunity to comb through large historical repositories of gigapixel WSIs to identify cases with similar morphological features and can be particularly useful for diagnosing rare diseases, identifying similar cases for predicting prognosis, treatment outcomes, and potential clinical trial success. A critical challenge in developing a WSI search and retrieval system is scalability, which is uniquely challenging given the need to search a growing number of slides that each can consist of billions of pixels and are several gigabytes in size. Such systems are typically slow and retrieval speed often scales with the size of the repository they search through, making their clinical adoption tedious and are not feasible for repositories that are constantly growing. Here we present Fast Image Search for Histopathology (FISH), a histology image search pipeline that is infinitely scalable and achieves constant search speed that is independent of the image database size while being interpretable and without requiring detailed annotations. FISH uses self-supervised deep learning to encode meaningful representations from WSIs and a Van Emde Boas tree for fast search, followed by an uncertainty-based ranking algorithm to retrieve similar WSIs. We evaluated FISH on multiple tasks and datasets with over 22,000 patient cases spanning 56 disease subtypes. We additionally demonstrate that FISH can be used to assist with the diagnosis of rare cancer types where sufficient cases may not be available to train traditional supervised deep models. FISH is available as an easy-to-use, open-source software package (https://github.com/mahmoodlab/FISH).

Introduction

Digital pathology has revolutionized the field by creating massive repositories of Whole Slide Images (WSIs). However, these repositories present a significant "big data" challenge: a single WSI can contain billions of pixels and occupy several gigabytes of storage. Searching through hundreds of thousands of such images to find morphologically similar cases is computationally intensive.

Existing search tools typically exhibit search speeds that scale linearly ($O(n)$) or log-linearly ($O(n \log n)$) with the number of slides in the database. As repositories grow, these systems become too slow for real-time clinical use. Furthermore, many current systems rely on expert-annotated "Regions of Interest" (ROIs) for training, which is a significant bottleneck for scalability. To address these issues, we developed FISH (Fast Image Search for Histopathology), a pipeline designed for infinite scalability and constant-time search speed.

Methods

The FISH pipeline is divided into four distinct stages designed to transform gigapixel images into a searchable, indexed format.

The complete FISH pipeline, illustrating the transition from whole slide images to searchable mosaics and final slide retrieval.

1. Mosaic Extraction

To avoid processing every pixel, FISH extracts a representative "mosaic" of patches from each slide. This is achieved through a two-stage K-means clustering process. First, patches are clustered based on their RGB histograms to capture color variety, followed by spatial clustering to ensure the selected patches are representative of the entire tissue area.

2. Feature Encoding and Indexing

FISH utilizes a Vector Quantized-Variational AutoEncoder (VQ-VAE), a self-supervised model that learns to represent complex image patches as discrete "latent codes." This effectively converts an image patch into a specific integer index from a learned codebook.

The Mosaic Indexing stage, highlighting the use of VQ-VAE for discrete latent code generation and the Van Emde Boas tree for constant-time indexing.

3. The Van Emde Boas (vEB) Tree

The core of FISH's scalability is the Van Emde Boas (vEB) tree. By representing slides as sets of integers derived from the VQ-VAE, FISH stores them in this specialized data structure. A vEB tree provides a search complexity of $O(\log \log M)$, where $M$ is the maximum possible integer value. Because $M$ is fixed by the model architecture, the search time remains constant ($O(1)$) regardless of the number of slides in the database.

4. Uncertainty-Based Ranking

To refine search results, FISH employs a ranking algorithm that accounts for the entropy (uncertainty) of retrieved matches. This ensures that rare, highly specific morphological features are prioritized over common, non-specific tissue patterns.

Experimental Results

We evaluated FISH using a massive dataset of over 22,000 patient cases spanning 56 disease subtypes, including data from The Cancer Genome Atlas (TCGA), the Clinical Proteomic Tumor Analysis Consortium (CPTAC), and Brigham and Women’s Hospital (BWH).

  • Search Speed and Scalability: FISH demonstrated remarkable efficiency, performing 15x faster than previous state-of-the-art systems like Yottixel on a database of ~11,000 slides. Crucially, while other systems slowed as the database grew, FISH’s query speed remained constant from 500 to over 11,000 slides.
  • Retrieval Accuracy: FISH achieved a macro-average majority top-5 accuracy (mMV@5) of 62.92% across the BWH cohort. On a specialized rare-type dataset, it achieved 69.15% accuracy, demonstrating its utility in cases where traditional supervised models often fail.
  • Patch-Level Performance: On the Kather100k benchmark, FISH achieved 98.09% accuracy for patch-level retrieval.

Discussion and Conclusion

FISH represents a significant leap forward in histology image retrieval. By utilizing self-supervised learning, it eliminates the need for manual annotations, making it easily deployable across different institutions. The use of vEB trees ensures that the system remains responsive even as repositories grow to millions of slides.

Beyond speed, FISH offers interpretability; it can highlight the specific regions in both the query and retrieved slides that led to a match, providing pathologists with verifiable evidence. Future work will focus on improving index expressiveness and refining the semantic relevance of the indexing system to further align search results with clinical and biological significance.

Summary updated

BibTeX
@misc{chen2021fast,
  author = {Chengkuan Chen and Ming Y. Lu and Drew F. K. Williamson and Tiffany Chen and Andrew J. Schaumberg and Faisal Mahmood},
  title = {{Fast and Scalable Image Search For Histology}},
  year = {2021},
  eprint = {2107.13587},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2107.13587},
}
Figure