Verifying Stain-Normalized Slides Without Storing Them

Hospitals that pool pathology images for machine learning almost always recolor them first. Stain normalization maps each slide's pink-and-purple dye colors onto a common reference, and it can matter a great deal: on multi-center colorectal tissue, The importance of stain normalization in colorectal tissue classification with convolutional networks reports an accuracy boost of over 20% on external laboratories. The recoloring creates a provenance problem. Each normalized version of a gigapixel whole-slide image (a full digitized glass slide, often several gigabytes) is a new file. Its cryptographic hash has nothing in common with the hash of the raw scan. An auditor who sees only hashes on a shared ledger cannot tell whether the training data really are "the registered raw slides, recolored by Macenko with reference R," or something else, such as tiles swapped in from another cohort, selectively altered tumor regions, or images from a generative model that invented texture. The usual answer is to store every derived version and hash it. That multiplies storage and still proves nothing about how each version was derived.

The proposal replaces stored derivatives with stored recipes. Classical stain normalization is a small parametric function: a 3×2 stain matrix, a reference matrix and a few intensity percentiles, about 50 bytes in total. We commit to the raw slide once, as a Merkle tree over its tiles (a hash tree in which any single tile can be proven to belong to the committed slide with a short proof). We then record only the recipe for each normalized version. An auditor checks a claimed normalized dataset by sampling tiles, recomputing the normalization from the raw tile and the recipe, and accepting a match within a tolerance. The problem that makes this a research question rather than an engineering chore is the tolerance itself. The normalization pipeline is nonlinear: a logarithm, a pseudo-inverse of the stain matrix, clipping and an exponential. Floating-point differences across hardware, and lossy JPEG re-encoding of tiles, mean recomputation never matches bit for bit. We propose to bound the error with the same move nonlinear control uses to propagate uncertainty "tubes" through dynamics: a per-slide local sensitivity bound that sets how far an honest recomputation can drift.

Core Claim

A per-slide sensitivity bound on the Macenko or Vahadane normalization map lets a verifier do two things. It can accept honest recomputations and reject tampered tiles with a single, principled tolerance, while storing roughly 50 bytes per derived version instead of a full slide. The same bound, because it grows exactly when the two stain directions become nearly indistinguishable, also flags the slides on which normalization itself is unreliable. The first claim is about storage and verification; the second is about pathology. The second is what would make the method worth adopting even for groups that do not care about ledgers.

Concretely, write a pixel's optical density (the Beer–Lambert transform of intensity, a log of transmitted over incident light) as $o(I) = -\log_{10}(I/I_0)$. Macenko-style normalization computes $f(I;\theta) = I_0\,10^{-S_{\text{ref}}\,D\,S^{+} o(I)}$. Here $S$ is the slide's estimated 3×2 stain matrix, $S^{+}$ its pseudo-inverse, $S_{\text{ref}}$ the reference stain matrix, and $D$ a diagonal rescaling from concentration percentiles. Linearizing around the honest computation gives

$$\|f(\tilde I;\tilde\theta) - f(I;\theta)\|_\infty \le \|J_I\|\,\delta_I + \|J_\theta\|\,\delta_\theta + \varepsilon_{\text{jpeg}},$$

where $J_I$ and $J_\theta$ are the Jacobians of $f$ with respect to pixel input and recipe parameters, and $\delta_I$ and $\delta_\theta$ are the input and parameter perturbations. Here $\delta_I$ comes from floating-point and decoding differences. $\delta_\theta$ is the rounding of stored parameters. $\varepsilon_{\text{jpeg}}$ is a codec error bound measured once per quality setting. Both Jacobians scale with $\|S^{+}\|$, which is inversely proportional to the smallest singular value of $S$. Nearly collinear hematoxylin and eosin directions therefore widen the tube. The verifier's tolerance is this per-slide bound, and the bound doubles as a warning sign.

Relation to Prior Work

The ledger side supplies the method and marks the gap. PBCert anchors only 32-byte roots on-chain and keeps bulk certificate data off-chain. Batching Techniques for Accumulators with Applications to IOPs and Stateless Blockchains shows that constant-size commitments with batched membership proofs scale to large datasets. Dietcoin shows that lightweight clients can verify against commitments without holding hundreds of gigabytes. We reuse these commitments unchanged for the raw tiles. All three assume that the committed object is the object to be checked, bit for bit, and none handles data derived through a continuous transformation. That is the gap. The delta-storage approach of Jinlong Wang et al. commits only structural changes between versions of 3D models. That works when edits are local. Recoloring changes every pixel, so a pixel delta is as large as the image, and a parametric recipe is the natural "delta" instead. Off-chain decoupling in A Fully Decentralized Web Application Framework with Dynamic Multi-Point Publishing and Shortest Access Path and health-data ledgers such as Distributed storage database system for motion data based on blockchain technology motivate the setting but do not address transformed data.

