Spacing transform not applied to dicom multi-frame image (transform for video frame/motion interpolation?) #2529
Replies: 6 comments
-
thanks for the question. the spacing transform assumes the input image has a "channel" dimension and the channel dimension should be the first (shape |
Beta Was this translation helpful? Give feedback.
-
Thanks for the answer. import monai dcm_path = '/home/gandalf/MIA/data/angio/2/0002.DCM' loader = LoadImaged(keys="image") data_dict = loader(data_dict[0]) channel_first = EnsureChannelFirstD(keys="image") spacing = Spacingd(keys="image", pixdim=( data_dict = spacing(data_dict) ####output: |
Beta Was this translation helpful? Give feedback.
-
the coordinate system is only tracked using the affine, instead of the |
Beta Was this translation helpful? Give feedback.
-
thanks for the answer again. |
Beta Was this translation helpful? Give feedback.
-
ok, thanks, the transform is mainly for spatial interpolations, video frame/motion interpolation will not be supported here... I'm converting this to a discussion, perhaps @charliebudd @rijobro have som other comments or feature requests |
Beta Was this translation helpful? Give feedback.
-
Since we don't currently support video transforms, perhaps it would be best to create your own transforms using something like OpenCV functionality? (As an aside, is modifying the frame rate actually necessary for you? f you're treating your video on a frame-by-frame basis, then the frame rate isn't so important during the inference phase. Perhaps you have a justified need to modify the frame rate, I just wanted to check!) |
Beta Was this translation helpful? Give feedback.
-
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.
Beta Was this translation helpful? Give feedback.
All reactions