---
title: 'TopoTTA: Topology-Enhanced Test-Time Adaptation'
url: https://www.emergentmind.com/topics/topology-enhanced-test-time-adaptation-topotta
type: topic
---

# TopoTTA: Topology-Enhanced Test-Time Adaptation

Searching arXiv for the specified TopoTTA and related topology-aware test-time adaptation papers.
arXiv search query: all:"TopoTTA" OR ti:"Topology-enhanced Test-Time Adaptation" OR ti:"Test-Time Adaptation for Anomaly Segmentation via Topology-Aware Optimal Transport Chaining" OR ti:"Learning Topology-Aware Representations via Test-Time Adaptation for Anomaly Segmentation"
Topology-enhanced Test-Time Adaptation (TopoTTA) is a test-time adaptation framework that incorporates topological priors into deployment-time model updating under domain shift. In its original and most specific usage, TopoTTA denotes a two-stage framework for tubular structure segmentation (TSS), where domain adaptation must preserve connectivity and continuity in thin, elongated foregrounds such as retinal vessels, roads, neuronal processes, and OCTA vessels [2508.00442]. Related later work extended the broader idea of topology-aware TTA to anomaly segmentation, but the canonical TopoTTA formulation is the TSS method built from Topological Meta Difference Convolutions (TopoMDCs) and Topology Hard sample Generation (TopoHG) [2508.00442].

## 1. Scope, motivation, and problem setting

Tubular structure segmentation is unusually sensitive to domain shift because errors affect both appearance and topology. The original TopoTTA formulation distinguishes **appearance shifts**—including changes in contrast, noise, texture, imaging device, and acquisition style—from **topological shifts**, including changes in trajectory, curvature, branching patterns, and thickness [2508.00442]. In TSS, a small number of incorrect pixels can interrupt a centerline, create gaps, destroy skeleton connectivity, or inflate topology errors. Consequently, overlap-oriented adaptation alone is inadequate.

The source-to-target TTA setting used by TopoTTA is standard. A labeled source dataset is written as
$$
\mathcal D^s=\{(\mathbf x_i^s,\mathbf y_i^s)\}_{i=1}^{N^s},
$$
and a model $\mathcal F(\cdot;\theta^s)$ is first trained by
$$
\theta^s = \arg\min_{\theta^s}\; \mathbb{E}_{(\mathbf x^s,\mathbf y^s)\sim \mathcal D^s}
\left[\mathcal L_{seg}(\mathcal F(\mathbf x^s;\theta^s),\mathbf y^s)\right].
$$
The target dataset is unlabeled,
$$
\mathcal D^t=\{\mathbf x_i^t\}_{i=1}^{N^t},
$$
and online per-image adaptation follows
$$
\theta_i^t = \arg\min_{\theta_{i-1}^t}\mathcal L_{tta}(\mathcal F(\cdot;\theta_{i-1}^t), \mathbf x_i^t),
$$
with $\theta_0^t=\theta^s$ [2508.00442].

Within this setting, TopoTTA is described as the first test-time adaptation framework designed specifically for TSS. The central premise is that TTA for tubular structures must address both **topological discrepancy** across domains and **fragile continuity** inside predicted structures. This suggests a division of labor between a structural adaptation stage and a continuity-restoration stage, which is exactly how the framework is organized.

## 2. Two-stage architecture

TopoTTA consists of two stages [2508.00442]. **Stage 1, Topological Structure Adaptation**, uses Topological Meta Difference Convolutions to adapt representations to domain-specific topological patterns while updating only a small set of router parameters. **Stage 2, Topological Continuity Refinement**, uses Topology Hard sample Generation to synthesize local pseudo-breaks and trains the model to recover continuity by prediction alignment on these hard samples.

| Stage | Main mechanism | Function |
|---|---|---|
| Stage 1 | TopoMDCs | Adapt to cross-domain topological discrepancies |
| Stage 2 | TopoHG + prediction alignment | Improve topological continuity on hard samples |

This decomposition is technically important. Stage 1 targets structural changes in tubular geometry, while Stage 2 targets local foreground-background discrimination around critical regions where continuity is easily broken. A common misconception is that topology-aware TTA necessarily means direct topological loss optimization over the whole model. In TopoTTA, the adaptation is more constrained: pretrained convolution weights are preserved in Stage 1, and the second stage uses teacher-student consistency on synthesized pseudo-break regions rather than whole-network retraining [2508.00442].

