Introduction
DigiPathAI provides a Python API for programmatic access to its tissue segmentation capabilities. The API allows you to integrate whole slide image (WSI) analysis directly into your workflows without using the web interface.Import Structure
The main functions are available from theDigiPathAI.Segmentation module:
Main Entry Points
DigiPathAI provides two primary functions for tissue analysis:getSegmentation
The high-level function for complete tissue segmentation. This is the recommended entry point for most use cases.get_prediction
A lower-level function for patch-based prediction with custom models. Provides more control over the inference process.Basic Usage Pattern
Here’s a typical workflow using the Python API:The
quick=True parameter uses a single model for faster inference. Set quick=False to ensemble 4 different models for higher accuracy.Return Types and Data Structures
getSegmentation Return Value
Returns a numpy array containing the binary segmentation mask:- Shape:
(height, width)matching the WSI dimensions at the highest resolution - Data type:
float32oruint8 - Values:
255= tissue (positive prediction)0= background (negative prediction)
get_prediction Return Value
Returns a tuple of(image, probs_map):
img: The original WSI as a numpy arrayprobs_map: Dictionary containing prediction statisticsprobs_map['mean']: Mean probability map across all models/augmentationsprobs_map['var']: Variance (uncertainty) map
Dictionary containing probability maps with mean and variance
Mean probability map. Values range from 0.0 to 1.0, where higher values indicate stronger tissue predictions.
Variance map representing prediction uncertainty. Higher values indicate less confident predictions.
Performance Considerations
Key parameters affecting performance:- batch_size: Higher values = faster processing but more GPU memory
- patch_size: Larger patches = fewer iterations but more memory per patch
- stride_size: Smaller strides = more overlap and better quality but slower processing
- quick:
True= single model (fast),False= 4-model ensemble (slow but accurate)
Next Steps
getSegmentation Function
Detailed documentation for the main segmentation function
Parameter Reference
Complete reference for all function parameters