@zivy I have a similar problem. Also having 2 nifti images, ct scan and segmentation mask containing (0-3s) label.
The CT scan and segmentation mask has the following differences:
- the origin does not match between the images:
(-126.67142486572266, -100.2229995727539, -35.8679313659668) <-CT scan
(-107.0, -105.69999694824219, -169.0) <-mask
- the spacing does not match between the images
(0.47460898756980896, 0.47460898756980896, 4.999993324279785) <-CT scan
(0.4179689884185791, 0.4179689884185791, 5.0) <-mask
- the direction does not match between the images
(0.9999979873288019, 2.2101333702174357e-05, -0.0020062028280818365, 2.210133363 4976865e-05, 0.9997573031831891, 0.022030304063859862, 0.0020062028502736066, -0 .022030302844218676, 0.99975529048516) <-CT scan
(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0) <-mask
I tried the following:
original_image = sitk.ReadImage(’./188_0000.nii.gz’)
original_segmentation = sitk.ReadImage(’./188.nii.gz’)
new_segmentation = sitk.Resample(original_segmentation, original_image,sitk.Transform(),sitk.sitkNearestNeighbor,0,original_segmentation.GetPixelID())
sitk.WriteImage(new_segmentation,‘188t.nii.gz’)
But the resulting image end up with an empty (all black) image after resampling.
Alternatively, I tried the following and still get all black
new_segmentation = sitk.Resample(original_segmentation, original_image.GetSize(),
… sitk.Transform(),
… sitk.sitkNearestNeighbor,
… original_image.GetOrigin(),
… original_image.GetSpacing(),
… original_image.GetDirection(),
… 0,
… original_segmentation.GetPixelID())
Do you have any solution for this?
Many thanks