Capped-Context Segmentation for Surgical Hyperspectral Imaging

Hyperspectral cameras record, for every pixel, a reflectance curve across about a hundred narrow wavelengths. That curve is a chemical fingerprint of the tissue. Deep segmentation networks trained on these images tend to ignore the fingerprint. They learn anatomy instead ("this is gallbladder because it sits next to liver"), and they fail badly when surgery removes, isolates, or occludes the neighbouring organs. We propose a segmentation network whose output for each pixel is the exact sum of two parts. The first is a spectral term computed only from that pixel's own curve. The second is a context term computed from the surrounding image, and it is limited in size so that it cannot override strong spectral evidence by more than a set margin. Because the fusion is a plain sum, every prediction comes with an exact, non-post-hoc split: how much of the decision came from chemistry and how much from surrounding geometry.

The payoff is two things in one mechanism. The first is robustness under the geometric shifts that break current models. The second is an explanation that can be checked, rather than a saliency map that may or may not reflect what the network computed. The explanation is also useful at test time. A pixel whose label depends mostly on context is a pixel to distrust when the surgical scene no longer looks like the training data. We test this directly as an error detector.

Core Claim

Current dual-branch hyperspectral networks already split spatial and spectral processing. They then merge the branches through gates, attention, or deep decoders, and that merge erases any clean attribution. We claim three things. First, a strictly additive merge of a pixel-local spectral term and a bounded context residual loses little in-distribution accuracy relative to coupled models. Second, it degrades substantially less under organ resection, isolation, and occlusion. Third, its per-pixel context share predicts where it will fail better than softmax confidence or grouped post-hoc attributions of a monolithic network.

For class $c$ at pixel $p$ of image $x$, the logit is

$$ z_c(x,p) = s_c(x_p) + \beta \tanh\!\big(g_c(x,p)/\beta\big), $$

where $x_p$ is the pixel's own spectrum, $s_c$ is the spectral branch, $g_c$ is a context branch with a full spatial receptive field, and $\beta > 0$ caps the magnitude of the context contribution. The context reliance of a prediction $\hat c$ is

$$ r(p) = \frac{|\beta \tanh(g_{\hat c}/\beta)|}{|s_{\hat c}| + |\beta \tanh(g_{\hat c}/\beta)|}. $$

In this expression $r(p)=0$ means a purely chemical decision. The cap $\beta$ turns the reviewer's question "how much should context be allowed to matter?" into a single dial that can be swept and reported.

We do not claim that the context branch is "purely spatial." It sees the full cube and can use spectral information from neighbouring pixels. The clean guarantee runs the other way: the spectral term provably uses nothing but the pixel itself. The context term is defined as whatever the neighbourhood adds on top of that.

Where This Sits in Prior Work

Two papers motivate the problem. Semantic Segmentation of Surgical Hyperspectral Images Under Geometric Domain Shifts showed that standard segmentation networks lose about 45% Dice (for hyperspectral input) when organs are isolated, resected, or occluded. Its authors fixed this with "Organ Transplantation," which pastes organs into foreign scenes during training. Red Teaming Models for Hyperspectral Image Analysis Using Explainable AI used SHAP on a soil-regression model and found that adding spatial features shifted the model's reliance away from spectra. Both diagnose the same failure. Neither changes the architecture so that the failure is measured and bounded by construction. Our proposal does that, and it treats Organ Transplantation as a competitor and a complement, not as prior art to dismiss.

Three architectures supply the decoupling idea but merge the branches opaquely:

  • DMS2F-HAD uses a spatial convolution/Mamba branch and a grouped-band Mamba branch fused by a learned per-pixel gate.
  • BiMambaHSI uses parallel bidirectional spatial and spectral state-space branches with adaptive gating.
  • HyperSIGMA uses separate spatial and spectral transformers joined by an enhancement module.

In all three the gate or fusion module feeds further nonlinear layers. The gate value is therefore not a faithful statement of branch contribution. Ours is, because nothing follows the sum except softmax.

Two interpretable-by-design works supply the method. MultiFIX forces each modality through a tiny bottleneck and replaces fusion with symbolic formulas. Regionally Additive Models build predictions from low-order additive terms. We borrow the additive-fusion principle, not their bottleneck. MultiFIX was only tested on synthetic shapes and tables, and a three-feature bottleneck is unlikely to hold nineteen tissue classes in dense segmentation.

Identifying chromophore fingerprints of brain tumor tissue found that the first principal component of glioblastoma spectra matches reduced cytochrome-c-oxidase absorption in 500–600 nm. That gives us an external physical reference for auditing the spectral branch. Xeno-learning shows that relative spectral shifts carry physiology across species. This constrains our design: the spectral branch must keep the full curve, not a handful of selected bands.

Research Program

Architecture. The spectral branch is a pixel-wise network that sees exactly one spectrum. It is built from 1×1 convolutions, equivalently an MLP with a light 1D convolution along wavelength. The context branch is a standard U-Net-style encoder–decoder on the full cube. We use the same family as the monolithic baseline so the comparison isolates the fusion rule rather than capacity.

Training order. Joint training invites the same "path of least resistance" that produces the context crutch. We therefore train the two branches stagewise, in the spirit of boosting:

  1. Fit the spectral branch alone to convergence.
  2. Freeze it, or fine-tune it at a low rate.
  3. Fit the capped context branch to the residual, so context only adds what spectra cannot supply.

Spectral audit (secondary). On HELICoiD we compute each class's input-gradient profile of $s_c$ over wavelength. We then measure its correlation with the PC1 loading reported to match reduced cytochrome-c-oxidase. We do the same for grouped SHAP of a monolithic model. This asks whether exact decoupling yields spectral attributions that are more physically aligned, not just more robust.