The framework is designed as a plug-and-play TTA solution for CNN-based TSS models. It is evaluated with U-Net and CS2Net, and a variant is also reported on DSCNet. TopoMDCs replace all $3\times3$ convolution layers in the encoder, while Stage 2 adds the teacher-student refinement branch [2508.00442].

## 3. Stage 1: Topological Meta Difference Convolutions

TopoMDCs are motivated by the limitations of Central Difference Convolution (CDC). CDC emphasizes local differences between a center pixel and its neighbors, but the TopoTTA paper argues that TSS requires explicit modeling of directional elongation, continuity along curves, and local tubular topology such as branches, bends, and thin junctions [2508.00442].

For a $3\times3$ neighborhood,
$$
\mathcal R = \{(1,1),(0,1),\cdots,(-1,0),(-1,-1)\},
$$
the vanilla convolution is
$$
\mathcal C_0(r_x,r_y) = \sum_{(\Delta r_x,\Delta r_y)\in\mathcal R} w(\Delta r_x,\Delta r_y)\cdot \mathbf x_{in}(r_x-\Delta r_x,r_y-\Delta r_y).
$$
CDC is described in center-difference form as
$$
\mathcal C_c(r_x,r_y) = \sum_{(\Delta r_x,\Delta r_y)\in\mathcal R} w(\Delta r_x,\Delta r_y)\cdot \mathbf x_{in}(r_x,r_y).
$$
TopoMDCs then define eight directional operators,
$$
\{\mathcal C_1,\mathcal C_2,\ldots,\mathcal C_8\},
$$
to encode eight directional topological patterns [2508.00442].

For example, the top-left directional operator is
$$
\begin{split}
\mathcal C_1(r_x,r_y) &= \mathcal C_c(r_x,r_y) - \sum_{(\Delta r_x,\Delta r_y)\in\mathcal R_1} w(\Delta r_x,\Delta r_y)\cdot \mathbf x_{in}(r_x,r_y) \\
&\quad + \sum_{(\Delta r_x,\Delta r_y)\in\mathcal R_1} w(\Delta r_x,\Delta r_y)\cdot \mathbf x_{in}(r_x+1,r_y+1),
\end{split}
$$
with
$$
\mathcal R_1=\{(-1,-1),(-1,0),(0,-1)\}.
$$
The appendix provides analogous definitions for the other seven directions, spanning orthogonal and diagonal patterns [2508.00442].

A distinctive design choice is that TopoMDCs do **not** introduce new parameters into convolution layers and **inherit the pretrained convolution weights**. Instead, the method patchifies the input into $n\times n$ non-overlapping patches and learns patch-specific routing weights $\boldsymbol\delta$. For patch $\mathbf p_j$, the output feature is
$$
\hat{\mathbf x}_{out} = \mathcal C_0(\mathbf x_{in}) - \sum_{j=1}^{n\times n}\boldsymbol\delta_j \sum_{i=1}^8 \mathcal C_i(\mathbf x_{in}^j).
$$
Here, $\mathcal C_0$ supplies the standard convolutional response, the eight $\mathcal C_i$ terms inject directional topology-aware differences, and $\boldsymbol\delta_j$ selects directionally relevant patterns on a patch basis [2508.00442].

Stage 1 adapts only the router parameters via entropy minimization:
$$
\mathcal L_{EM} = -\sum_{j=1}^2 \hat y_j \log(\hat y_j),
$$
with update rule
$$
\boldsymbol\delta = \arg\min \mathcal L_{EM}(\mathcal F(\cdot;\theta^t;\boldsymbol\delta),\mathbf x).
$$
The stated rationale for updating only $\boldsymbol\delta$ is to reduce search-space complexity, avoid interference between parameter updates, preserve pretrained representations, and provide sample-specific topological adaptation with greater stability [2508.00442]. This is empirically reinforced by the ablation in which updating all parameters underperforms router-only updating.

## 4. Stage 2: Topology Hard sample Generation and continuity refinement

Stage 2 addresses continuity failures that persist after structural adaptation. The mechanism is Topology Hard sample Generation, which constructs pseudo-break regions that resemble broken tubular structures and then trains the model to recover continuity under teacher-student prediction alignment [2508.00442].

