# Wrong MPR image orientation when using vtkResliceImageViewer

**URL:** <https://discourse.vtk.org/t/wrong-mpr-image-orientation-when-using-vtkresliceimageviewer/4158>\
**Category:** Development\
**Created:** [September 5, 2020, 5:41pm UTC](https://discourse.vtk.org/t/wrong-mpr-image-orientation-when-using-vtkresliceimageviewer/4158 "2020-09-05T17:41:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sherinnovation](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@sherinnovation](https://discourse.vtk.org/u/sherinnovation)\
**Post date:** [September 5, 2020, 5:41pm UTC](https://discourse.vtk.org/t/wrong-mpr-image-orientation-when-using-vtkresliceimageviewer/4158/1 "2020-09-05T17:41:43Z")

</div>

I am using **vtkResliceImageViewer** for displaying MPRs. Depending on the dataset I load, I am facing problems related to orientation. In the below example image, first row shows the image orientations displayed in Slicer3D. For the same dataset, when using vtkResliceImageViewer in my vtk source, some of the images appear rotated as shown in the second row.

 ![image](https://discourse.vtk.org/uploads/default/original/2X/6/6d66e0db1d2921c08c064c4d2c2896b7ad2f10e9.jpeg)

I was able to fix this problem by manually rotating the actor by

`> self.resliceImageViewerMPRA.GetImageActor().RotateZ(180)`

but I am not happy with the solution because it is not a global solution. For some datasets, the above source line is needed and for some, it is not needed. I was wondering if we have any member functions in **vtkResliceImageViewer** to help me in displaying the MPRs at proper image orientation. If there are no member functions, do you have any idea on what calculation/computation I should be doing?

---

<div class="post-metadata">

**Author:** ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)\
**Post date:** [September 5, 2020, 10:01pm UTC](https://discourse.vtk.org/t/wrong-mpr-image-orientation-when-using-vtkresliceimageviewer/4158/2 "2020-09-05T22:01:34Z")

</div>

If you want to display the image in standard anatomical orientations then you need to take into account the IJK to LPS transformation stored in the DICOM image. It is called PatientMatrix in [vtkDICOMReader](https://github.com/dgobbi/vtk-dicom/blob/master/Source/vtkDICOMReader.h).

I would not recommend to build a medical imaging application on raw VTK, though. Instead, you can build your application on any of the open-source VTK-based medical imaging frameworks, such as 3D Slicer or MITK. These frameworks have been developed for the exact purpose of allowing R&D projects to focus on science and innovation instead wasting time with redeveloping trivial features from scratch.

---

<div class="post-metadata">

**Author:** ![sherinnovation](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@sherinnovation](https://discourse.vtk.org/u/sherinnovation)\
**Post date:** [September 6, 2020, 10:56am UTC](https://discourse.vtk.org/t/wrong-mpr-image-orientation-when-using-vtkresliceimageviewer/4158/3 "2020-09-06T10:56:15Z")

</div>

Thank you Andras! Your reply gives me some direction. Unfortunately, I have to continue working on my standalone application as I am a visualization researcher. I am using a **vtkNIFTIImageReader** because my files are not DICOM but a NIFTI. In **vtkNIFTIImageReader** , I have only functions like [GetQFormMatrix](https://vtk.org/doc/nightly/html/classvtkNIFTIImageReader.html#a7d1a2975a7c69f025b924d549a128cb4) () and [GetSFormMatrix](https://vtk.org/doc/nightly/html/classvtkNIFTIImageReader.html#a122aba3c5dcd44a5b147f6966ee97cea) () . What would be the corresponding member function that gives the PatientMatrix in **vtkNIFTIImageReader** class? Can you also please throw some light on this?

---

<div class="post-metadata">

**Author:** ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)\
**Post date:** [September 6, 2020, 3:22pm UTC](https://discourse.vtk.org/t/wrong-mpr-image-orientation-when-using-vtkresliceimageviewer/4158/4 "2020-09-06T15:22:38Z")

</div>

GetQFormMatrix and GetSFormMatrix provide you the patient matrix (in two slightly different forms).

> [@sherinnovation](#):
>
> Unfortunately, I have to continue working on my standalone application as I am a visualization researcher

If you use VTK for visualization then you can just as well use 3D Slicer or MITK, as they all use VTK for visualization. VTK cameras, renderers, shaders, etc. are all exposed the same way as in plain VTK and you are free to do whatever you need.

For example, developers of VTK-based [PRISM rendering framework](https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0193636) make available their results [as a 3D Slicer extension](https://githubcomets-vis-interactiveslicerprismrendering.readthedocs.io/en/latest/) so that it can easily be easily accessed by clinical end users and other researchers. Visualization researchers don’t need to spend time with implementing features that are essential for clinical evaluation, such as importing, positioning, pre/post-processing the images, specify input points or regions, etc. Usability and effectiveness of new visualization methods can be evaluated in for various clinical tasks, ranging from simple diagnostic workflows to intra-operative surgical navigation or virtual reality - without implementing a single line of code (because these are all provided by the application platform).

---

<div class="post-metadata">

**Author:** ![flaviu2](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/f/74df32/32.png) [@flaviu2](https://discourse.vtk.org/u/flaviu2)\
**Post date:** [September 6, 2020, 5:56pm UTC](https://discourse.vtk.org/t/wrong-mpr-image-orientation-when-using-vtkresliceimageviewer/4158/5 "2020-09-06T17:56:57Z")

</div>

> [@lassoan](#):
>
> Instead, you can build your application on any of the open-source VTK-based medical imaging frameworks, such as 3D Slicer

I was thinking if we can use large portion of existing code (from Slicer) into a brand new C++ application. Is that can be possible ? If it is, I would ready to be involved right away …

---

<div class="post-metadata">

**Author:** ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)\
**Post date:** [September 6, 2020, 8:28pm UTC](https://discourse.vtk.org/t/wrong-mpr-image-orientation-when-using-vtkresliceimageviewer/4158/6 "2020-09-06T20:28:10Z")

</div>

Yes, of course, 3D Slicer is very modular, so you can pick only the pieces what you actually need (you could even delete unneeded modules, but it is simpler to just exclude them from the build). There is even a custom application template that most companies and research groups use as a starting point to build 3D Slicer based prototypes or products. This page is a good starting point: [https://blog.kitware.com/slicercat-creating-custom-applications-based-on-3d-slicer/](https://blog.kitware.com/slicercat-creating-custom-applications-based-on-3d-slicer/)

---

<div class="post-metadata">

**Author:** ![dporter](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dporter](https://discourse.vtk.org/u/dporter)\
**Post date:** [November 19, 2020, 4:45pm UTC](https://discourse.vtk.org/t/wrong-mpr-image-orientation-when-using-vtkresliceimageviewer/4158/7 "2020-11-19T16:45:01Z")

</div>

A question about oblique slicing: Is there a way to show orientation labels on each of the 3 orthogonal views as we rotate the slice cursors?
