Whiten by the Slide, Classify the Patch: Orderless Slide Statistics for Cross-Hospital Pathology

When a tissue classifier trained at one hospital is deployed at another, accuracy collapses. On the Camelyon17 lymph-node benchmark, plain training drops from about 93% to about 70% on an unseen hospital (WILDS). Most of that shift is not about where things sit in the image. It comes from stain chemistry and scanner optics, and those act on the whole slide at once. This proposal turns orderless aggregation to a different job. Orderless aggregation means summarizing a set of local features with a function that ignores their order, such as a mean or a covariance. Instead of using it to build the diagnostic descriptor, we use it to estimate the nuisance. We pool every local feature from every patch of a slide into one unordered bag and compute that bag's mean and covariance. We then whiten each patch's feature maps by these slide-level statistics before classifying the patch. Whitening here means subtracting the mean and multiplying by the inverse square root of the covariance.

The bet is that stain and scanner effects are shared across a slide and act roughly like an affine change of early-layer features, while tumor-versus-normal differences vary from patch to patch within the slide. Removing what the whole slide has in common should therefore remove site style and keep diagnosis. Training then needs no noise injection, no generative translation, and no target labels, only knowing which slide a patch came from.

Core Claim

The obvious idea at this intersection is the file's "Gap 1": swap global average pooling for second-order covariance pooling (MPN-COV) and hope the richer orderless descriptor is intrinsically robust across sites. We think this is likely backwards.

Channel covariances of feature maps are essentially what style-transfer methods treat as "style." Correlated Style Uncertainty (CSU) succeeds on Camelyon17 precisely by treating cross-channel correlation of feature statistics as the site signature to be randomized. A per-image covariance descriptor should therefore make hospital identity easier to read off, not harder. That is a falsifiable prediction, and we test it first.

Our claim is that the useful role of second-order orderless statistics under medical domain shift is as a reference frame, estimated at the granularity where acquisition is shared (the slide). Their useful role is not as the classification feature. Concretely, at a chosen layer with local features $x_i \in \mathbb{R}^C$ for every spatial location $i$ of every patch in slide $s$, we form

$$ \mu_s = \frac{1}{N_s}\sum_{i \in s} x_i,\qquad \Sigma_s = \frac{1}{N_s}\sum_{i\in s}(x_i-\mu_s)(x_i-\mu_s)^\top + \epsilon I,\qquad z_i = \gamma \odot \Sigma_s^{-1/2}(x_i-\mu_s) + \beta, $$

where $N_s$ is the number of feature locations in the slide, $\epsilon$ is a small ridge term, and $\gamma,\beta\in\mathbb{R}^C$ are learned per-channel rescaling parameters shared across all slides.

The inverse square root is computed with the Newton–Schulz iteration from MPN-COV/iSQRT-COV. That paper supplies the method. It also states the key numerical limitation, which is that covariance estimates are ill-conditioned when locations are fewer than channels. Our design sidesteps this: a slide contributes thousands of patches times hundreds of locations against at most a few hundred channels.

Relation to Prior Work

CSU and the style augmentations it improves on perturb batch-level feature statistics during training and still classify with first-order average pooling. We do not perturb anything. We deterministically remove slide-level second-order statistics at both training and test time.

Model-Based Domain Generalization learns invariance to a pretrained image-translation model through constrained optimization. That buys robustness at the cost of a generative model and hallucination risk; our method needs neither.

Fish aligns gradients across training hospitals and is evidence that optimization-level fixes help only modestly on this benchmark. WILDS reports the same for IRM and CORAL. That negative result constrains us: we change the representation, not the loss.

The multiple-instance-learning literature also treats a slide as an unordered bag of patches, but pools it to predict a slide label. Representative work includes dependency-aware MIL and SparseConvMIL, and those papers argue that full orderlessness discards tissue architecture. Our use of the bag is narrower. It only estimates nuisance statistics, so their criticism of spatial blindness does not apply: patch-level prediction keeps its full spatial feature map.

LoTeNet is the closest "locally orderless" medical classifier. It reports AUC 0.943 on PCam with 0.8 GB of memory, but it was never tested across sites. Capsule Network Is Not More Robust Than Convolutional Network shows that orderless pooling buys geometric robustness. We argue the pathology shift is mostly not geometric, which is why geometric orderlessness alone, as in plain average pooling, does not rescue ERM.

Research Program

We will build a slide-whitening layer that can be inserted after any stage of a ResNet or DenseNet backbone. During training, each mini-batch is assembled from a few slides, and slide statistics are maintained as running estimates over that slide's patches. A configurable number of patches per slide caps the cost. At test time, the statistics for an unseen slide are computed in one forward pass over its patches. No labels are used and no weights are updated.

The program has three analyses beyond accuracy.

The first is a decodability probe. We train a linear classifier to predict hospital from (a) average-pooled features, (b) MPN-COV features, and (c) slide-whitened features. This tests whether covariance pooling encodes site more strongly and whether slide whitening removes it.

