-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Describe the bug
Saving a Dicom image into Nifti, and load the nifti, we should get the same data representation.
To Reproduce
import itk
from monai.transforms import Compose, EnsureChannelFirstD, LoadImageD, SaveImageD
img_dir = "tests/testing_data/CT_DICOM"
data_dict = {"img": img_dir}
keys = data_dict.keys()
xforms = Compose(
[
LoadImageD(keys, reader="itkreader", pixel_type=itk.UC),
EnsureChannelFirstD(keys),
]
)
img_dict = xforms(data_dict) # load dicom with itk
save_xform = SaveImageD(keys, meta_keys="img_meta_dict", output_dir=".")
save_xform(img_dict) # save to nifti
new_xforms = Compose(
[
LoadImageD(keys, reader="itkreader"),
EnsureChannelFirstD(keys),
]
)
out = new_xforms({"img": "CT_DICOM/CT_DICOM_trans.nii.gz"}) # load nifti with itk
print(img_dict["img"].shape)
print(out["img"].shape)
print(img_dict["img_meta_dict"]["affine"])
print(out["img_meta_dict"]["affine"])
print(img_dict["img_meta_dict"]["spatial_shape"])
print(out["img_meta_dict"]["spatial_shape"])inconsistent output:
(1, 4, 16, 16)
(1, 16, 16, 4)
[[ 0.488281 0. 0. -125. ]
[ 0. 0.488281 0. -128.100006 ]
[ 0. 0. 68.33333333 -99.480003 ]
[ 0. 0. 0. 1. ]]
[[ -0.48828101 0. 0. 125. ]
[ 0. -0.48828101 0. 128.1000061 ]
[ 0. 0. 68.33333588 -99.48000336]
[ 0. 0. 0. 1. ]]
[ 4 16 16]
[16 16 4]
this is an integration issue of nibabel writer <=> itk reader
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request