Building 3D In-Context Learning Universal Model in Neuroimaging

Jiesi Hu, Hanyang Peng, Yanwu Yang, Xutao Guo, Yang Shang, Pengcheng Shi, Chenfei Ye, Ting Ma · OpenReview

Abstract

In-context learning (ICL), a type of universal model, demonstrates exceptional generalization across a wide range of tasks without retraining by leveraging task-specific guidance from context, making it particularly effective for the complex demands of neuroimaging. However, existing ICL models, which take 2D images as input, struggle to fully leverage the 3D anatomical structures in neuroimages, leading to a lack of global awareness and suboptimal performance. In this regard, we introduce Neuroverse3D, an ICL model capable of performing multiple neuroimaging tasks (e.g., segmentation, denoising, inpainting) in 3D. Neuroverse3D overcomes the large memory consumption due to 3D inputs through adaptive parallel-sequential context processing and a U-shape fusion strategy, allowing it to handle an unlimited number of context images. Additionally, we propose an optimized loss to balance multi-task training and enhance the focus on anatomical structures. Our study incorporates 43,674 3D scans from 19 neuroimaging datasets and evaluates Neuroverse3D on 14 diverse tasks using held-out test sets. The results demonstrate that Neuroverse3D significantly outperforms existing ICL models and closely matches the performance of task-specific models.

Introduction

In-context learning (ICL) has revolutionized 2D image analysis by allowing models to perform new tasks simply by observing a few example pairs. However, applying this to 3D neuroimaging (MRI and CT) presents a significant dimensionality challenge. A 3D volume can be over 100 times larger than a 2D slice. Previous "universal" models often process 3D volumes as a series of 2D slices, which loses critical "inter-slice correlation" and results in poor performance on complex anatomical regions like the hippocampus. Furthermore, the memory required to process multiple 3D context pairs simultaneously exceeds current hardware capacities.

Methodology

Neuroverse3D Architecture

Neuroverse3D utilizes a dual-branch 3D U-Net architecture consisting of a Target Branch and a Context Branch. Unlike previous models that utilize one-way information flow, Neuroverse3D employs a U-shaped Fusion Strategy. During encoding, features from the target image are sent to the context branch; during decoding, fused context information is returned to the target branch to guide the final prediction.

Figure 1: The Neuroverse3D architecture featuring dual-branch processing and U-shaped fusion between target and context representations.

Adaptive Parallel-Sequential Processing (APSP)

To solve the memory bottleneck of 3D data, we introduced Adaptive Parallel-Sequential Processing (APSP). Instead of loading all context examples at once (Parallel) or processing them strictly one-by-one (Sequential), APSP partitions context into "mini-contexts." These are processed in parallel to capture local features, but their representations are fused sequentially. By discarding intermediate features after they contribute to the global mean, the model can handle an theoretically unlimited number of context images on a single GPU.

Figure 2: Comparison of context processing modes. APSP (Adaptive) maintains the memory efficiency of sequential processing while achieving the representational power of parallel processing.

Optimized Loss Function

To address the extreme class imbalance in 3D segmentation, where target structures may be very small, we developed a modified $L_{smooth-L1}$ loss with a higher exponent. This forces the model to prioritize accuracy on difficult anatomical boundaries.

Experimental Results

Dataset and Training

The model was trained on a massive dataset of 43,674 3D multi-modal scans from 19 neuroimaging benchmarks (e.g., BraTS, ADNI, UK Biobank). Tasks included anatomical and tumor segmentation, denoising, inpainting, and modality transformation.

Performance and Efficiency

  • Accuracy: Neuroverse3D outperformed state-of-the-art 2D ICL models (UniverSeg, SegGPT) by over 20 Dice points in complex segmentation tasks. It frequently matched the performance of task-specific specialist models.
  • Inference Speed: Neuroverse3D processes a full 3D volume in 1.01 seconds. In contrast, 2D models like SegGPT require over 184 seconds because they must redundantly re-calculate context for every individual slice.
  • Generalization: The model showed strong performance even on "unseen" tasks (e.g., PET scan segmentation), suggesting it learns the underlying logic of neuroimaging rather than just memorizing patterns.

Conclusion

Neuroverse3D is the first universal ICL model designed specifically for 3D neuroimaging. By overcoming memory constraints through APSP and maintaining 3D spatial awareness, it provides a scalable, efficient foundation for diverse clinical tasks. Future work will focus on increasing the diversity of generation tasks and expanding the model's application to other 3D medical imaging domains.

Summary updated

BibTeX
@misc{hu2025building,
  author = {Jiesi Hu and Hanyang Peng and Yanwu Yang and Xutao Guo and Yang Shang and Pengcheng Shi and Chenfei Ye and Ting Ma},
  title = {{Building 3D In-Context Learning Universal Model in Neuroimaging}},
  year = {2025},
  eprint = {2503.02410},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.02410},
}
Figure