The control side supplies a way of thinking, not a controller. Linear tube methods, such as Recursively Feasible Stochastic Model Predictive Control using Indirect Feedback, propagate uncertainty sets exactly because linear maps preserve their shape. Dynamic Tube MPC for Nonlinear Systems instead sizes tubes from local nonlinear sensitivity. We borrow only this second idea. The normalization pipeline is a single-step nonlinear map, and we bound its output spread with a local Jacobian and an explicit remainder check. We do not claim closed-loop stability for normalization. The research file suggests that framing, but it would be decoration. The honest connection is error propagation through a nonlinear map with a certified width.

The pathology side supplies the transformations and a known failure mode. Macenko normalization is used for survival models in Deep learning can predict survival directly from histology in clear cell renal cell carcinoma and in the pancreatic cancer work of Stroma and lymphocytes identified by deep learning are independent predictors for survival in pancreatic cancer. Vahadane's sparse factorization is used in Using deep learning to predict survival outcome in non-surgical cervical cancer patients based on pathological images. The known weakness of these methods, ill-conditioned stain estimates and reference bias, is what our bound measures. Generative restainers such as Self-attentive Adversarial Stain Normalization and RestainNet constrain the scope. They have no compact recipe, and their risk of altering nuclear detail is exactly what a verifier should catch. We therefore treat their outputs as the thing to be detected, not supported. The one exception is Ultra-High-Resolution Unpaired Stain Transformation via Kernelized Instance Normalization, whose normalization statistics are low-dimensional. It is a plausible second target.

Research Program

The work has three parts. The first is a reference system. It commits each raw slide as a Merkle root over fixed-size tiles and records one recipe per derived version: stain matrices, percentiles, tile size, codec and quality setting, and a software version tag. It implements a sampling auditor that requests $k$ random tiles with membership proofs, recomputes them, and checks each against its per-slide tolerance. If a fraction $p$ of tiles is tampered, uniform sampling misses all of them with probability $(1-p)^k$. For example, $k \approx 300$ gives about 95% detection at $p = 1\%$. This standard sampling argument sets the audit budget.

The second part is the tolerance itself. We derive $J_I$ and $J_\theta$ analytically for Macenko, and via implicit differentiation at the factorization's fixed point for Vahadane. We then check the first-order bound against brute-force perturbation on real tiles, because clipping and percentile steps are non-smooth. Where the linear bound fails, we add an empirical remainder term, estimated on held-out slides with a stated violation rate.

The third part tests whether the tube width predicts downstream failure, per slide and per center. If it does, the recipe record carries clinical information that raw hashes cannot.

Baselines

The naive reference point is store-and-hash: keep every normalized slide as a full file and anchor its SHA-256 root on the ledger, as in PBCert. It fixes storage cost at one full slide per derived version. It detects post-hoc modification of the stored file but not whether the file was honestly derived. We run it on identical slides and codec settings. We beat it if storage per derived version falls by at least three orders of magnitude and derivation-level tampering that it cannot see is detected.

The strongest competitor is deterministic bit-exact recomputation. Every party runs one pinned, fixed-point integer implementation of Macenko and Vahadane, with table-based log and exp, outputs are stored losslessly, and the verifier compares hashes. No tolerance is needed. This is a serious rival, and we will build it ourselves and give it the same audit sampling. It beats us whenever all parties can pin one implementation and avoid lossy codecs. We count as ahead only where that fails. We will measure how often it fails in practice across CPU and GPU builds, vendor tile decoders, and JPEG-stored pyramids. We then show equal tamper detection with non-zero acceptance of honest heterogeneous recomputations, where the bit-exact scheme rejects them.

The key ablation replaces the per-slide Jacobian tolerance with a single global tolerance, tuned on the same calibration slides to the same honest-rejection rate. If a global threshold reaches the same attack detection at the same false rejection rate, the sensitivity analysis adds nothing, and we will say so. We beat it if per-slide tolerances detect subtle color attacks on well-conditioned slides while still accepting honest recomputations on ill-conditioned ones.

For the reliability question, the baselines are the raw angle between the two estimated stain vectors, tissue-fraction and background heuristics, and a classifier trained with RandStainNA augmentation and no normalization. The tube width must predict per-slide error better than the stain angle alone to count as useful.

Why not just…?

