Manuscript Offprint

arXiv:2611.07431

TRiST: Topology-Reinforced Swin Transformer for Medical Image Analysis

Pengfei Gu, Huimin Li, Guangyu Meng, Hao Zheng, Haoteng Tang, Bin Fu, Danny Z. Chen

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Topological patterns in medical images, such as connected components and loops, across multiple spatial scales carry critical structural information, from microaneurysm-scale lesions to organ-level boundaries. Despite the success of hierarchical Vision Transformers (e.g., Swin Transformer) in medical image analysis, existing methods lack an explicit architectural scheme to represent and incorporate multi-scale topological structures through the Transformer hierarchy. In this paper, we propose Topology-Reinforced Swin Transformer (TRiST), a new Swin Transformer model family for medical image analysis, which reinforces multi-scale hierarchical topology into the hierarchical Transformer architecture. Instead of treating topology as an auxiliary descriptor or post hoc fusion cues, TRiST takes topology as a native part of representation construction, refinement, and token interaction. First, because topology does not compose hierarchically through pooling or interpolation, we develop a Hierarchical Multi-Scale Topology Representation algorithm that computes 2D persistent homology (H0H_0 and H1H_1 on image patches) at each native scale of Swin Transformer, constructing four topological representations aligned 1-to-1 with the Swin token grid. Second, motivated by the persistence lifetime of topological features, we develop a Band-Aware H0/H1H_0/H_1 Residual Refinement module that separately processes short-, medium-, and long-persistence information using dedicated gated residual MLPs. Third, we introduce a Persistence-Band Progressive Attention Bias that converts stage-specific topological descriptors into learned key-saliency scores and injects them into shifted-window attention logits. Based on these strategies, we instantiate two task-specific models: Topo-SwinV2-B for classification and Topo-Swin-UNet for segmentation. Both models retain the original Swin-based backbone structure while equipping it with native multi-scale topological features. Experiments on five medical image datasets show consistent improvements over Swin-based baselines and competitive performance relative to existing topology-augmented methods.

1 Introduction

Medical image analysis benefits largely from models that jointly capture fine-grained local appearance and large-scale structural organization [29, 1, 4, 49, 32]. In many medical imaging applications, spatial organization and structural patterns provide complementary information to photometric and semantic representations. In diabetic retinopathy grading, microaneurysms manifest as small isolated

40th Conference on Neural Information Processing Systems (NeurIPS 2026).

connected components whose number and spatial distribution across retinal quadrants determine the disease severity [39, 31]. In dermoscopy, malignant lesions exhibit irregular boundary loops and asymmetric connected structures that distinguish them from benign nevi [16, 36, 35, 37]. In cardiac MRI, the myocardium forms a closed annular boundary whose topological integrity is clinically meaningful [14]. In mammography, suspicious microcalcification clusters form spatially distributed point sets whose connectivity and persistence distinguish malignant from benign cases [41]. In these examples, the relevant signals span multiple spatial scales: fine-scale topology captures local lesion structures, intermediate-scale topology captures vascular connectivity and tissue boundaries, and coarse-scale topology captures global anatomical enclosures and organ-level distributions. Such topological properties, e.g., connected components and loops captured by H0H_{0} and H1H_{1} persistent homology (PH) [13] on 2D image patches and their birth and death across filtration thresholds, are not captured well by pixel intensity alone. An explicit multi-scale representation of topological structures can largely boost the capability of deep learning (DL) models.

Despite the strong inductive bias that topology can provide for medical imaging, integrating PH into DL models remains an under-explored topic. Standard DL methods for medical image classification and segmentation (e.g., ResNet [20], SwinV2-B [33], U-Net [43], TransUNet [9], Swin-UNet [7], Attention U-Net [40], and UNETR [18]) operate purely on visual features with no representation of topological persistence. Topology-guided loss approaches [23, 24, 11, 45, 19] incorporate topological constraints into training objectives to encourage topologically correct predictions, but do not inject topology into intermediate feature representations; the model must still infer topological structures from visual features alone. Topology-as-features approaches learn from persistence diagrams (PDs) [2] directly or fuse persistence descriptors with visual features. PersLay [8] and PLLay [26] introduce learnable vectorization layers for PDs; PersFormer [42] embeds persistence features into Transformer architectures; PHG-Net [41] and its multi-scale extension [16] fuse multi-scale topological descriptors with CNN features for medical image classification. TopoTxR [46] extracts 1D (loop) and 2D (bubble) topological structures from breast DCE-MRI using PH and incorporates them into a 3D CNN with a topology-guided spatial attention mechanism, directing the model's focus toward biologically relevant voxels near fibroglandular tissue structures for pathological complete response prediction. While TopoTxR shows that topological structures can meaningfully guide spatial attention, it operates at a single spatial scale, applies topology as an external attention mask rather than an additive bias inside the attention logit, and is designed for a 3D CNN rather than a hierarchical Vision Transformer. More broadly, known topology-as-features methods [8, 26, 42, 47, 27, 15, 36, 35, 16, 21, 41] typically fuse topology at a single scale or as a global descriptor, losing the spatial localization and scale correspondence essential for dense prediction tasks. More importantly, these methods do not compute topology at multiple scales natively and directly from raw images, and do not place topology inside the attention computation of a hierarchical Vision Transformer to directly modulate which tokens communicate with one another at each spatial scale.

