Skip to content

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

@perctrix

Description

@perctrix

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions