Medical Transformer: Gated Axial-Attention for Medical Image Segmentation

Jeya Maria Jose Valanarasu, Poojan Oza, Ilker Hacihaliloglu, Vishal M. Patel

Abstract

Convolutional Neural Networks (CNNs) have long dominated medical image segmentation but often struggle to capture long-range dependencies due to their inherent local inductive bias. While Transformers offer a solution through self-attention, they typically require massive datasets to train effectively—a luxury rarely available in medical imaging. This paper introduces the Medical Transformer (MedT), which utilizes a novel Gated Axial-Attention mechanism and a Local-Global (LoGo) training strategy. These innovations allow the model to learn expressive representations from small-scale medical datasets. Evaluated on multiple datasets, MedT demonstrates superior performance over traditional CNNs and standard Transformer architectures.

Introduction

In medical image analysis, precise segmentation is critical for diagnosis and treatment planning. Architectures like U-Net have achieved significant success by leveraging convolutions. However, the limited receptive field of convolutional kernels prevents these models from understanding global context, which is often necessary to distinguish anatomical structures from background noise or artifacts.

Transformers, originally designed for natural language processing, have recently shown promise in computer vision by modeling long-range dependencies. However, standard Transformers face two major hurdles in the medical domain: high computational complexity ($O(N^2)$) and a requirement for large-scale pre-training. The Medical Transformer (MedT) addresses these challenges by refining the attention mechanism and optimizing the training strategy for limited data regimes.

Proposed Methodology

Gated Axial-Attention

To reduce computational overhead, MedT employs Axial-Attention, which decomposes 2D self-attention into two 1D operations along the height and width axes. To make this architecture robust for small datasets, the authors introduce a Gating mechanism. In standard axial attention, positional embeddings are added to queries, keys, and values to provide spatial context. However, on small datasets, these embeddings can be noisy and difficult to learn. MedT introduces four learnable gates ($G_Q, G_K, G_{V1}, G_{V2}$) that control the influence of these positional encodings, allowing the model to prioritize reliable features during training.

Local-Global (LoGo) Training Strategy

To capture both high-level context and fine-grained details, MedT uses a dual-branch training strategy called LoGo:

  1. Global Branch: Processes the entire image at its original resolution with fewer transformer layers to capture the overall structure and long-range dependencies.
  2. Local Branch: Operates on 16 smaller patches of the image ($I/4 \times I/4$) using a deeper stack of transformer layers to extract detailed local features.
The MedT architecture featuring the LoGo training strategy (a), the Gated Axial Transformer Layer (b), and the detailed Gated Axial Attention mechanism (c).

The features from both branches are eventually fused and passed through a $1 \times 1$ convolution to generate the final segmentation mask.

Experimental Results

MedT was evaluated on three datasets: Brain Ultrasound (US), Gland Segmentation (GlaS), and Multi-organ Nuclei Segmentation (MoNuSeg).

Quantitative Performance

MedT consistently outperformed standard U-Net and other Transformer-based baselines. On the Brain US dataset, MedT achieved an F1 score of 88.84, surpassing the standard U-Net (85.37). Notably, on the GlaS dataset—which contains only 85 training images—MedT reached an F1 of 81.02, significantly higher than the non-gated Axial-Attention baseline (76.26). This highlights the effectiveness of the gating mechanism in low-data scenarios.

Qualitative Analysis

Visual comparisons demonstrate that MedT produces cleaner segmentation masks with fewer false positives. By understanding global context, the model is better equipped to ignore background artifacts that might confuse a purely local CNN.

Qualitative comparison of segmentation results. (a) Input ultrasound image; (b-e) comparison of different segmentation outputs, where MedT (e) shows superior accuracy and fewer artifacts in the highlighted regions.

Conclusion

The Medical Transformer (MedT) successfully bridges the gap between the global modeling capabilities of Transformers and the data-constrained reality of medical imaging. By introducing Gated Axial-Attention and the LoGo training strategy, MedT provides a powerful alternative to traditional CNNs, achieving state-of-the-art results across various medical segmentation tasks. Future work may involve extending this architecture to 3D volumetric data and exploring more sophisticated feature fusion techniques.

Summary updated

BibTeX
@inproceedings{valanarasu2021medical,
  author = {Jeya Maria Jose Valanarasu and Poojan Oza and Ilker Hacihaliloglu and Vishal M. Patel},
  title = {{Medical Transformer: Gated Axial-Attention for Medical Image Segmentation}},
  booktitle = {International Conference on Medical Image Computing and Computer-Assisted Intervention},
  year = {2021},
  url = {https://openreview.net/forum?id=6a_H3KhBflI},
}
Figure