[vtkusers] Correct anatomical orientation of volumes from Niftii and DICOM

ochampao ochampao at hotmail.com
Fri May 18 07:20:04 EDT 2018


Hi David,
 
Thanks for all the information you’ve been sending. It has been very
helpful. 
 
Indeed, I have confused the RAS coordinate system with the neurological
convention. I also assumed that because Slicer uses RAS it automatically
meant that it also used the neurological viewing convention, which is not
the case. 
 
My intention with the camera configuration posted in my previous comment was
to use the neurological convention because I will be displaying images of
the brain (this explains why I thought that all my images appeared flipped
compared to Slicer). With the RAS coordinate system and the neurological
viewing convention in mind, I think the camera configuration as posted above
is correct now. To be more specific, this is what I am aiming for with that
camera configuration:
 
Axial (Looking towards patient’s inferior):
  * Patient's Right    <= maps to => View Right
  * Patient's Anterior <= maps to => View Up
  * (Patient's Superior points "outside" the screen)
 
Coronal (Looking towards Patient's Anterior):
  * Patient's Right    <= maps to => View Right
  * Patient's Superior <= maps to => View Up
  * (Patient's Anterior points "inside" the screen)
 
Sagittal (Looking towards Patient's Right):
  * Patient's Posterior <= maps to => View Right
  * Patient's Superior  <= maps to => View Up
  * (Patient's Right points "inside" the screen)
 
<http://vtk.1045678.n5.nabble.com/file/t341857/2018-05-17_14_52_58-kPlan_TPM.png> 

I found the following resources very helpful:
Slicer Coordinate systems <https://www.slicer.org/wiki/Coordinate_systems>  
and all the links therein. Especially the table ""Radiological" vs
"Neurological" Orientation in Viewers" from:  Orientation Terms
<http://www.grahamwideman.com/gw/brain/orientation/orientterms.htm>   

Regarding the computed vtkMatrix4x4 (RASMatrix, QFormMatrix), if it is not
the identity, then this means that we need to either transform the data
(e.g. flip the respective axis) or apply the vtkMatrix4x4 to the respective
actor?

Another source of confusion was (and probably still is), what is done by the
readers for us and what remains to be done by the programmer to properly
display the volume. Also, if nothing is done to the reconstructed output
volume of the reader, how is it positioned/oriented in VTK's world? Here is
my current understanding:
  * The reader loads the raw voxels which are stored in indexed/structured
coordinates (scanner's i,j,k).
  * The reader reconstructs the volume and transforms the uniteless (i,j,k)
coordinates to (x',y',z') data coordinates with dimensions (e.g. mm):
    - If, for example, the file format is using an RAS convention, then
increasing i/j/k corresponds to increasing x'/y'/z' which in turn
corresponds to moving towards R/A/S respectively. 
    - This volume is not oriented or positioned in the Patient's coordinate
system yet i.e. its origin (i.e. voxel 0,0,0) is still at (0,0,0)mm and its
RAS axes have not been mapped to VTK's world (X,Y,Z) coordinates.
	  -> This was probably my biggest point of confusion. I was assuming that
even if the volume was not translated to the Patient's origin, it at least
had its RAS axes mapped to VTK's positive X,Y,Z axes.
    - This is actually the output of the reader i.e. the volume is still not
positioned and oriented in Patient's corrdinate system but has the correct
dimensions.
    - The above coordinates refer to coordinates within the volume (user
coordinates in VTK's terminology?).
    - How is this volume positioned in VTK's world, without applying the
transofmration matrix? <check this by plotting axes, and bounding box>
  * the reader also computes the transformation matrix for orienting and
positioning the reconstructed volume. The matrix should be applied by the
programmer.
  * this is where the job of the reader stops
  
  * Let's assume that the file uses RAS and that the camera is setup using
the neurological viewing convnetion. Then, if the volume is displayed using
a vtkImageSlice prop without applying the UserMatrix, I was expecting VTK's
world (X+,Y+,Z+) to map to the volumes (R,A,S) and the origin of VTK's world
to coincide with the volume' s 0,0,0. When I apply this in prctice with a
volume form a Nifti file, it clearly does not work.
  * This is where the computed vtkMatrix4x4 (RASMatrix, QFormMatrix) that
you mentioned comes into play. 
    - If the top left 3x3 of the matrix is identity, it means that the RAS
axes are aligned with VTK's world positive XYZ coordinates, but the origin
is at (0,0,0)mm, rather at the Patient's Origin.
	- If the top left 3x3 is not identiy, then we need to apply the computed
vtkMatrix4x4 to the actor, or transform the data accordingly (e.g. flipping
the respective dimension or maybe passing it through a vtkTransformFilter?)
  
I apologise for the long post. I hope that the above are not completely
wrong and may be helpful.




---------------------------------------------------------------------------
From: David Gobbi [] 
Sent: 16 May 2018 19:28
To: ochampao <>
Subject: Re: [vtkusers] Correct anatomical orientation of volumes from
Niftii and DICOM

This is a follow-up with more info about view orientations, since they
are a common source of confusion when talking about RAS and LPS
coordinates.

As I mentioned in my previous email, RAS and LPS are two different
ways of linking anatomical orientations to an x,y,z coordinate system.
The RAS coordinate system is what the Montreal Neurological Institute
chose as as the basis of its "MNI" coordinate system, which in turn
has become a de-facto standard coordinate system for brain atlases.
As a result RAS is used widely by neurological image processing
software (FSL, Freesurfer, Slicer, to name a few).  This is why it was
chosen as the coordinate system for NIFTI files.

In addition to considering RAS vs LPS, it is also necessary to consider
the radiological vs. the neurological view orientations.  The difference
between these view orientation is that "radiological" places patient left
on view right, while "neurological" places patient right on view right.
So for a radiological view with RAS, -x points to the view right.
And for a radiological view with LPS, +x points to the view right.
For a neurological view, it is the opposite.

There is some historical confusion that RAS implies a neurological
view, and that LPS implies a radiological view.  This was true of most
software developed in the 1990s, but is demonstrably not true for
many modern software packages.  For example:
- Slicer uses RAS but uses a radiological view (ditto for Freeview)
- Commercial image-guided brain surgery software generally uses
 DICOM and LPS, but universally uses a neurological view

In other words, when deciding whether to use neurological vs.
radiological view orientation, you must consider your audience.
Also note that neurological and radiological are not the only view
conventions.  There are conventions that are specific to cardiology,
specific to viewing extremities, conventions for animals, etc. etc.

Finally, when setting up the camera for a particular view, you have to
consider (a) how the view orientations (view right, view up) correspond
to anatomical orientations, and then (b) how these anatomical orientations
map to x, y, z directions (which of course depends on whether you are
using LPS or RAS).

 - David


---------------------------------------------------------------------------
On Wed, May 16, 2018 at 9:38 AM, David Gobbi <> wrote:

Hi Panos,

Your cameras are not set up the same as Slicer's cameras.
Consider your axial view:

                                double viewUp[3] = { 0, 1, 0 };
                                double leftToRight[3] = { 1, 0, 0 };

You have set the camera so that +x points towards the right
of the view (i.e. towards the right edge of the screen).
In RAS coordinates, +x points to the patient's right.
Hence, your view points the patient's right to the view right.

By comparison, Slicer points the patient's left to the view right.
So you need to use this instead, in both your axial and coronal:

                                double leftToRight[3] = { -1, 0, 0 };

I think that I know where your confusion lies.  The RAS and LPS
coordinate systems specify anatomical orientation, not view orientation.
View orientation has to do with how doctors/scientists prefer the
anatomical directions to map to view directions.  Slicer uses the
convention that the patient's left is oriented to the view right.
This convention is commonly called the radiological view convention,
it also specifies that the anterior direction (nose) points to the top.


One further issue that you're going to run into sooner or later is that
you aren't using a vtkMatrix4x4 to orient the actors (when I say actors
in this context, I mean the vtkImageSlice objects).  VTK's vtkImageData
just stores the voxels but doesn't specify orientation, which is why
a vtkMatrix4x4 is needed to orient the images.

In your case, you aren't using these matrices in your display pipeline yet,
so you must at least verify that they are identity.  What I mean
by this is, after updating vtkDICOMToRAS, call GetRASMatrix() and
check that the upper left 3x3 portion of this matrix is identity.
Similarly, when you use vtkNIFTIImageReader, call GetQFormMatrix()
and verify that it specifies an identity orientation.

 - David






--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list