research-contributions icon indicating copy to clipboard operation
research-contributions copied to clipboard

UNETR implementation incompatible with MONAI >= 1.3.0 due to deprecated pos_embed parameter

Open perctrix opened this issue 3 months ago • 0 comments

Describe the bug The UNETR implementation in the research-contributions repository uses an outdated parameter name pos_embed that is incompatible with MONAI versions >= 1.3.0. Starting from MONAI 1.3.0, the parameter was renamed from pos_embed to proj_type in the ViT class.

To Reproduce Steps to reproduce the behavior:

  1. Install MONAI >= 1.3.0 (tested with MONAI 1.5.0)
  2. Clone the research-contributions repository
  3. Navigate to UNETR/BTCV/networks/unetr.py
  4. Try to instantiate the UNETR model:
from networks.unetr import UNETR
model = UNETR(in_channels=1, out_channels=14, img_size=(96, 96, 96))
  1. Observe the error when ViT is initialized with pos_embed parameter

Expected behavior The UNETR model should work with current MONAI versions without parameter compatibility issues. The parameter should be proj_type for MONAI >= 1.3.0.

Screenshots N/A

Environment (please complete the following information):

  • OS: Windows 11
  • Python version: 3.12.8
  • MONAI version: 1.5.0
  • PyTorch version: 2.8.0+cu129
  • CUDA/cuDNN version: CUDA 12.9
  • GPU models and configuration: NVIDIA GeForce RTX 4060 Laptop GPU

Additional context The issue affects users trying to use the UNETR implementation with newer MONAI versions. A simple fix would be to:

  1. Update line 37 from pos_embed: str = "perceptron" to proj_type: str = "perceptron"
  2. Update line 96 from pos_embed=pos_embed to proj_type=proj_type
  3. Update the docstring and examples accordingly

This change would maintain backward compatibility if the minimum supported MONAI version is updated to 1.3.0, or alternatively, a version check could be implemented to support both parameter names.

perctrix avatar Sep 23 '25 14:09 perctrix