Analyses. We sweep $\beta$ across a range from pure spectral ($\beta=0$) to effectively uncapped. For each value we report in-distribution Dice, Dice under each geometric shift, and the distribution of $r(p)$ per organ. The resulting curve is itself a finding: it quantifies how much anatomical context each organ genuinely needs.

Baselines

The naive reference point is the monolithic hyperspectral segmentation network of the geometric-shift study Semantic Segmentation of Surgical Hyperspectral Images Under Geometric Domain Shifts. It is trained on the full cube with no augmentation, and the paper reports its roughly 45% Dice drop under shift. The file gives relative drops but no absolute per-shift Dice values, so we retrain it ourselves on the same splits. This baseline defines the gap to close.

The strongest existing method is that same monolithic network trained with Organ Transplantation. The paper reports Dice improvements "up to 90% for HSI" under geometric shift and 283% for the pancreas under occlusion. No reported absolute Dice for this configuration was found on Lacuna. It is the strongest competitor because it attacks exactly our failure mode and already works. We run it with the same backbone, same data splits, same epoch and hyperparameter-search budget, and the paper's augmentation settings.

We count as beating it if either of two outcomes holds:

  • Our model matches its mean shifted Dice within one standard deviation across cross-validation folds, while also providing the exact context share and better failure prediction.
  • Our model combined with Organ Transplantation exceeds Organ Transplantation alone on shifted Dice.

Merely matching it on Dice without the failure-prediction advantage would count as a null result for the architectural claim.

A gated dual-branch baseline adapts the adaptive-gating fusion of BiMambaHSI and DMS2F-HAD to segmentation, using our two branches and a learned per-pixel gate followed by a small decoder. It tests whether additivity matters, or whether any dual-branch split helps. The gate value serves as its "context share" in the failure-prediction test.

Three ablations isolate the key ingredients. The first is our model with $\beta\to\infty$, which is additive but uncapped. The second is joint rather than stagewise training. The third is the spectral branch alone ($\beta=0$).

Why not just…?

Why not just use Organ Transplantation on a standard network? This is the real threat. It may give shifted-Dice numbers as good as ours, since it directly removes the shortcut from the training distribution. Two things remain that it cannot provide. It gives no per-pixel account of why a prediction was made. And it gives no test-time signal of context dependence, so a surgeon cannot tell which pixels would flip if the anatomy changed. The experiments settle this in two ways. We compare shifted Dice head-to-head. We also run the combination, which tests whether the two are complementary. If the combination adds nothing and our failure-prediction advantage is absent, the architectural contribution is not supported.

Why not just classify each pixel from its spectrum alone? A pixel-wise model is immune to geometric shift by construction, so its shifted Dice could rival anything else. This is the $\beta=0$ end of our sweep and is reported as its own baseline. The question is whether a bounded amount of context buys in-distribution accuracy, especially at organ boundaries and for spectrally similar tissues, without reintroducing the collapse. If the $\beta$ curve shows no interior optimum, that is a clean negative result: context should simply be removed.

Why not just apply grouped SHAP or Grad-CAM to a monolithic model and split attributions into spatial and spectral? This is what the red-teaming study did Red Teaming Models for Hyperspectral Image Analysis Using Explainable AI. Post-hoc attributions are approximations whose faithfulness is itself contested, a point MultiFIX A Step towards Interpretable Multimodal AI Models with MultiFIX also raises. The fair test is predictive. We compute grouped SHAP context shares for the monolithic and Organ-Transplantation models and ask whether they flag shifted-scene errors as well as $r(p)$ does. If they do, our explanation advantage reduces to computational cost.

Why not just read off the gate of an existing dual-branch model? The gate is followed by nonlinear layers, so a gate weight of 0.8 on the spectral branch does not mean 80% of the decision is spectral. The gated baseline tests whether this matters in practice for failure prediction.

Proposed Experiments

Data and splits. The primary benchmark is the geometric-shift setting of Semantic Segmentation of Surgical Hyperspectral Images Under Geometric Domain Shifts: 600 cubes from 33 pigs, 100 bands from 500–1000 nm, 19 classes, with isolation, resection, and occlusion test sets. Folds are split by subject. HeiPorSPECTRAL, with 5,758 cubes over 20 organs, serves as additional in-distribution training and evaluation data. Its reported low inter-pig spectral variance (2.3%) suggests that pixel-local spectra should be a strong signal, which our $\beta=0$ baseline tests. HELICoiD is used only for the spectral audit, since it lacks a geometric-shift split.

Metrics. For accuracy we report per-class and mean Dice, in distribution and per shift. For failure prediction we report area under the ROC curve for detecting misclassified pixels on shifted scenes, and area under the risk–coverage curve. For the spectral audit we report the correlation between class wavelength-attribution profiles and the reference cytochrome loading.

Decisive checks. The proposal succeeds if three results hold together. First, some interior $\beta$ gives shifted Dice comparable to Organ Transplantation, with in-distribution Dice above the spectral-only model. Second, $r(p)$ detects shifted-scene errors better than softmax confidence, grouped SHAP, and gate values. Third, stagewise training yields lower average $r(p)$ and better shifted Dice than joint training, which confirms that the training order, not just the sum, counters the context crutch.

Counterfactual context-swap test. We transplant an organ into a foreign scene at test time and check two predictions. The spectral term for that organ should stay nearly unchanged. The context term should move toward the host-scene anatomy, and its effect on the final label should be bounded by $\beta$. Because the decomposition is exact, this is a falsifiable statement about the model rather than a picture to inspect.