The first step is confident key-point selection. Given teacher prediction $\hat{\mathbf y}'$, the method keeps
$$
\mathcal P=\{(u,v)\mid \hat{\mathbf y}'(u,v)>\tau\}, \quad \tau=0.95,
$$
then randomly samples
$$
N_p = k \cdot |\mathcal P|
$$
points from $\mathcal P$. The number of sampled points therefore grows with the amount of highly confident foreground [2508.00442].

The second step slides a background window around each selected foreground point. For a point $(u_c,v_c)$, a foreground window $\mathbf x_p^{fg}$ of size $s\times s$ is centered on the point, and a same-sized background window is searched over nearby non-overlapping areas to find the region $\mathbf x_p^{bg,*}$ with the lowest pseudo-label confidence. A lower threshold $\tau^{bg}$ rejects candidate background windows that still contain too much foreground [2508.00442].

The third step creates pseudo-breaks through low-frequency swapping in the Fourier domain. With FFT, inverse FFT, and low-frequency mask $\mathbf m_{low}$,
$$
\mathbf f_p^{fg}=\text{FFT}(\mathbf x_p^{fg}), \qquad \mathbf f_p^{bg}=\text{FFT}(\mathbf x_p^{bg,*}),
$$
and
$$
\mathbf x_p^{swap} = \text{iFFT}\Big( \mathbf f_p^{fg}\cdot(1-\mathbf m_{low}) + \mathbf f_p^{bg}\cdot \mathbf m_{low} \Big).
$$
Foreground pixels from the pseudo-label are then selectively replaced:
$$
\mathbf x_p' = \mathbf x_p^{swap}\cdot \hat{\mathbf y}_p' + \mathbf x_p^{fg}\cdot (1-\hat{\mathbf y}_p').
$$
The resulting patch $\mathbf x_p'$ is intended to weaken continuity while preserving essential foreground structure and avoiding the unnatural artifacts associated with crude corruption [2508.00442].

Prediction alignment uses a teacher-student scheme. The teacher produces pseudo-labels $\hat{\mathbf y}'$ on the original image, while the student predicts $\hat{\mathbf y}''$ on the hard sample. The weighted consistency loss is
$$
\mathcal L_{CE} = -\sum_{(u,v)} \mathcal W(u,v)\cdot \Big( \hat{\mathbf y}'\log(\hat{\mathbf y}'') + \hat{\mathbf y}''\log(\hat{\mathbf y}') \Big),
$$
with weight map
$$
\mathcal W(u,v)=
\begin{cases}
10, & \text{if } (u,v)\in \mathbf x_p' \cdot \hat{\mathbf y}_p' \\
1, & \text{otherwise}.
\end{cases}
$$
The student is updated by
$$
\theta_i^t = \arg\min_{\theta_{i-1}^t}\mathcal L_{CE}(\mathcal F(\cdot;\theta_{i-1}^t;\boldsymbol\delta),\mathbf x),
$$
and the teacher is updated with EMA of student parameters [2508.00442]. Final inference is performed on the original, unmodified input.

## 5. Experimental profile, metrics, and ablations

TopoTTA is evaluated on 10 datasets grouped into four scenarios: retinal vessel segmentation (DRIVE, STARE, CHASEDB1), road extraction (DeepGlobe, Massachusetts road, CNDS), microscopic neuronal segmentation (Neub1, Neub2), and retinal OCT-angiography vessel segmentation (ROSE1, OCTA500) [2508.00442]. The reported metrics are Dice, clDice, and Betti error $\beta$, with clDice emphasized because it evaluates skeleton-level continuity.

The headline result is an average **31.81% improvement in clDice** over source-only testing across the four scenarios [2508.00442]. Average results over ten datasets are reported as follows.

| Backbone | Source Only | TopoTTA |
|---|---|---|
| U-Net | Dice 50.56, clDice 42.19, $\beta$ 51.94 | Dice 69.44, clDice 74.00, $\beta$ 43.01 |
| CS2Net | Dice 50.31, clDice 51.17, $\beta$ 54.35 | Dice 67.68, clDice 72.70, $\beta$ 43.86 |

Per-scenario examples further illustrate the topology-sensitive gains. On DRIVE $\rightarrow$ CHASE, TopoTTA reaches Dice 70.73, clDice 77.05, and $\beta$ 25.38. On CHASE $\rightarrow$ DRIVE, it reports Dice 72.96, clDice 70.26, and $\beta$ 79.15. On DeepGlobe $\rightarrow$ CNDS, it reports Dice 89.15, clDice 96.35, and $\beta$ 5.98. On ROSE $\rightarrow$ OCTA500, it reports Dice 70.70, clDice 78.24, and $\beta$ 31.88 [2508.00442].

The ablation studies support both stages. A representative ablation reports: baseline at Dice 65.37, clDice 61.69, $\beta$ 82.24; baseline + TopoMDCs at Dice 68.70, clDice 65.14, $\beta$ 76.28; baseline$^\star$ + TopoHG at Dice 68.82, clDice 66.61, $\beta$ 73.63; and full TopoTTA at Dice 69.87, clDice 67.81, $\beta$ 73.27 [2508.00442]. The TopoMDC variant study shows the full eight-direction set outperforming CDC-only, orthogonal-only, and diagonal-only alternatives. The TopoHG comparison against Gaussian blur, random Gaussian noise, and spatial image swap attributes its advantage to preserving high-frequency cues while generating realistic pseudo-breaks [2508.00442].

A practically important ablation compares updating all parameters with updating only the router parameters $\boldsymbol\delta$. The reported results favor router-only adaptation: Dice 70.73, clDice 77.05, $\beta$ 25.38 versus Dice 70.07, clDice 72.58, $\beta$ 30.23 when all parameters are updated. The paper also notes that $\boldsymbol\delta$ adds only **1280 parameters** [2508.00442]. This directly contradicts the assumption that stronger test-time adaptation necessarily requires broader parameter updates.

Implementation details reinforce the lightweight design: all datasets are resized to $384\times384$; test-time adaptation uses six iterations per image, split as three for Stage 1 and three for Stage 2; Adam is used with Stage 1 learning rate $0.01$ and Stage 2 learning rate $10^{-4}$; mask binarization uses threshold $0.5$; and key TopoMDC/TopoHG hyperparameters include $n\times n=4\times4$, window size $s=30$, and $\tau^{bg}=0.05$ [2508.00442].

## 6. Broader topology-aware TTA variants, limitations, and conceptual significance

Later work extended the same general intuition—topology as a deployment-time adaptation signal—into anomaly segmentation, but with a substantially different technical stack. A 2026 anomaly-segmentation method also named **TopoTTA** converts anomaly score maps into cubical complexes, computes persistent homology on sublevel and superlevel filtrations, retains the most persistent components as pseudo-labels, fuses them with an Euler-aware Intersection rule,
$$
Y = \operatorname{FixEuler}(A \cap B, A \cup B),
$$
and trains only a lightweight shallow MLP called PCES on frozen backbone features using a margin-based contrastive loss; it is evaluated on MVTec AD, VisA, Real-IAD, MVTec 3D-AD, AnomalyShapeNet, and MVTec LOCO, and reports an average $\sim 15\%$ F1 improvement over state-of-the-art methods [2606.28268]. A closely related framework, **TopoOT**, uses multi-filtration persistence diagrams and Optimal Transport Chaining to derive geodesic stability scores, generate stability-aware pseudo-labels, and adapt a lightweight head online; it reports gains of up to **+24.1% mean F1 on 2D datasets** and **+10.2% on 3D AS benchmarks** [2601.20333].

These anomaly-segmentation methods show that the phrase “topology-aware TTA” no longer refers to a single mechanism. In the original TSS TopoTTA, topology enters through directional convolutions and synthetic continuity breaks. In the anomaly-segmentation variants, topology enters through persistent homology, cubical complex filtrations, Euler-consistent fusion, and, in TopoOT, entropy-regularized optimal transport across persistence diagrams [2606.28268, 2601.20333]. A plausible implication is that the term now denotes a family of methods united more by their use of structural invariants during test-time updating than by any single architectural recipe.

The limitations of the original TopoTTA remain specific and concrete. It is designed for **CNN-based** architectures, not arbitrary backbones. Stage 2 adds runtime cost because it requires patch selection and pseudo-break synthesis. Hyperparameters such as patch size, region count, and confidence thresholds matter. For some challenging cases, clDice may be undefined when skeletonization fails. The DSCNet variant omits Stage 1 because deformable kernels reduce compatibility with TopoMDCs, indicating that TopoMDC integration is not universal across all architectures [2508.00442].

Conceptually, TopoTTA is significant because it reframes test-time adaptation for topology-sensitive segmentation as more than a distribution-calibration problem. In TSS, the framework explicitly separates adaptation to structural discrepancy from restoration of local continuity. In later anomaly-segmentation formulations, the same broader principle appears as persistent-homology-based pseudo-labeling that replaces brittle raw-score thresholding. Across these variants, the unifying proposition is that under domain shift, segmentation quality depends not only on confidence or pixel intensity but also on the preservation of connected components, holes, branch continuity, and related structural invariants [2508.00442, 2606.28268, 2601.20333].

Source: https://www.emergentmind.com/topics/topology-enhanced-test-time-adaptation-topotta