In this work, we aim to show that hierarchical Vision Transformers, and in particular Swin Transformer [33], are naturally compatible with multi-scale topology computation and integration. By applying shifted-window self-attention at four progressively coarser spatial resolutions, the Swin hierarchy defines four distinct spatial scales, each with a well defined token stride and spatial support. This hierarchy provides a principled scaffold for multi-scale topology: computing topology at the four native resolutions of the Swin hierarchy ensures that each topological representation is spatially aligned with the corresponding Swin feature map by construction, without requiring any resizing, pooling, or interpolation. However, exploiting this compatibility requires overcoming two non-trivial obstacles: (1) How to compute topological representation at each scale correctly and (2) how to inject topology into the attention mechanism in order to directly modulate token communication.

We propose Topology-Reinforced Swin Transformer (TRiST), a new Swin Transformer model family, which reinforces multi-scale hierarchical topology in the hierarchical Transformer architecture. Our design is guided by the following observations. (1) Topology does not compose hierarchically. A simplest approach to compute multi-scale topology is to compute a single topology representation at the finest resolution and downsample it to coarser stages via pooling or interpolation. However, this is fundamentally flawed: the PD of a large region captures qualitatively different topological patterns than the average of many small-region PDs, because global structures such as vessel loops and organ enclosures may become complete only at an appropriate spatial scale. Thus, downsampling a fine-scale topological representation can destroy scale-specific semantic content that

Figure

Figure 1: (a) The overall architecture of our Topology-Reinforced Swin Transformer (TRiST). In parallel to the Swin backbone, we pre-compute hierarchically aligned multi-scale topological representations at four native scales. (b) The structure of a TRiST block. Each stage-specific topological representation is normalized and refined by the proposed Band-Aware H0/H1H_0/H_1 Residual Refinement module, and then decomposed into persistence bands to construct an additive topology bias for window attention. The resulting topology bias is injected into the attention logits together with the relative position bias. Stages 1, 2, and 3–4 use short, medium, and long bands, respectively.

makes topology comprehensive. We develop a Hierarchical Multi-Scale Topology Representation algorithm that computes PH independently at each stage-specific native scale, producing four topology representations that are aligned 1-to-1 with the Swin token grid at each stage. (2) The persistence axis of PD has semantic meaning. Note that features near the diagonal of a PD have short lifetime and correspond to ephemeral events such as noise and fine texture, while features far from the diagonal have long lifetime and encode stable structures such as organ boundaries, vessel walls, and lesion clusters. Treating all persistence elements uniformly with a single MLP conflates noise-level features with structurally significant ones, and can lead the model to inadvertently suppress diagnostically relevant long-lifetime features. We design a Band-Aware H0/H1H_0/H_1 Residual Refinement module that independently refines each of six persistence lifetime sub-bands (i.e., H0H_0 and H1H_1 each split into short, medium, and long persistence) using dedicated gated residual MLPs, respecting both the semantic structure of the persistence axis and the geometric distinction between connectivity (H0H_0) and enclosure (H1H_1). (3) Topologically salient tokens should attract stronger attention. Tokens corresponding to microaneurysms, vessel junctions, or boundary segments have high topological salience, and their local persistence descriptors encode structurally significant events relative to surrounding background tokens. Standard shifted-window self-attention learns content-dependent token interactions but does not explicitly incorporate persistence-derived structural salience. We propose a Persistence-Band Progressive Attention Bias that adds an outer-sum topology bias to the attention logits. After row-wise softmax, the query-dependent component of the outer-sum bias cancels, leaving an effective topology-conditioned key-saliency prior. Consequently, tokens assigned higher topology scores can contribute more strongly to the updated representations of neighboring query tokens.

We instantiate our TRiST framework using two specific architectures: Topo-SwinV2-B for medical image classification built on Swin Transformer [33], and Topo-Swin-UNet for medical image segmentation built on Swin-UNet [7]. Both models share the same topology pipeline and require no structural changes to the original backbones. On benchmark datasets that include dermoscopy classification (ISIC 2018), mammography classification (CBIS-DDSM), retinal grading (RetinaMNIST), multi-organ CT segmentation (Synapse), and cardiac MRI segmentation (ACDC), both architectures consistently improve over their strong Swin-based baselines and achieve competitive performance relative to topology-augmented methods, with only negligible additional parameter costs.

References (47)