Thin branching structures such as nerve canals, brain arteries, airways and roads are segmented by networks trained to maximize pixel overlap. Overlap scores can stay high while a branch is cut in two. The cuts concentrate where the structure fades into its surroundings: a canal dissolving into bone near its exit, a distal vessel sinking into noise. The current topology-aware losses are weakest exactly there. Centerline losses lose their gradient when the predicted centerline fades. Exact topological matching is expensive and returns nothing when prediction and truth do not overlap. Adversarial training, where a second network judges the segmentation, could supply a learned, image-aware signal in those regions. The one topology-focused version, however, only says "correct" or "incorrect."
We propose replacing that yes/no judge with a categorical discriminator: a judge network that names the kind of mistake it sees in each patch. Its classes are a real annotation, an intact prediction, a false break, a false merge or bridge, and a spurious fragment. It is trained on labels computed exactly from persistent homology, a tool from algebraic topology that tracks connected pieces and loops. Because a break and a bridge must be fixed by pushing pixels in opposite directions, a judge that separates them gives the segmenter usable gradients. A yes/no judge mixes these opposite corrections into one blurred signal. Because the judge sees the image and runs convolutionally over the whole volume, it can learn from context that "a canal continues here" even where pixel contrast is gone.
Core Claim
A binary topology discriminator suffers the same flaw that Activation Maximization Generative Adversarial Nets found in class-conditional image generators. That paper showed that a single "look real" signal over several classes produces gradients that cancel or average when a sample sits between classes. Its fix was a discriminator with K real-class outputs plus one fake output, so that each class pulls the generator in its own direction. In segmentation, a "topologically incorrect" patch may be incorrect because pixels are missing (a break) or because extra pixels are present (a merge or fragment). These two cases call for opposite updates. Our claim has two parts. First, splitting the judge's fake side into topological failure types, with labels taken from Betti matching rather than heuristics, gives better-aligned generator gradients and fewer topological errors than a binary judge trained on the same labels. Second, the benefit is largest in low-contrast fading zones. There the exact topological loss is either unaffordable at full scale or returns no gradient because prediction and truth do not overlap. The judge, once trained, transfers its learned topology prior to the whole volume at the cost of a forward pass.
Relation to Prior Work
The closest work is TopoAL. It trains a multi-scale discriminator on road segmentations and labels each patch "topologically incorrect" if it contains a skeleton break of at least 4 pixels. It also passes the aerial image to the discriminator and uses a straight-through estimator to backpropagate through binarized masks. We reuse its image conditioning and its straight-through estimator. We depart from it in two ways. Our judge is categorical rather than binary. Our labels come from spatially matched persistence features rather than a pixel-length threshold. TopoAL's errors come from sharp occlusions such as trees and shadows. We target continuous contrast fading, a regime it does not study.
Three exact or near-exact topology losses motivate and constrain the design.
- Topologically Faithful Image Segmentation via Induced Matching of Persistence Barcodes introduced Betti matching. It pairs predicted and true components and loops only when they are spatially co-located, and it showed that earlier Wasserstein-based topology losses mismatch features over 99% of the time. We use Betti matching as the label oracle because it can tell which feature is unmatched and therefore which failure occurred.
- Topologically faithful multi-class segmentation in medical images extends Betti matching to several classes, one class at a time. It is the strongest direct-loss competitor, but it shares the cubic cost and the need for overlap.
- clDice compares soft skeletons and predicted volumes. Its gradient shrinks where the soft skeleton fades.
Lv et al. provide the clearest motivating failure. Their Swin-UNetR with clDice segments the mandibular canal well overall, but they report that it consistently severs the canal at the head and tail near the foramen, where contrast disappears into bone.
Two other lines constrain what counts as an improvement. Skea-Topo locates topologically critical pixels in linear time by intersecting skeletons with error masks. It relies on morphological skeletons that become unstable on diffuse boundaries. DeepTree uses a non-adversarial module trained on synthetically broken airways to predict reconnections. It is the template for the strongest non-adversarial alternative discussed below.
Boundary-attention networks such as MISNet sharpen faint edges locally but have no notion of connectivity. That is the gap the categorical judge fills.
Research Program
The segmenter. The generator is a standard 3D segmenter, an nnU-Net-style network, trained with Dice plus cross-entropy as an anchor. This anchor matters: both the Betti matching literature and adversarial-exploitation concerns say a topological signal cannot stand alone.
Labeling patches. During training we sample small patches from the binarized prediction (2D crops of the size Betti matching tolerates, about 48×48, or small 3D cubes). Sampling is biased toward low-contrast regions. We measure contrast as the local contrast-to-noise ratio between the annotated structure and a surrounding shell. Each patch is labeled by running Betti matching against the ground truth:
- an unmatched true component, or a true connection absent in the prediction, is a break;
- predicted merges or loops with no true counterpart are a bridge;
- unmatched predicted components are a spurious fragment;
- patches with no unmatched features are intact.
Ground-truth mask patches form the real class. When a patch has several errors, it receives a multi-label target with a softmax over failure types.
The judge and the generator's objective. The discriminator sees the image, the mask and the contrast map. Its output is a softmax over five classes. The generator is trained to raise the probability of the real class at every location of the full-volume judge map. In AM-GAN terms, the fake side is split by failure type so that each failure logit supplies its own direction.
Cost. The expensive topology computation is spent only on labeling a bounded number of patches per step. The judge is then applied densely and cheaply.
Guarding against exploitation. We will watch for the generator fooling the judge with high-frequency noise, a known risk of activation-maximization objectives. We pass binarized masks through the straight-through estimator, apply spectral normalization to the judge, and report Dice alongside topology metrics so that any trade-off is visible.
Direct mechanistic test. Beyond end metrics, we test the overlaid-gradient claim directly. For matched sets of break and bridge patches, we compute the generator gradients induced by the binary judge and by the categorical judge. We then measure (a) the cosine similarity between the two gradient families and (b) the fraction of gradient mass that lands inside the actual error region.
Baselines
Naive reference. An nnU-Net-style segmenter trained with Dice plus cross-entropy only, with matched epochs and augmentation. This shows how much any topology signal adds. For overlap on the mandibular canal, the published reference is Lv et al., who report Dice 0.796 for nn-UNet.
Strongest topology-specific methods. There are two, each the strongest on its own regime.
- Lv et al.'s Swin-UNetR with clDice reports Dice 0.844, HD95 2.947 mm and IoU 0.731 on the mandibular canal. It is the strongest published system on the dataset where fading-zone breaks are documented.
- Multi-class Betti matching from Berger et al. reports Betti Matching Error 0.773 on TopCoW, against 1.791 for Dice. It is the strongest direct topology loss on brain arteries.
Both are retrained on our splits with our backbone, the same training budget and an equal hyperparameter search (for example, the clDice weight α or the Betti matching weight), so that differences reflect the training signal rather than the architecture. Beating them means lower Betti Matching Error and higher terminal-segment connectivity in the lowest-contrast stratum, with Dice no worse than 0.01 below the baseline.
Ablations isolating the key ingredient. The decisive ablation is a TopoAL-style binary judge (following TopoAL). It receives exactly the same Betti-matching-derived labels collapsed to correct versus incorrect, the same inputs, the same architecture and the same compute. Any gain of the categorical judge over this binary one isolates the value of naming the failure type. A second ablation uses TopoAL's own heuristic labels (a 4-pixel break threshold) with the categorical head, to separate the label source from the output structure. On RoadTracer, TopoAL reports TLTS 0.388 against 0.323 for UNet; reproducing roughly that gap confirms that our binary reimplementation is faithful.
Why not just…?
Why not just use Betti matching as the loss and skip the discriminator?
This is the most serious threat. On regions where prediction and truth overlap and patches are small, direct Betti matching may be as good as or better than a learned judge. Two documented limits favor the judge in fading zones. The cubic cost restricts the loss to small crops. More importantly, the loss returns null gradients where there is no overlap (Stucki et al.), which is precisely what happens when a canal's tail is missed entirely. Our experiments stratify all metrics by local contrast. If Betti matching matches the judge in the lowest-contrast stratum too, our claim fails. We also test Betti matching combined with the judge, since the two may be complementary rather than competing.
Why not just use clDice or Skea-Topo, which are cheaper?
Lv et al. already ran clDice on the mandibular canal and reported the canal being severed at the foramen. Skea-Topo depends on morphological skeletons that are unstable on diffuse boundaries. Both are run as baselines. The contrast-stratified results will show whether their failure is specific to fading zones, as we expect.
Why not just train a frozen failure-type classifier and use it as a fixed loss, as DeepTree trains its reconnection module?
This removes the adversarial game, and it may be more stable. The risk is that a fixed critic is learned from early or synthetic errors and goes stale as the segmenter changes, or is exploited without retraining. DeepTree shows that synthetic-break training works for airways. We therefore include a frozen version of our categorical judge, trained once on a pretrained segmenter's errors, under the same compute. If it equals the adversarially updated judge, we will report that the categorical labels, not the adversarial game, carry the benefit.
Why not just add boundary attention?
Boundary branches such as MISNet need an edge to supervise. In foramen-like fading zones that edge does not exist, and MISNet reports no connectivity metric. We add a boundary-attention baseline on the same backbone to test whether sharper edges alone reduce breaks.
Proposed Experiments
Datasets. The primary testbed is the mandibular canal in CBCT. We use the dataset Lv et al. report on, listed in the file as Cipriano/ToothFairy; split details must be confirmed before use. We stratify foramen-adjacent head and tail segments as the fading zone. Secondary testbeds are TopCoW and OCTA-500 for multi-class vessels and ATM'22/BAS for airways. RoadTracer serves as an occlusion-driven control on which we expect the categorical-over-binary gain to be smaller.
Metrics.
- Betti Matching Error (Stucki et al.), overall and per contrast tercile.
- The fraction of cases in which the canal is predicted as a single connected component.
- Recall of the terminal 10 mm of the canal.
- Dice, HD95 and clDice to confirm overlap is not sacrificed.
- On airways: Tree Length Detected and Branches Detected.
- On roads: TLTS, against TopoAL's reported 0.388.
No reported result was found on Lacuna for Betti Matching Error, terminal recall or connectivity rate on the mandibular canal. On OCTA-500, no reported Betti Matching Error was found. These baselines will be established by our own reruns.
Decisive checks. Three outcomes would settle the claim.
- Categorical versus binary on identical labels. The categorical judge must beat the binary one on Betti Matching Error in the lowest-contrast tercile, across at least three seeds with non-overlapping confidence intervals. If it does not, the central idea is wrong.
- Gradient alignment. The categorical judge's generator gradients for break and bridge patches must be measurably less aligned with each other than the binary judge's, and must concentrate more inside the error region. This directly tests the AM-GAN-derived mechanism rather than inferring it from end metrics.
- Beating direct Betti matching where it is blind. In the fading stratum, the judge, alone or combined with the Betti matching loss, must reduce disconnections relative to Betti matching alone at equal wall-clock compute.
If the judge helps only where Betti matching already works, the proposal reduces to an expensive approximation of a known loss, and we would say so.
References
- Activation Maximization Generative Adversarial Nets
- TopoAL: An Adversarial Learning Approach for Topology-Aware Road Segmentation
- Topologically Faithful Image Segmentation via Induced Matching of Persistence Barcodes
- Topologically Faithful Multi-class Segmentation in Medical Images
- clDice - A Novel Topology-Preserving Loss Function for Tubular Structure Segmentation
- Automatic segmentation of mandibular canal using transformer based neural networks
- Enhancing Boundary Segmentation for Topological Accuracy with Skeleton-based Methods
- Accurate Airway Tree Segmentation in CT Scans via Anatomy-Aware Multi-Class Segmentation and Topology-Guided Iterative Learning
- Multi-scale information sharing and selection network with boundary attention for polyp segmentation