DICOM upside down using vtkDICOMImageReader

I was using vtkGDCMImageReader from vtkgdcm (build from GDCM with USE_VTK on) to import DICOM data and toggling the FileLowerLeftOn() to solve the upside down issue.

Recently when I changed from vtkGDCMImageReader to vtkDICOMImageReader, I am experiencing the upside down issue same as this post, even with the FileLowerLeft toggled on.

The minimal code is as follows:

import numpy as np
import vtk
from vtk.util import numpy_support
import os 
from gdcm import vtkgdcm

dir = 'path to DICOM dataset'
list_of_dcm = os.listdir(dir)
shape = (len(list_of_dcm), 512, 512)
volume_array = np.zeros(shape)

for n, path in enumerate(list_of_dcm):
    dicom_reader = vtkgdcm.vtkGDCMImageReader()
    # dicom_reader = vtk.vtkDICOMImageReader()
    dicom_reader.SetFileName(os.path.join(dir, path))
    vtk_image_data = dicom_reader.GetOutput()
    dx, dy, dz = vtk_image_data.GetDimensions()
    im_array = numpy_support.vtk_to_numpy(
    if dz == 1:
        im_array.shape = dy, dx
        im_array.shape = dz, dy, dx
    volume_array[n] = im_array
    print(f"finish {n}")
np.savez_compressed('vtkgdcmimagereader', a=volume_array)
# np.savez_compressed('vtkdicomimagereader', a=volume_array)

I ran this code two times, with different dicom reader and saved as different name (the commented line above)

after that I visualized them using a simple matplotlib codes:

import numpy as np
test_gdcm = np.load('vtkgdcmimagereader.npz')['a']
test_vtkdicom = np.load('vtkdicomimagereader.npz')['a']
import matplotlib.pyplot as plt

fig, axes = plt.subplots(2, 3, figsize=(100, 75)) 

axes[0, 0].imshow(test_gdcm[:, :, 100], cmap='gray') 
axes[0, 0].set_title('gdcm sagittal')        
axes[0, 0].axis('off')                  

axes[0, 1].imshow(test_gdcm[:, 100, :], cmap='gray')  
axes[0, 1].set_title('Image coronal')       
axes[0, 1].axis('off')                  

axes[0, 2].imshow(test_gdcm[100, :, :], cmap='gray')  
axes[0, 2].set_title('Image axial')    
axes[0, 2].axis('off') 

axes[1, 0].imshow(test_vtkdicom[:, :, 100], cmap='gray')  
axes[1, 0].set_title('gdcm sagittal')
axes[1, 0].axis('off')                 

axes[1, 1].imshow(test_vtkdicom[:, 100, :], cmap='gray')  
axes[1, 1].set_title('Image coronal')     
axes[1, 1].axis('off')                  

axes[1, 2].imshow(test_vtkdicom[100, :, :], cmap='gray')  
axes[1, 2].set_title('Image axial')         
axes[1, 2].axis('off')                    



I am using a custom build VTK (v8.1.2) and GDCM(3.0.9), but I have tried using the VTK from Pypi for vtkDICOMImageReader(), and the result is the same.

For both vtkgdcm.vtkGDCMImageReader() and vtk.vtkDICOMImageReader(): if FileLowerLeft is set to False, their output are the same (upside down)

If FileLowerLeft is set to True, vtkgdcm.vtkGDCMImageReader() is now correct but vtk.vtkDICOMImageReader() gives me the same output with upside down image.

Could I ask why is this happening? How do I get the same result from vtkgdcm.vtkGDCMImageReader() using vtk.vtkDICOMImageReader()? Any help is appreciated.