Skip to content

ImageFilterd removes applied_operations #7394

Closed
@vlaminckaxel

Description

@vlaminckaxel

Describe the bug
When ImageFilterd is in the transformation sequence it removes all the applied_operations from the history.
Now we cant inverse the transformation sequence!

To Reproduce

    LoadImaged,
    Spacingd,
    ImageFilterd,
    Compose,
)
import numpy as np

# applied operations are present in the output of the transform
image = np.random.rand(10, 10, 10)
transforms = Compose(
    [
        Spacingd(keys=["image"], pixdim=(1.0, 1.0, 1.0), mode=("bilinear")),
    ]
)
print(transforms({"image": image})['image'].applied_operations)

# applied operations are not present in the output of the transform when using ImageFilterd
image = np.random.rand(10, 10, 10)
transforms = Compose(
    [
        Spacingd(keys=["image"], pixdim=(1.0, 1.0, 1.0), mode=("bilinear")),
        ImageFilterd(keys=["image"], kernel="mean", kernel_size=3)
    ]
)

print(transforms({"image": image})['image'].applied_operations)

Output:

[]
[{class: 'SpatialResample', id: 140011668257424, tracing: True, do_transforms: True, orig_size: (10, 10), lazy: False, extra_info: {'dtype': 'float64', 'mode': 'bilinear', 'padding_mode': 'border', 'align_corners': False, 'src_affine': tensor([[1., 0., 0.],
        [0., 1., 0.],
        [0., 0., 1.]], dtype=torch.float64)}}]

Environment

================================
Printing MONAI config...
================================
MONAI version: 1.3.0
Numpy version: 1.26.3
Pytorch version: 2.1.2+cu121
MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False
MONAI rev id: 865972f7a791bf7b42efbcd87c8402bd865b329e
MONAI __file__: /home/<username>/protocept/rheumafinder_poc/.venv/lib/python3.11/site-packages/monai/__init__.py

Optional dependencies:
Pytorch Ignite version: NOT INSTALLED or UNKNOWN VERSION.
ITK version: NOT INSTALLED or UNKNOWN VERSION.
Nibabel version: 5.2.0
scikit-image version: NOT INSTALLED or UNKNOWN VERSION.
scipy version: 1.11.4
Pillow version: 10.2.0
Tensorboard version: 2.15.1
gdown version: NOT INSTALLED or UNKNOWN VERSION.
TorchVision version: NOT INSTALLED or UNKNOWN VERSION.
tqdm version: 4.66.1
lmdb version: NOT INSTALLED or UNKNOWN VERSION.
psutil version: 5.9.7
pandas version: NOT INSTALLED or UNKNOWN VERSION.
einops version: 0.7.0
transformers version: NOT INSTALLED or UNKNOWN VERSION.
mlflow version: NOT INSTALLED or UNKNOWN VERSION.
pynrrd version: NOT INSTALLED or UNKNOWN VERSION.
clearml version: NOT INSTALLED or UNKNOWN VERSION.

For details about installing the optional dependencies, please visit:
    https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies


================================
Printing system config...
================================
System: Linux
Linux version: Ubuntu 22.04.3 LTS
Platform: Linux-6.5.0-14-generic-x86_64-with-glibc2.35
Processor: x86_64
Machine: x86_64
Python version: 3.11.3
Process name: python
Command: ['python', '-c', 'import monai; monai.config.print_debug_info()']
Open files: [popenfile(path='/home/avlaminck/.vscode-server/data/logs/20240116T230111/ptyhost.log', fd=19, position=4331, mode='a', flags=33793), popenfile(path='/home/avlaminck/.vscode-server/data/logs/20240116T230111/network.log', fd=20, position=0, mode='a', flags=33793), popenfile(path='/home/avlaminck/.vscode-server/data/logs/20240116T230111/remoteagent.log', fd=22, position=5021, mode='a', flags=33793), popenfile(path='/home/avlaminck/.vscode-server/bin/0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2/vscode-remote-lock.avlaminck.0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2', fd=99, position=0, mode='w', flags=32769)]
Num physical CPUs: 24
Num logical CPUs: 32
Num usable CPUs: 32
CPU usage (%): [13.0, 14.5, 13.2, 13.0, 11.8, 11.9, 13.0, 13.2, 98.5, 13.2, 14.5, 13.2, 13.2, 13.2, 13.2, 13.2, 13.2, 11.9, 13.2, 14.5, 11.9, 13.2, 11.9, 13.2, 13.0, 13.2, 11.9, 14.5, 13.2, 11.8, 13.2, 11.9]
CPU freq. (MHz): 1871
Load avg. in last 1, 5, 15 mins (%): [0.1, 0.5, 4.5]
Disk usage (%): 96.3
Avg. sensor temp. (Celsius): UNKNOWN for given OS
Total physical memory (GB): 125.6
Available memory (GB): 111.6
Used memory (GB): 12.5

================================
Printing GPU config...
================================
Num GPUs: 1
Has CUDA: True
CUDA version: 12.1
cuDNN enabled: True
NVIDIA_TF32_OVERRIDE: None
TORCH_ALLOW_TF32_CUBLAS_OVERRIDE: None
cuDNN version: 8902
Current device: 0
Library compiled for CUDA architectures: ['sm_50', 'sm_60', 'sm_70', 'sm_75', 'sm_80', 'sm_86', 'sm_90']
GPU 0 Name: NVIDIA GeForce RTX 4090
GPU 0 Is integrated: False
GPU 0 Is multi GPU board: False
GPU 0 Multi processor count: 128
GPU 0 Total memory (GB): 23.6
GPU 0 CUDA capability (maj.min): 8.9

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