Skip to content

Spacing transform not applied to dicom multi-frame image #2526

@ChristianEschen

Description

@ChristianEschen

It does not look like the spacing (resampling) transform is applied to dicom multi-frame images.
The image can be downloaded here: https://www.rubomedical.com/dicom_files/dicom_viewer_0002.zip

My environment is:
Ubuntu 18.04.5 LTS
Anaconda3: python 3.7.8
Monai: 0.5.3
itk: 5.2.0

Code to reproduce:

import monai
from monai.transforms import (
Compose,
LoadImaged,
Spacingd,
ToTensord)

dcm_path = '/home/gandalf/MIA/data/angio/2/0002.DCM'
label = 1
data_dict = [{'image': dcm_path, 'label': label}]

loader = LoadImaged(keys="image")
data_dict = loader(data_dict[0])
print(f"image shape: {data_dict['image'].shape}")
print(f"image spacing:\n{data_dict['image_meta_dict']['spacing']}")
print(f"image affine:\n{data_dict['image_meta_dict']['affine']}")

spacing = Spacingd(keys="image", pixdim=(
1.5, 1.5, 10.0), mode="bilinear")

data_dict = spacing(data_dict)
print(f"image shape: {data_dict['image'].shape}")
print(f"image spacing af Spacing:\n{data_dict['image_meta_dict']['spacing']}")
print(f"image affine after Spacing:\n{data_dict['image_meta_dict']['affine']}")

Output::

image spacing:
[ 1. 1. 33.]
image affine:
[[ 1. 0. 0. 0.]
[ 0. 1. 0. 0.]
[ 0. 0. 33. 0.]
[ 0. 0. 0. 1.]]
image shape: (96, 342, 342)
image spacing after Spacing:
[ 1. 1. 33.]
image affine after Spacing:
[[ 1.5 0. 0. 0. ]
[ 0. 1.5 0. 0. ]
[ 0. 0. 33. 0. ]
[ 0. 0. 0. 1. ]]

##############################
In the output above the first dimension is not resampled as expected.
I am not sure what the expected behavior should be for multi-frame images (vidoes), but I think this could be a potential bug or missing feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions