Setting camera direction of projection (position) to have slices like in 3d slicer

Hi,

I am writing MRI browser and I am trying to set camera projection perpendicular to IJK planes in vtk-js (camera in parallel mode).
I am using only vtkImageData direction matrix to calculate slicing modes and camera position and viewup. I would like to have exactly the same scene like in 3DSlicer, i.e. slicing in direction: L->R, P->A, I->S, camera viewup always for a given orientation,etc…

Let suppose that I have two images with direction matrices (using row-major order for 9-element vector) as follows:

[ 0, 1, 0]
[ 0, 0,-1]
[-1, 0, 0]

[ 0, 1, 0]
[ 0, 0,-1]
[ 1, 0, 0]

First, I am setting proper slicing mode in IJK,and I am checking
anatomical orientation:

RL AP IS
i[ 0, 1, 0] 1>0 A
j[ 0, 0,-1] -1<0 S
k[-1, 0, 0] -1<0 L

i[ 0, 1, 0] 1>0 A
j[ 0, 0,-1] -1<0 S
k[ 1, 0, 0] 1>0 R

Using ITK notation A:A->P, S:S->I etc. I confirmed in ITK-SNAP that these images are in fact in ASL and ASR orientations.

So I know that vtkImageMappers should be set as follows:

  • SlicingMode.I for Coronal (reversed slicing direction in both)
  • SlicingMode.J for Axial (reversed slicing direction in both)
  • SlicingMode.K for Sagittal. (reversed slicing direction in ASR)

To set camera’s direction of projection I just use a given row of direction matrix.
For example: for axial this would be [0,0,-1] in both cases.

However for ASR image, the image is flipped (Left to Right) when compared to 3DSlicer.
If I multiply j row ([0,0,-1]) by -1, then it works for ASR, but ASL will be flipped.
I checked with all orientations and this would work nicely if only I would know when to change direction to opposite.

I was trying to figure out with using some transformations, like described in https://www.slideserve.com/kare/slicer-s-coordinate-systems
but I did not manage to find the solution.
I also studied vtk-js ViewProxy and InteractorStyleMPRSlice but it didn’t help.
How can set camera direction of projection, so that it will work as in 3D slicer?
Thank you for any help
Andrzej Marciniak