Skip to main content

Overview

DigiPathAI provides specialized models for breast cancer metastasis detection, trained on the Camelyon (Cancer Metastases in Lymph Nodes) dataset. These models identify metastatic regions in lymph node sections.

Camelyon Dataset

The Camelyon dataset contains whole slide images of lymph node sections with annotations for breast cancer metastases. The model ensemble includes:

Inception

Multi-scale analysis for metastatic patterns

DenseNet

Efficient feature propagation for detection

DeepLabV3

Precise metastasis boundary segmentation

Model Details

The breast cancer models are automatically managed by DigiPathAI:
# From Segmentation.py lines 264-278
elif mode == 'breast':
    path = os.path.join(home, '.DigiPathAI/camelyon_models')
    if (not os.path.exists(os.path.join(path, 'camelyon_inception.h5'))) or \
        (not os.path.exists(os.path.join(path, 'camelyon_deeplabv3.h5'))) or \
        (not os.path.exists(os.path.join(path, 'camelyon_densenet.h5'))):
        if status is not None: status['status'] = "Downloading Trained Models"
        download_camelyon() 
        model_path_inception = os.path.join(path, 'camelyon_inception.h5')
        model_path_deeplabv3 = os.path.join(path, 'camelyon_deeplabv3.h5')
        model_path_densenet = os.path.join(path, 'camelyon_densenet.h5')
    else :
        if status is not None: status['status'] = "Found Trained Models, Skipping download"
        model_path_inception = os.path.join(path, 'camelyon_inception.h5')
        model_path_deeplabv3 = os.path.join(path, 'camelyon_deeplabv3.h5')
        model_path_densenet  = os.path.join(path, 'camelyon_densenet.h5')
Models are stored in ~/.DigiPathAI/camelyon_models/ and include:
  • camelyon_inception.h5
  • camelyon_deeplabv3.h5
  • camelyon_densenet.h5

Usage Example

Basic Breast Metastasis Detection

from DigiPathAI.Segmentation import getSegmentation

# Detect metastatic regions in lymph node
prediction = getSegmentation(
    img_path='lymph_node_slide.tiff',
    mode='breast',
    patch_size=256,
    stride_size=128,
    batch_size=32,
    quick=False  # Use ensemble of all three models
)

Quick Mode (Single Model)

# Use only Inception for faster screening
prediction = getSegmentation(
    img_path='lymph_node_slide.tiff',
    mode='breast',
    model='inception',
    quick=True
)

High-Sensitivity Detection

# Maximize detection with TTA and ensemble
prediction = getSegmentation(
    img_path='lymph_node_slide.tiff',
    mode='breast',
    tta_list=['FLIP_LEFT_RIGHT', 'ROTATE_90', 'ROTATE_180'],
    quick=False,
    stride_size=64  # Increased overlap for better coverage
)
For lymph node metastasis detection, use ensemble mode (quick=False) with test-time augmentation to maximize sensitivity, especially for small metastatic foci.

Parameters

ParameterDescriptionDefaultBreast-Specific Notes
modeTissue type-Must be set to 'breast'
modelArchitecture choice'dense'Options: ‘dense’, ‘inception’, ‘deeplabv3’
quickSingle vs ensembleTrueSet to False for ensemble
patch_sizeInference patch size256Recommended: 256 for metastasis detection
stride_sizeSliding window stride128Use 64 for higher sensitivity
batch_sizeBatch size for inference32Adjust based on GPU memory

Output

The segmentation provides comprehensive metastasis analysis:
  1. Probability Map - Continuous probability values for metastatic likelihood
  2. Binary Mask - Thresholded segmentation (threshold=0.3) of metastatic regions
  3. Uncertainty Map - Model variance for quality assessment
# Outputs optimized for clinical review
prediction = getSegmentation(
    img_path='lymph_node.tiff',
    mode='breast',
    probs_path='./metastasis_probability.tiff',
    mask_path='./metastasis_mask.tiff',
    uncertainty_path='./metastasis_uncertainty.tiff'
)

Clinical Applications

  • Sentinel Lymph Node Screening: Rapid detection of metastases
  • Micrometastasis Detection: Identify small metastatic foci (less than 2mm)
  • Macrometastasis Quantification: Measure extent of large metastases
  • Quality Assurance: Uncertainty maps highlight areas needing pathologist review
  • Research: Correlate metastatic burden with patient outcomes

Detection Thresholds

The default threshold (0.3) balances sensitivity and specificity. Adjust based on your use case:
# For screening (higher sensitivity)
# Use lower threshold or probability map directly

# For confirmation (higher specificity)  
# Use default threshold (0.3) with ensemble mode
The Camelyon models are trained on lymph node sections and optimized for detecting breast cancer metastases. Performance on other tissue types may vary.

Build docs developers (and LLMs) love