An AI-powered educational assistant for pathology residents learning whole-slide histopathology (WSI) interpretation with multimodal reasoning and evidence-based IHC recommendations.
Disclaimer: Educational use only. Must not be used for clinical diagnosis or patient care.
PathPatch Navigator helps pathology trainees understand differential diagnoses, identify diagnostically important image regions, select appropriate IHC stains, and generate structured educational reports.
- Multi-patch analysis (3-5 patches simultaneously)
- Differential diagnosis generation with confidence scores
- Patch importance ranking
- IHC recommendation engine with evidence-based stain selection
- Cost & availability analysis with institutional pricing
- CAP-aligned report generation
- 4-bit quantized inference (optimized for 8GB VRAM)
- Memory-efficient sequential processing
- MedGemma 1.5 multimodal AI
- OpenSlide WSI support
- Structured JSON output
- FastAPI REST API
5-agent orchestration pipeline:
- Diagnosis Agent - Generate ranked differential diagnoses from patches
- Patch Importance Agent - Rank submitted patches by diagnostic value
- IHC Recommendation Agent - Recommend immunohistochemistry stains
- Cost Calculator Agent - Calculate testing costs and institutional availability
- Report Generator Agent - Create CAP-aligned pathology report templates
Agents coordinate through AgentOrchestrator and output structured JSON via PathPatchJSONFormatter.
cd pathpatch-navigator
python -m venv .venv
source .venv/bin/activate # Linux/macOS
.venv\Scripts\activate # Windows
pip install -r requirements.txtDownload MedGemma model:
huggingface-cli download googlelabs/medgemma-1.5-4b-it --local-dir models/medgemma-1.5-4b-itRun tests:
python scripts/run_smoke_local.py
python tests/test_full_pipeline.py
python tests/test_on_tcga.pyStart server:
python src/api/main.pyPOST to http://localhost:8000/api/v1/analyze with multipart form data (3-5 PNG patches + clinical context fields).
Response includes: differential diagnoses, patch importance rankings, IHC recommendations, cost analysis, and CAP-aligned report template.
Input data: PNG/JPG patches (256x256 at 20x magnification)
Directory structure:
data/
├── metadata/: Patch extraction metadata
├── patches/: Extracted patches per slide
├── processed/: Post-processed patches
├── raw/: BreCaHAD, DIAGSET, TCGA datasets
├── splits/: Train/val/test splits
└── wsi_slides/: .svs whole-slide images
Output: ./output/<case_id>_<timestamp>_results.json
Data preparation:
scripts/preprocessing/batch_extract_patches.py- Extract patches from WSIscripts/preprocessing/create_train_test_split.py- Generate splitsscripts/data_download/download_tcga.py- Download TCGA slidesscripts/data_download/download_diagset.py- Download DIAGSETscripts/data_download/download_brecahad.py- Download BreCaHAD
Testing:
scripts/run_smoke_local.py- Lightweight test without large modelstests/test_full_pipeline.py- End-to-end pipeline with MedGemmatests/test_integration_orchestrator.py- Agent orchestrator teststests/test_on_tcga.py- Multi-slide TCGA evaluation
IHC Database (src/knowledge_base/ihc_database.py): 20+ stains for breast, prostate, epithelial, squamous, neuroendocrine, lymphoid pathology
Cost Database (src/knowledge_base/cost_database.py): Institutional pricing (default: ER/PR $60, HER2 $80, Ki-67 $75, resident approval limit $300)
CAP Guidelines (src/knowledge_base/cap_guidelines.py): Diagnostic criteria, Nottingham grading, Gleason scoring, synoptic elements
Supported diagnoses: Invasive Ductal Carcinoma, Invasive Lobular Carcinoma, Prostate Adenocarcinoma
Differential Diagnosis Agent (src/inference/differential_diagnosis_agent_8gb.py): MedGemma 1.5 with 4-bit quantization for 8GB VRAM
Patch Importance Analyzer (src/inference/patch_importance_analyzer_8gb.py): Sequential patch ranking with memory management
Dependencies:
bitsandbytes, fastapi, huggingface_hub, numpy, opencv-python
openslide-python, Pillow, pydantic, python-multipart, requests
safetensors, sentencepiece, tokenizers, torch, transformers
uvicorn, loguru
Tech Stack:
- Backend: FastAPI + Uvicorn
- AI/ML: MedGemma 1.5 (4-bit quantized)
- Image Processing: OpenSlide, OpenCV, Pillow
- Data: Pydantic, JSON
- Logging: Loguru
Complete:
- Core agentic workflow (5 agents)
- MedGemma inference optimization
- IHC recommendations engine
- Cost calculations with approvals
- CAP-aligned report generation
- REST API with multipart support
- 4-bit quantization for 8GB VRAM
- Comprehensive testing suite
- Haris bin Amir
- Muhammad Uzair
- Muhammad Zabil
- Talha Kausar
To be determined
- MedGemma: https://huggingface.co/googlelabs/medgemma-1.5-4b-it
- OpenSlide: http://openslide.org/
- FastAPI: https://fastapi.tiangolo.com/
- CAP Guidelines: https://www.cap.org/guides-and-quality-standards/cap-synoptic-checklists
Last Updated: February 21, 2026 Version: 1.0.0