Outlier Detection via Path Foundation
A QuPath menu that embeds tiles with Google’s Path Foundation model and scores them for outlierness with an Isolation Forest — quality control by “which tiles do not look like the others” rather than by a list of named artefacts.
Purpose
Most WSI quality control asks a supervised question: is there a pen mark, a fold, an air bubble? That is the approach in GrandQC-QuPath and it works well for artefacts somebody thought to label. This project asks the unsupervised one instead — embed every tile, then find the tiles that sit far from the rest of the distribution — which catches whatever is unusual, including things not on anyone’s list.
That difference is the reason it earns a page rather than a line. It is a genuinely different QC strategy from everything else in QuPath Tooling, and the two are complementary rather than competing: a named-artefact detector and a distributional outlier detector fail on different things.
Three tracked files, one commit, no git remote at all — this exists only on this machine.
Data used
No cohort. It consumes whatever tiles the QuPath project provides, and requires Google’s Path Foundation model as a TensorFlow SavedModel on disk. The server does not download it; the requirements file documents fetching it once from HuggingFace after accepting Google’s HAI-DEF terms.
Note a small inconsistency worth resolving: the documented model path here is K:/hf/…, while Foundation Model Cache inventories Path Foundation under the J: drive. Two model roots on two drives, with no manifest reconciling them, is exactly the reproducibility gap that page already flags — this project is a concrete instance of it.
Methods
Two pieces, joined by HTTP:
scripts/PathFoundation_Menu.groovy— a QuPath startup script (dropped intoscripts/startup/, auto-executed on launch), building a JavaFX dialog and adding a menu. Declares QuPath 0.4/0.5 compatibility.python/path_outlier_server.py— a Flask server that receives base64-encoded tiles, generates embeddings with Path Foundation, standardises them, and scores them.
The scoring is the substance. Embeddings go through StandardScaler, then IsolationForest by default, with LocalOutlierFactor also imported as an alternative method. The code’s own comment gives the reasoning — Isolation Forest is “fast, works well for high-dim embeddings” — which is a defensible choice for a few-hundred-dimensional feature space where density estimation struggles.
The environment pinning is unusually well documented and worth preserving. The requirements file explains that TensorFlow is pinned to 2.10.1 because that is the last release with native Windows GPU support — from 2.11 onward Windows users must go through WSL2 — and that the nvidia-cudnn-cu11 wheel bundles the cuDNN and cuBLAS DLLs into the virtualenv so no system cuDNN install is needed, with the server adding those directories to the Windows DLL search path before importing TensorFlow. That is a real, hard-won piece of Windows GPU knowledge written down in the one place someone would look for it, and it is the same class of problem the OpenSlide patches in Drafts Helpers exist to solve.
Current state / open questions
Paused after a single commit on 2026-05-24, and never pushed anywhere.
- The method is untested against a known reference. Nothing here records whether the tiles it flags are the ones a pathologist would call problematic. That is a small experiment — run it over a slide set that GrandQC-QuPath has already scored and compare — and it would turn an idea into a measured capability. It is also the natural way to establish the complementarity claimed above: the interesting number is how many tiles one method flags that the other misses.
- Isolation Forest has no notion of “how outlying is too outlying”. It returns a score, and nothing here sets a threshold or calibrates one, so the output is a ranking rather than a decision. For QC that is arguably the right shape — review the worst n — but it should be stated rather than left implicit.
- No remote means one disk failure loses it. Given it is three small files, this is the cheapest thing on this list to fix.
[unverified]whether outlierness in Path Foundation’s embedding space tracks tissue quality or acquisition. A tile can be unusual because it is damaged, or because it came off a different scanner — and Scanner and Stain Variability says the second effect is often the larger one. If the detector is mostly rediscovering the scanner, it is a batch detector wearing a QC label. Running it across a deliberately mixed-scanner set would settle it.
Related: WSI Quality Control — the method this belongs to, approached from the unsupervised side rather than the named-artefact side. Related: GrandQC-QuPath — the supervised counterpart, and the obvious thing to compare against. Related: Foundation Model Cache — Path Foundation is already local, though under a different drive root than this project expects. Related: Foundation Models in Pathology — this uses a foundation model as a distribution to measure distance from, rather than as features for a classifier. Related: Scanner and Stain Variability — the confounder that decides whether the outliers found are about quality or about acquisition.
Derived from: repository source read 2026-07-29 — scripts/PathFoundation_Menu.groovy, python/path_outlier_server.py (imports and scoring path), requirements.txt read in full; git log and git remote for currency and the absence of a remote.