# How to Properly Rotate a DICOM

Hello,

I have Python/vtk code that reads a DICOM image that was acquired obliquely, and uses vtkImageReslice to reslice the DICOM volume axially. I achieve this by generating an affine transformation matrix (vtkMatrix4x4) using the “ImagePositionPatient” and “ImageOrientationPatient” attributes of the DICOM, then setting this matrix as the vtkImageReslice reslice axes. Note that these DICOM attributes are in reference to the default DICOM coordinate orientation - axial. Thus, my resulting slices are oriented axially.

But what if I want to reslice in a coronal or sagittal orientation? Do I need to rotate the volume? Or do I simply need to reslice in a different orientation? If the former, won’t rotating the volume affect the DICOM patient coordinate system? If the latter, is there a vtk method for rotating a non-orthogonal reslice axes?

Thanks,

Michelle K.

See my answer to your previous question here. To answer your question specifically: To compute the appropriate reslice transform, you can specify coordinate system axes of your slice coordinate system in patient coordinate system (LPS). For example an axial slice axes in LPS: `x = [1, 0, 0]`, `y = [0, 1, 0]` (and `z = cross(x,y)`), therefore AxialSliceToLPS transform is:

``````1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
``````

Coronal slice axes in LPS: `x = [1, 0, 0]`, `y = [0, 0, 1]` (and `z = cross(x,y)`), therefore CoronalSliceToLPS transform is:

``````1 0  0 0
0 0 -1 0
0 1  0 0
0 0  0 1
``````

From your questions on the forum it seems that you are building a DICOM image viewer that is capable of showing orthogonal slice views with an MRI image and a colored overlay and some annotations. This is a very useful learning exercise, so it make sense to continue this way if your goal is to get to know VTK better. However, at some point you may consider switching to medical image visualization application framework, which already provides all these basic features (and many more), because if you spend too much time with redeveloping and maintaining these then you might not have enough time to work on things that actually matter: implement your new ideas, new methods, and test and improve them.

I’m one of the developers of 3D Slicer, so I’m the most familiar with this application framework, but there are others (such as MITK or MeVisLab). Since Slicer is built on VTK and it has an embedded Python interpreter, you can develop and customize features in Python and you can manipulate VTK objects at the lowest level as needed (this is where all your VTK learning experience will be useful). Slicer is free, open-source, same way as VTK. For example, here is an example of visualization of breast MRI with colored overlay, segmentation, and DCE curve obtained without any customization or programming:

1 Like