<div dir="ltr"><div>I'll have to provide some background before answering your questions,</div><div>please bear with me and hopefully everything will come together at the</div><div>end.</div><div><br></div><div>Originally (meaning around 20 years ago) VTK was very limited as far</div><div>as image display is concerned.  The original vtkImageMapper always</div><div>displayed images in a 2D pixel coordinate system where the first pixel</div><div>in the image was at the bottom left.</div><div><br></div><div>Of course, for most image file formats the first pixel in the file is meant</div><div>to be at the top left.  Such file formats include JPEG, DICOM, and many</div><div>others.  So in general the VTK image readers flip the image vertically,</div><div>and the FileLowerLeft flag can be used to tell the readers not to flip the</div><div>image.  There are some exceptions, however.</div><div><br></div><div>So the vtkDICOMImageReader flips the DICOM image vertically by</div><div>default, in order to make the 2D slices look right when displayed with</div><div>the vtkImageMapper.  It should be obvious that flipping the images</div><div>can mess things up as far as the 3D coordinate system is concerned.</div><div>Also, it's 2018 and nobody should be using vtkImageMapper anymore,</div><div>there are much better ways of displaying images in VTK.  By using</div><div>3D image rendering and by setting the ViewUp of the camera, one</div><div>can keep the images in their original orientation and still display them</div><div>properly.</div><div><br></div><div>The vtkGDCMImageReader does this same vertical flip when reading</div><div>images, and of course I strongly recommend setting FileLowerLeftOn()</div><div>to stop it from doing so.</div><div><br></div><div>So now we get to your first question.  The readers do, indeed, try to</div><div>handle certain orientation issues themselves.  But often what they do</div><div>hurts more than it helps.  That is why, in that document of mine that you</div><div>linked to earlier, I recommend setting up the reader so that it reads the</div><div>pixels directly into memory without any flips or other mangling.  Once</div><div>you have done so, you can go to the official, standard documentation</div><div>for the file formats to figure out how to properly orient and position the</div><div>images in 3D space.</div><div><br></div><div>For your second question, I'll turn it into an exercise.  You know that</div><div>in DICOM, left is +x and anterior (towards the nose) is -y.  So first,</div><div>verify that this is the view orientation that you are providing for your</div><div>'axial' view.  When I say verify, I don't mean to do so by displaying</div><div>an image and seeing if it looks like... that's not independent verification!</div><div>Verify with vtkAxesActor or with something similar:</div><div><a href="https://lorensen.github.io/VTKExamples/site/Cxx/Visualization/DisplayCoordinateAxes/">https://lorensen.github.io/VTKExamples/site/Cxx/Visualization/DisplayCoordinateAxes/</a><br></div><div><br></div><div>Once you've verified that the camera is correct, you can display</div><div>output of vtkDICOMImageReader and vtkGDCMReader and check</div><div>which is correct.</div><div><br></div><div>After you've made sure that everything is correct for the axial view,</div><div>you can do the same for the other views (again, using vtkAxesActor</div><div>to verify the camera).</div><div><br></div><div>That should be enough to get you started.</div><div><br></div><div> - David</div><div><br></div><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 11, 2018 at 7:44 AM, ochampao <span dir="ltr"><<a href="mailto:ochampao@hotmail.com" target="_blank">ochampao@hotmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi David.<br>
<br>
Thanks for the detailed reply. It's clear I need to familirize myself more<br>
with the two formats.<br>
<br>
I have a few follow-up questions:<br>
<br>
1) I understand that we need to look into the information stored in each<br>
file to determine how to position and orient the volume. What is not clear<br>
to me is how much of this is done by the readers themselves. Are there some<br>
rules/conventions/logic that each reader follows when orienting and<br>
positioning the reconstructed volume in vtk's world coordinate system? Can<br>
we make some assumptions about the reconstructed volume (vtkImageData)<br>
generated by the reader?<br>
<br>
2) Let's put Niftii on the side for a moment. With in my code above the same<br>
volume appears with it's x and y axes reversed when using vtkGDCMImageReader<br>
(loadDicomGDCM()) compared to when using vtkDICOMImageReader (loadDicom())?<br>
How can I ensure the correct volume orientation (or equivalently the correct<br>
camera perspective)?<br>
<br>
<br>
Panos.</blockquote></div></div></div>