Apologies for yet another DICOM handling question but couldn’t seem to find the answer to my question.
We need to integrate VTK into our existing application which has it own custom loading of the DICOM data, so using vtk-dicom or similar is not an option. I did try vtkDICOMImageReader in my test application just for comparison … while the results were not exactly the same, it had very similar issues.
In my own loader, I am populating the vtkImageData buffer by directly copying in the DICOM pixel data. Note that even though DICOM pixel data is oriented top left, I thought that correctly setting the direction matrix based on the DICOM orientation vectors would allow ensure proper handling even though VTK’s default is +Y pointing upwards (is this a correct assumption?) For example, I used a standard axial dataset that has the identity matrix (which I specify as the vtkImageData direction matrix). Also note, I am loading the lowest slices first in the buffer … which matches with the z direction in the identity matrix specified.
Now the issue is when I go to display this data, the orientation (and image) seems messed up. I have a simple volume rendering pipeline and I want an initial coronal view of the image from the anterior direction. To achieve this I set my camera position to a large -Y value. However, in order to get the head (+z in DICOM) at the top of the image, I needed to use a ViewUp vector of (0,0,-1) which makes no sense to me. In DICOM, the head should be +z, not -z. Also note that the image appears flipped in the lateral direction … the person’s right side is on the +x axis and it should be on the -x axis.
I then tried the vtkDICOMImageReader for comparison. It also still required a ViewUp vector of (0,0,-1). The lateral direction is now OK, but the anterior/posterior direction is now messed up. I took a quick look at the code and I see they flip the order of the pixel data rows (bottom row to the top) which I think explains what I visually see. I don’t understand why they still keep the same identity matrix even though it is flipping the row data … seems to me they should have changed that since they changed the order of the rows in the pixel data.
I am really hoping someone can shed some light on this or point me to an informative post that explains exactly the relationship between vtkImageData, the direction matrix, and how it gets interpreted by vtk.