The second asks where style lives. We sweep the insertion depth, expecting gains concentrated in early stages where color and blur dominate.

The third is a granularity study. We compare whitening by hospital, by slide, and by the patch itself. The granularity matters because patch-level whitening risks erasing diagnostic color density, since tumor patches are denser and more purple. Hospital-level whitening, in turn, misses slide-to-slide stain variation within a hospital.

We also confront a known risk directly. A slide with heavy tumor burden shifts $\mu_s$ toward tumor features, partially subtracting the signal we want. We will measure the accuracy gain as a function of annotated tumor fraction. We will also test a robust variant that estimates statistics from a trimmed bag, discarding the patches farthest from the slide median.

As a secondary, dense-prediction setting, the same layer applies with the volume as the bag. We will test it on AMOS, which reports a drop of more than 20% mDice on MRI from unseen scanners. Because only normalization is changed and nothing is pooled away, the 3D-UNet decoder keeps full spatial resolution. That avoids the dense-prediction limitation of orderless pooling noted in the file.

Baselines

The naive reference is ERM: a DenseNet-121 trained on the three Camelyon17-WILDS training hospitals with standard augmentation and average pooling. The cited reported values are 70.3% out-of-distribution accuracy in Fish and 73.3% in MBDG. We rerun it ourselves under our exact protocol.

The strongest existing method in the file is CSU, which reports 95.1% accuracy on Camelyon17 (CSU). MBDG reports 94.8%. The gap between these figures and ERM's ~70% suggests the published evaluations may differ in protocol or backbone, so we will not compare against quoted numbers. We will reimplement CSU on our backbone, data split, epoch budget, and hyperparameter search budget, selected on the WILDS out-of-distribution validation hospital only.

Beating CSU means higher mean test-hospital accuracy over at least five seeds, with non-overlapping confidence intervals, at no more training compute. A tie with lower compute and no augmentation machinery would still be a reportable but weaker result.

We include MPN-COV covariance pooling in place of average pooling as the "obvious idea" baseline. We predict that it improves in-distribution accuracy but not out-of-distribution accuracy, and the hospital probe should show why.

Fish is run as the optimization-level representative.

The key ablation isolates our ingredient. We replace full-covariance slide whitening with diagonal slide standardization (per-channel mean and variance only). We also run the same full whitening with statistics drawn from a random other slide of the same hospital. The first ablation tests whether cross-channel structure matters. The second tests whether the slide, rather than the hospital, is the right unit.

Why not just…?

Why not just recompute BatchNorm statistics on the target hospital? This test-time normalization trick is the most serious threat, because it is cheap, label-free, and targets the same nuisance. It differs from our method in two ways: it is diagonal (first-order per channel) and it is pooled per site. The diagonal-slide ablation and a per-hospital BatchNorm-recomputation baseline, run under identical conditions, directly settle whether full covariance and slide granularity add anything. If they do not, we will report that simpler per-slide standardization suffices. That would still be a useful, publishable negative result about where second-order structure helps.

Why not just stain-normalize the pixels? Pixel stain normalization fixes color under a fixed dye-mixing model but not scanner blur, compression, or texture differences. We will include a standard color-normalization preprocessing baseline. If it closes most of the gap, the feature-space claim fails. Running it before our layer also tells us whether the two are complementary.

Why not just use covariance pooling, as the gap analysis suggests? Our hypothesis is that this feeds the classifier exactly the statistics CSU must randomize to generalize. The hospital-decodability probe and the out-of-distribution comparison test this directly, and we will report the outcome either way.

Why not just use stronger style augmentation, like CSU? Augmentation must guess the range of unseen styles. Whitening adapts to the observed style of each test slide. The head-to-head comparison above decides which works better, and we will also test the combination.

Proposed Experiments

The primary experiment uses Camelyon17-WILDS under the official split, with OOD accuracy averaged over at least five seeds and patient-level AUC as a secondary metric. We add leave-one-hospital-out evaluation over all five centers so that conclusions do not rest on one test hospital.

The decisive checks are four. First, slide whitening should beat diagonal slide standardization and same-hospital-other-slide whitening, showing that cross-channel structure and slide granularity both matter. Second, hospital decodability should fall after whitening while tumor decodability does not. Third, out-of-distribution accuracy should be stable once roughly a few dozen patches per slide are used to estimate statistics; we will plot accuracy against patch count. Fourth, the gain should not vanish on high-tumor-fraction slides when the trimmed estimator is used.

The secondary experiment trains a 3D-UNet on AMOS scanners with and without volume-level whitening and tests on the held-out MRI scanners. The reported reference point is the more than 20% mDice drop, with 89.04% mDice for 3D-UNet in-distribution on CT. No reported result for feature-whitened segmentation was found on Lacuna, so the comparison is against our own reruns.