Skip to content

NormalizeLabelsInDatasetd to lost Meta Information  #921

@tangy5

Description

@tangy5

Describe the bug
During handling a discussion problem with a user, I found the transformation NormalizeLabelsInDatasetd in deepedit has some issues to be compatible with MetaTensor. It seems the meta information after NormalizeLabelsInDatasetd will be lost.

Version: latest MONAI and MONAILABEL release.

To Reproduce

from monai.transforms import (
    EnsureChannelFirstd,
    LoadImaged,
    SaveImaged,
    Compose,
    Orientationd
)
from monai.apps.deepedit.transforms import (
    NormalizeLabelsInDatasetd,
)

_labels = {'cancer': 1, 'transfer': 2, 'background': 0}

train_transforms = Compose(
    [
        LoadImaged(keys=("label"), reader="ITKReader"),
        NormalizeLabelsInDatasetd(keys=("label"), label_names=_labels),
        EnsureChannelFirstd(keys=("label")),
        Orientationd(keys=("label"), axcodes="RAS"),
        #========================================================================
        SaveImaged(keys="label", output_dir = './', mode='bilinear', output_postfix='label2')
    ]
)

image_path = [{'label': '/home/yuchengt/yuchengt/2022/MONAI/monailabel_projectYT/MONAILabel-main/test_data/HNC/labels/original/NPC_AI_Detectionl_01.nii.gz'}]
train_transforms(image_path)

Behavior

isinstance(img, MetaTensor) will be True, but img.meta will lost meta information.

KeyError: 'filename_or_obj'

The tested data can be downloaded via the link that the user provided:

https://drive.google.com/file/d/1VSHNW1m3mLZDch60S_LdHF62kUdiCai_/view?usp=sharing

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