MRP Orientation and setting camera roll issue

Hi All,

I am trying to see if I can get some help resolving an issue I am facing concerning MPR slice view orientation. I am slicing real-time ultrasound data coming in from the scanner. The slicing view follows the XY (lateral, front-view), YZ (elevation, side view), and ZX (top view).

I want to orient the XY and YZ views to be rendered “top-down” rather than “bottom-up”. To achieve this, I am applying a roll to the respective cameras. However, the roll is correctly applied to the YZ view but doesn’t work for the XY view. You can see an illustration below.

VTK VERSION: 9.3.0 (Also observed on 9.2.x)
OS: Windows 10

I would greatly appreciate any help.

I was wondering if anyone had any insights?

Hello,

Can you, please, share the code to perform the unsuccessful roll?

best,

PC

Hi Paulo,

I just saw your response. Let me make a minimum working example and get back to you.

Thank you!

Hello,

I don’t think going through the trouble of coming up with a demonstrator is necessary, but if you feel like it, ok. Often just sharing the code snippet involved in the roll operation is enough.

regards,

PC

Sounds good. Here is a snippet of how I am applying the roll. I am happy to provide any more info.

       # viewerXY and viewerYZ are instances of vtkResliceImageViewer

        # define viewers
        [self.viewerXY, self.viewerYZ, self.viewerXZ] = [
            vtk.vtkResliceImageViewer() for x in range(3)
        ]

        cam_xy = self.viewerXY.GetRenderer().GetActiveCamera()
        cam_xy.Roll(180) # <---- This doesn't work
        cam_yz = self.viewerYZ.GetRenderer().GetActiveCamera()
        cam_yz.Roll(180) # <---- This works

Ok. What happens if you do cam_xy.Roll(90)?

Fig.1 cam_xy.Roll(90) & cam_yz.Roll(180)

Fig.2 cam_xy.Roll(90) & cam_yz.Roll(90)

I would not recommend using roll-pitch-yaw parametrization for specifying slice view orientations for medical imaging due to ambiguities (the same orientation can be represented multiple ways) and gimbal lock issue.

Instead, using homogeneous transformation matrices is an excellent way to specify view orientation. You can generate the transformation matrix by writing the direction vector of the horizontal and vertical axes in the first two columns of the matrix and write the cross product in the third column.

Note that you don’t need to invent and implement all these from scratch. For example, we have shared lots of tools for cardiac echocardiography in 3D Slicer’s SlicerHeart extension (free, open-source, restriction-free software). You can import 4D ultrasound, CT, or MRI images and visualize the image sequence in 2D and 3D (we probably already implemented what you are trying to figure out), but we go way beyond that and offer many analysis, modeling, and simulation tools (define annulus curve, papillary muscles, coaptation surface, segment leaflets - manually or fully automatic AI models, compute metrics, simulate various device placement procedure - from simple stents and closure devices to robotic catheters, biomechanical modeling, etc. We are working on many projects and continuously releasing tools (we release the source code along with all papers that we publish).

Hi Andras, I had ignored this for a bit but eventually got back to it. Your advice pointed me in the right direction and I was successfully able to orient them.

To your second suggestion, we use Slicer a fair bit and I have been personally doing so extensively for many years. Thanks for the incredible work that has enabled a ton of reasearch. This particular project called for a bespoke solution so building off old code/examples was the way to go.

Thanks again!