Why not just hash the normalized slides and store them off-chain? This is the store-and-hash baseline. It proves that a file has not changed since upload. It does not prove that the file is a recoloring of a registered raw slide. It also multiplies storage by the number of normalization variants, which grows quickly when groups compare references or methods. The experiment measures both costs directly.

Why not just use one deterministic fixed-point implementation so hashes match exactly? This is the most serious alternative, and it may be enough for a single consortium that controls its software stack and stores tiles losslessly. Our claim depends on heterogeneity being common. We will count how often independent but honest implementations disagree bit-wise on real slides, including JPEG-backed pyramids. If they rarely do, the tolerance machinery is only a fallback. What remains is the reliability-flag contribution.

Why not just skip normalization and train with stain augmentation, so there is nothing to verify? If augmentation such as RandStainNA or Stain SAN fully replaces normalization, the provenance problem shrinks to raw tiles, which ordinary hashing handles. The evidence cuts both ways. Ciompi et al. report an accuracy boost of over 20% from normalization. Segmenting functional tissue units across human organs using community-driven development of generalizable machine learning algorithms finds that preprocessing drives cross-scanner generalization. Neither result tests modern pathology foundation-model features such as EXAONEPath. We include an augmentation-only arm on those features. If normalization gives no cross-center gain there, the verification half of this proposal matters only to the many existing pipelines that still normalize.

Why not just use a generative restainer, which handles unusual slides better? Such restainers have no compact recipe, so they cannot be verified by recomputation, and their failure mode is invented tissue detail. We use them as an attack model. The auditor should reject their outputs as not derived from the committed slide.

Proposed Experiments

We use the multi-center colorectal classification data of Ciompi et al., whose reported cross-laboratory gain from normalization (accuracy boost of over 20%) is the reference effect we need to preserve. We use the cross-organ, cross-scanner functional tissue unit segmentation benchmark of Jain et al., for which no reported result was found on Lacuna. We use the thyroid internal and external multi-instance cohort of Thyroid pathology image classification via multi-scale feature fusion and multi-instance learning, for which no reported result was found on Lacuna either. Each raw slide is committed once. Normalized versions are produced with Macenko and Vahadane against several references, on at least three software and hardware stacks, and at two JPEG quality settings.

Verification is measured by storage per derived version, audit bandwidth and time per slide, the honest false-rejection rate across stacks, and detection rate under five attacks. The attacks are tile substitution from another patient, recoloring of tumor regions only, a slightly wrong recipe (a different reference), generative restaining of a subset of tiles, and pure codec re-encoding, which should be accepted. The first decisive check is that per-slide tolerances keep honest false rejection below 1% while detecting region-selective recoloring that the global-tolerance ablation misses at matched false rejection. The second is that bit-exact recomputation fails on a measurable fraction of honest heterogeneous runs. The third is that per-slide tube width predicts downstream classification or Dice error better than the stain-vector angle does, measured by rank correlation and by the gain from excluding the top-decile slides. If all three fail, the recipe ledger reduces to a storage trick. If only the third succeeds, the stain-reliability score alone is still worth publishing.

References

  1. The importance of stain normalization in colorectal tissue classification with convolutional networks
  2. PBCert: Privacy-Preserving Blockchain-Based Certificate Status Validation Toward Mass Storage Management
  3. Batching Techniques for Accumulators with Applications to IOPs and Stateless Blockchains
  4. Dietcoin: Hardening Bitcoin Transaction Verification Process For Mobile Devices
  5. A Fully Decentralized Web Application Framework with Dynamic Multi-Point Publishing and Shortest Access Path
  6. Distributed storage database system for motion data based on blockchain technology
  7. Recursively Feasible Stochastic Model Predictive Control using Indirect Feedback
  8. Dynamic Tube MPC for Nonlinear Systems
  9. Deep learning can predict survival directly from histology in clear cell renal cell carcinoma
  10. Stroma and lymphocytes identified by deep learning are independent predictors for survival in pancreatic cancer
  11. Using deep learning to predict survival outcome in non-surgical cervical cancer patients based on pathological images
  12. Self-Attentive Adversarial Stain Normalization
  13. RestainNet: A self-supervised digital re-stainer for stain normalization
  14. Ultra-High-Resolution Unpaired Stain Transformation via Kernelized Instance Normalization
  15. RandStainNA: Learning Stain-Agnostic Features from Histology Slides by Bridging Stain Augmentation and Normalization
  16. Stain SAN: simultaneous augmentation and normalization for histopathology images
  17. Segmenting functional tissue units across human organs using community-driven development of generalizable machine learning algorithms
  18. EXAONEPath 1.0 Patch-level Foundation Model for Pathology
  19. Thyroid pathology image classification via multi-scale feature fusion and multi-instance learning