Get the same views of 3D dicom image

Hello everyone,

I have two 3D images (creat from 2 different registration methods, 2 images with same size (476,512,512) origin (0,0,0), direction(1,0,0,0,1,0,0,0,1)). I visualized 2 images with matplotlib (same slice) and got the the views as following.
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize = (20, 10))
ax1.imshow(a[ 150, :, :],‘gray’)
ax2.imshow(a[ :, 256, :], ‘gray’)
ax3.imshow(a[ :, :, 200], ‘gray’)


It seems that image A and B have different views (axial, coronal and diggital) (and flip axis?). I want to convert the views of B to be the same as A. Could you please suggest what I might try?
Many thanks,

Hello @tutti,

If the images have the same size origin and direction, the axial, sagittal and coronal views should match (possibly rotated).

Based on the provided size (476,512,512) you are looking at a numpy array and not the original SimpleITK image. Note that the index order in SimpleITK and numpy is reversed, image[x,y,z] vs. image_numpy_array[z,y,x]. Possibly the two are mixed resulting in the mismatch.

If this does not address the issue, take a look at PermuteAxesImageFilter or DICOMOrientImageFilter.

2 Likes

Hi @zivy,
Based on your suggestion, I resampled B and transposed the x and z. It solved my problem.
Thank you for your help! :))
Best regards,