Medical Image Segmentation Using Directional Window Attention

Daniya Najiha Abdul Kareem, Mustansar Fiaz, Noa Novershtern, Hisham Cholakkal

TL;DR

DwinFormer is a new hierarchical encoder-decoder architecture that tackles the precision-efficiency trade-off in 3D medical image segmentation. By introducing Directional Window (Dwin) attention, which separately processes information along horizontal, vertical, and depthwise axes, the model captures both fine-grained local details and broad global context more effectively than standard Transformers or CNNs.

What Problem Does This Paper Address?

Accurate segmentation of 3D medical images (like CT scans) is a high-stakes task. Doctors need to know exactly where a tumor ends and healthy tissue begins. Traditionally, researchers used Convolutional Neural Networks (CNNs), but these have a "limited receptive field"—they are great at seeing textures but struggle to understand the overall shape of large organs.

Transformers recently stepped in to solve this by using self-attention to look at the whole image at once. However, this comes with two big headaches:

  1. Computational Cost: Standard self-attention has "quadratic complexity," meaning the processing power needed explodes as image resolution increases.
  2. Loss of Detail: While Transformers are great at the "big picture," they often miss the pixel-precise local information needed for sharp boundaries.

The authors of DwinFormer aim to bridge this gap, creating a model that is computationally efficient enough for 3D data while remaining precise enough for clinical use.

Methods

The core innovation is the Dwin Block, which replaces standard attention layers in the high-resolution stages of a hierarchical U-Net-style architecture.

Fig. 1: (a) Overall architecture of the proposed DwinFormer having a hierarchical encoder-decoder framework. In the encoder, the stem features are input to the directional window (Dwin) block to explicitly learn the local and global dependencies at high resolution in the initial two stages of the encoder, whereas global self-attention (GSA) block is applied in the later two stages to capture the global information. In the decoder, the features are first upsampled and then added with the encoder features using a skip connection. The focus of our design is the introduction of (b) Dwin block into DwinFormer, enabling the effective capturing of local and global information in multiple directions within the input feature map. The Dwin block consists of two components:(c) nested Dwin attention (NDA) that gradually expands the receptive field in the depthwise, horizontal and vertical directions, and (d) convolutional Dwin attention (CDA) that strives to capture local contextual information using depthwise convolution during the attention computation,. (e) shows the qkv computation for attention in (i) Nested Dwin Attention (NDA) (ii) Convolutional Dwin Attention (CDA). The NDA employs a linear layer to obtain qkv while CDA additionally captures local information using a depthwise convolution.

The Dwin Block consists of two specialized layers:

  • Nested Dwin Attention (NDA): Instead of looking at the entire 3D volume at once, it splits the attention task. It performs attention along the horizontal, vertical, and depthwise volumes separately. This progressively increases the receptive field without the massive computational overhead of full 3D attention.
  • Convolutional Dwin Attention (CDA): To ensure the model doesn't lose track of local textures, this layer incorporates a 5x5 depthwise convolution during the attention calculation. This "injects" local context back into the Transformer's global view.

The overall architecture is hierarchical: the first two stages use Dwin blocks to handle high-resolution details, while the final two stages use Global Self-Attention (GSA) to capture the broadest possible context once the data has been downsampled.

Datasets

The researchers evaluated DwinFormer on two distinct challenges:

  1. 3D Synapse Multi-organ dataset: A collection of 30 abdominal CT scans. The task is to segment eight different organs (liver, kidneys, spleen, etc.), which vary wildly in size and shape.
  2. Cell HMS dataset: 3D microscopic images of zebrafish cells. This tests the model's ability to handle high-density, small-scale structures with complex boundaries.

Key Insights and Ideas

  • Directional Decomposition is Key: The paper demonstrates that you don't need to attend to every voxel in a 3D space simultaneously. By breaking attention down into H, V, and D directions, you can capture long-range dependencies much more efficiently.
  • The Order Matters: Through ablation studies, the authors found that the sequence of directional attention impacts performance. The most effective order was found to be Depthwise → Horizontal → Vertical (see Table 4 in the paper).
  • Hybrid Strengths: DwinFormer proves that a "one size fits all" attention mechanism isn't always best. Using directional windows for high-res stages and global attention for low-res stages provides a superior balance of precision and context.

Key Results

DwinFormer achieved state-of-the-art (SOTA) results on both benchmarks, outperforming well-known models like UNETR and nnFormer.

  • Synapse Dataset: It achieved a Dice Similarity Coefficient (DSC) of 87.38% and a significantly lower Hausdorff Distance (HD95) of 8.68, indicating much more accurate boundary detection compared to nnFormer (86.57% DSC / 10.63 HD95).
  • Organ-Specific Wins: The model showed particularly strong improvements in segmenting the left kidney, right kidney, and gallbladder—organs that are notoriously difficult due to their complex boundaries.
Fig. 2: Qualitative analysis on multi-organ synapse dataset [20] shows that our method provides improved segmentation by accurately detecting the organs with clear boundaries.

On the Cell HMS dataset, DwinFormer also led the pack, showing superior performance in cell count accuracy and overall segmentation overlap (JI and DSC metrics).

Limitations and Future Work

While the paper demonstrates clear improvements, a few areas remain for exploration:

  • Dataset Scale: The experiments were conducted on relatively small datasets (30-36 images). Testing on larger, more diverse clinical datasets would further validate the model's robustness.
  • Computational Efficiency: Although Dwin attention is designed to be more efficient than global attention, the paper does not provide a detailed breakdown of inference speed or memory usage compared to pure CNN approaches, which is often a concern for real-time clinical applications.

The authors suggest that the Dwin block's ability to handle directional dependencies makes it a promising candidate for other volumetric tasks beyond just medical segmentation.

Summary updated

BibTeX
@inproceedings{kareem2024medical,
  author = {Daniya Najiha Abdul Kareem and Mustansar Fiaz and Noa Novershtern and Hisham Cholakkal},
  title = {{Medical Image Segmentation Using Directional Window Attention}},
  booktitle = {ISBI},
  year = {2024},
  doi = {10.1109/isbi56570.2024.10635414},
}
Figure