I have two CT volumetric scans for the same patient (for arterial and venous) with different number of slices. e.g. arterial scan has ~146 dicom images whereas venous scan has ~156 dicom images.
I want to resample one phase (e.g. arterial) to another (e.g. venous) so that they have the same number of images and slices are aligned (for example, slice number 100 in arterial looks same as that of slice number 100 in venous). The two phases seem to be already registered.
I first converted the arterial image to an isotropic image and the resampled original venous onto it as follows:
ven_resampled = sitk.Resample(ven_image, art_isotropic, defaultPixelValue=-1000)
This worked. The two phases now have the same properties and slices matches.
image size: (445, 445, 438)
image spacing: (1.0, 1.0, 1.0)
pixel type: 32-bit float
number of channels: 1
But when I first crop slices of the original sitk images through python slicing:
sitk_cropped = sitk_image[:,:,i1:i2] (now both phases have the same number of slices) and then follow the same steps as above (converting arterial to isotropic and resampling venous onto it), the resampled venous now results in all black slices. Why is this happening?
You most likely have a bug in your code.
Why do you resample both images? Why not resample one to the other?
ven_resampled = sitk.Resample(ven_image, art_image, defaultPixelValue=-1000)
A question for @zivy @blowekamp and maybe @dchen: does SITK slicing (
sitk_image[:,:,i1:i2]) preserve spatial location of pixels?
Yes, unless the operation reduces the dimensions of the image then some spacial location is lost in the dimension reduction.
I do not resample both images. I first convert arterial to isotropic and then resample venous to arterial.
Spatial Location if I do not crop the slices is as follows:
Arterial: (-231.0654296875, -391.0654296875, 219.5)
Venous: (-231.0654296875, -391.0654296875, 37.5)
Arterial: (-231.0654296875, -391.0654296875, 384.5)
Venous: (-231.0654296875, -391.0654296875, 217.5)
After cropping and resampling, the output is all black. Why does this happen after cropping only?
This implies resampling.
Principally, what you describe should work. I still think it is some bug in your code.
The above positions make me think that one or both of your images has non-identity direction. If you assume identity matrix direction, that would explain the problem.
Both the images have identity direction (both before and after cropping):
Direction: (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)