Estimate project
← All posts

Detecting breast cancer metastases in lymph nodes

A Deep Learning approach to detecting breast cancer metastases in lymph nodes automates the process, supports pathologists and pinpoints small tumors, while explainability methods make it possible to audit the model.

4 min read
Artificial IntelligenceMedical Domainmedtech

For localized breast cancer, the 5-year survival rate is excellent, at around 99%. For regional cancer, however, the 5-year survival rate falls to 86%, and for distant cancer to 31%. That is why an early, fast and precise diagnosis greatly improves a patient’s chances of survival.

Breast cancer most often spreads first to the lymph nodes in the axilla. The likelihood of metastases and death grows with the size of the breast cancer when it is detected and with the number of affected axillary lymph nodes. For this reason, lymph nodes are removed surgically and examined under a microscope. For pathologists, though, these diagnostic procedures are laborious and slow. Above all, small metastases are hard to spot and are sometimes overlooked.

AI can support pathologists by pointing out tumor regions in human tissue on whole slide images (WSI). This makes tumor detection quicker and more precise, which in turn raises the survival rate.

WSI processing

WSI are huge microscopic images of human tissue. These gigapixel images frequently exceed 100,000x100x000 pixels in width x height. Because the entire image cannot be processed in one go, it is typically split into many patches, and the work is done on a per-patch basis. For working with WSI, I recommend CLAM. This Python library offers features built specifically for machine learning tasks: selecting tissue areas, extracting patches and extracting features.

WSI segmentation

Why not U-Net

In computer vision, U-Net is the standard go-to tool for image segmentation. It was created in 2015 at the University of Freiburg for biomedical image segmentation. Today it is also widely used for other tasks, such as image style transfer and stable diffusion. With WSI, however, the image measures about 100,000x100,000, so it cannot be processed in one go. You can cut the image into many patches and run U-Net on each patch separately. For human tissue in whole slide imaging, however, this approach is not ideal.

The U-Net architecture

Figure 1. The U-Net architecture introduced in U-Net: Convolutional Networks for Biomedical Image Segmentation.

Below are several reasons why U-Net is not the best fit for WSI segmentation:

  • Segmentation aims to give every pixel a class: foreground or background. One 224x224 patch holds just a few cells. It makes more sense to classify each cell than each pixel.
  • A 100,000x100,000 segmentation mask is unnecessary. A lower resolution is simpler to store and process, and it is more than sufficient to support a pathologist.
  • Binary classification is simpler to train and gives better results than image segmentation. For this reason, per-patch tumor-normal classification is preferred over U-Net segmentation.
  • Consistency at the borders. Classifying whole patches instead of segmenting individual pixels makes the results more consistent across patches.

Patch level classification

Rather than U-Net segmentation, WSI segmentation commonly relies on classification at the patch level. The WSI is split into 224x224 patches, and each patch becomes an individual training example. The patch goes into the classification model, which outputs 0 for normal, cancer-free patches and 1 for patches containing a tumor. At inference time, the final segmentation map is assembled from the predictions for every patch of the WSI.

The Breast Cancer Metastasis Detection Pipeline

Figure 2. The pipeline for detecting breast cancer metastases. The WSI is split into many 224x224 patches. ResNet18 processes each patch and returns a prediction.

To detect breast tumors, we use a pre-trained ResNet18 model in which the last fully connected layer is swapped for a 1x1 convolution layer. The model takes 224x224 WSI patches as input. It outputs a binary class, 0 or 1, with 0 meaning a normal patch and 1 meaning a tumor patch. Figure 2 shows the prediction pipeline. For evaluation, we used WSI from the Camelyon16 challenge together with a pre-trained model from the Monai model zoo.

Results

The final segmentation map is assembled from the per-patch predictions. Figure 3 shows the output of the tumor detection algorithm on breast tissue. The algorithm clearly found a tumor in the upper-left part of the tissue, along with false positive noise elsewhere in the image. The predicted segmentation mask can then be post-processed with morphologic operations to suppress the noise and amplify the signal in actual tumor regions.

Figure 3. Tumor segmentation output.

Summary

This article presented an approach to detecting breast cancer metastases in lymph nodes. Deep Learning makes it possible to automate the process and can greatly support pathologists in their work. On top of that, AI can help pinpoint small tumor regions that are hard to detect and might otherwise slip past the pathologist. Explainability methods let us audit the AI model. If you’d like to know how AI could help in your medical use case, don’t hesitate to get in touch. I’d be glad to talk about your use case.