<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi all,<br>
<br>
So this is my understanding of how orientations and ITK work.<br>
<br>
the GetDirection and GetOrigin methods in itk::Image return the
directional cosines in an LPS world frame. Thus an identity matrix
returned by GetDirection() would mean the image is stored in LPS.<br>
<br>
The QForm and SForm matrices in the nifti file format&nbsp; are in the RAS
world coordinate frame. See
<a class="moz-txt-link-freetext" href="http://nifti.nimh.nih.gov/nifti-1/documentation/nifti1fields/nifti1fields_pages/qsform.html">http://nifti.nimh.nih.gov/nifti-1/documentation/nifti1fields/nifti1fields_pages/qsform.html</a><br>
<br>
So Mathieu, what you are reporting is the expected behavior.<br>
qform (shown by fslhd etc) of<br>
<div>[1, 0, 0, -90]</div>
<div>[0, 1, 0, -126]</div>
<div>[0, 0, 1, -72]</div>
<div>[0, 0, 0, 1]</div>
<br>
should yield a GetDirection() and GetOrigin of<br>
-1&nbsp; 0&nbsp; 0 &nbsp; 90<br>
0&nbsp; -1&nbsp; 0&nbsp;&nbsp; 126<br>
0&nbsp;&nbsp; 0&nbsp; 1&nbsp; -72<br>
0&nbsp;&nbsp; 0&nbsp; 0&nbsp;&nbsp; 1<br>
<br>
<br>
Antoine,<br>
Your situation is more confusing, I'm not familiar with dcm2nii, but it
isn't unheard of to have dicom converters change the orientation of the
output image, to bring it into some consistent frame (LAS is a favorite
of labs that have lots of old code expecting analyze files). From what
you posted it seems that dcm2nii converted your image from an LPS
arranged dicom to an LAS arranged Nifti file. I would investigate the
nifti file's qform and sform matrics using either nifti_tool, fslhd or
pynifti to confirm this.<br>
<br>
Hope this helps,<br>
Luke<br>
<br>
Mathieu Coursolle wrote:
<blockquote
 cite="mid:161C521D-48E4-45C1-8664-BFF4D87A7EE8@rogue-research.com"
 type="cite">
  <div>Hi,</div>
  <div><br>
  </div>
  <div>I am having a similar issue, which may be related.</div>
  <div><br>
  </div>
  <div>I have a NIfTI file, which I load using itkNIfTIImageIO.</div>
  <div><br>
  </div>
  <div>By stepping into ITK, I can see that the s-form (sto_xyz) is:</div>
  <div><br>
  </div>
  <div>[1, 0, 0, -90]</div>
  <div>[0, 1, 0, -126]</div>
  <div>[0, 0, 1, -72]</div>
  <div>[0, 0, 0, 1]</div>
  <div><br>
  </div>
  <div>However, when it read the origin and orientation of the
resulting itkImage,</div>
  <div>I get:</div>
  <div><br>
  </div>
  <div>[-1, 0, 0, 90]</div>
  <div>[0, -1, 0, 126]</div>
  <div>[0, 0, 1, -72]</div>
  <div>[0, 0, 0, 1]</div>
  <div><br>
  </div>
  <div>This data is in the MNI-152 space. I know that the index (0, 0,
0) should be</div>
  <div>(-90, -126, -72) mm in LPI &nbsp;coordinate system (NIfTI's default I
believe).</div>
  <div><br>
  </div>
  <div>Since I want my data in the RAI coordinate system, I then use
the itkOrientImageFilter.</div>
  <div>Assuming it converts the image from LPI to RAI, I would expect
the ouput to be:</div>
  <div>[-1, 0, 0, 90]</div>
  <div>[0, -1, 0, 90]</div>
  <div>[0, 0, 1, -72]</div>
  <div>[0, 0, 0, 1]</div>
  <div><br>
  </div>
  <div>But I get:</div>
  <div>[1, 0, 0, -90]</div>
  <div>[0, 1, 0, -90]</div>
  <div>[0, 0, 1, -72]</div>
  <div>[0, 0, 0, 1]</div>
  <div><br>
  </div>
  <div>By the way, my image dimensions are 181 x 217 x 181.</div>
  <div><br>
  </div>
  <div>I know that index (0, 0, 0) is (90, &nbsp;90, -72) mm in RAI.&nbsp;</div>
  <div><br>
  </div>
  <div>I am right that the matrix I get from ITK is not what is
expected ?</div>
  <div><br>
  </div>
  <div>It looks to me that the itkNIfTIImageIO is doing some transform
to</div>
  <div>the orientation matrix.</div>
  <div><br>
  </div>
  <div>What would be that transformation's purpose ?</div>
  <div><br>
  </div>
  <div>Thanks a lot!</div>
  <div><br>
  </div>
  <div>Mathieu</div>
  <div><br>
  </div>
  <div>
  <div>____________________&nbsp;<br>
Mathieu Coursolle, M.Ing.<span class="Apple-tab-span"
 style="white-space: pre;"> </span><br>
Rogue Research Inc. &nbsp; &nbsp; &nbsp; &nbsp;</div>
  <div><a moz-do-not-send="true" href="http://www.rogue-research.com/">www.rogue-research.com</a><br>
  </div>
  <div><br>
  </div>
  </div>
  <br>
  <div>
  <div>On 6-Apr-09, at 10:46 AM, Antoine DUCHAMPS wrote:</div>
  <br class="Apple-interchange-newline">
  <blockquote type="cite">
    <div>Hi all,<br>
    <br>
I have a DWI sequence (brain) acquired with a Siemens scanner in Dicom<br>
format. After converting it to NIfTI with dcm2nii<br>
(<a moz-do-not-send="true"
 href="http://www.sph.sc.edu/comd/rorden/mricron/dcm2nii.html">http://www.sph.sc.edu/comd/rorden/mricron/dcm2nii.html</a>)
I tried to read<br>
it an recover the orientation by using ITK (I've copied the code below).<br>
The matrix I obtain is the following:<br>
    <br>
0.9997 &nbsp;0.0000 &nbsp;0.0252<br>
0.0002 -1.0000 -0.0072<br>
-0.0252 -0.0072 &nbsp;0.9997<br>
    <br>
However, the transforation matrix in the Dicom header is<br>
    <br>
0.9997 &nbsp;0.0000 &nbsp;0.0252<br>
0.0002 &nbsp;1.0000 -0.0072<br>
-0.0252 &nbsp;0.0072 &nbsp;0.9997<br>
    <br>
If the Dicom image orientation is LPS, this means that the image<br>
orientation in NIfTI is LAS (And not RAS as I believed). Could anybody<br>
clarify this please? Are there several possible orientations in NIfTI?<br>
If so, how can I know the specific image orientation?<br>
    <br>
Antoine. &nbsp;<br>
    <br>
    <br>
#include "itkImageFileReader.h"<br>
#include "itkOrientedImage.h"<br>
    <br>
const unsigned int Dimension = 4;<br>
typedef short PixelType;<br>
typedef itk::OrientedImage&lt;PixelType, Dimension&gt; ImageType;<br>
typedef ImageType::Pointer ImagePointerType;<br>
typedef itk::ImageFileReader&lt; ImageType &gt; ReaderType;<br>
    <br>
    <br>
int main(int argc, char* argv[])<br>
{<br>
    <span class="Apple-tab-span" style="white-space: pre;"> </span><br>
&nbsp;ImageType::Pointer image = ImageType::New();<span
 class="Apple-tab-span" style="white-space: pre;"> </span><br>
    <br>
&nbsp;ReaderType::Pointer reader = ReaderType::New();<br>
&nbsp;reader-&gt;SetFileName(argv[1]);<br>
&nbsp;reader-&gt;Update();<br>
    <br>
&nbsp;image = reader -&gt; GetOutput();<br>
&nbsp;std::cout &lt;&lt; image-&gt;GetDirection() &lt;&lt; std::endl;
std::cout.flush();<br>
    <br>
}<br>
    <br>
_____________________________________<br>
Powered by <a moz-do-not-send="true" href="http://www.kitware.com">www.kitware.com</a><br>
    <br>
Visit other Kitware open-source projects at<br>
    <a moz-do-not-send="true"
 href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br>
    <br>
Please keep messages on-topic and check the ITK FAQ at:
<a class="moz-txt-link-freetext" href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a><br>
    <br>
Follow this link to subscribe/unsubscribe:<br>
<a class="moz-txt-link-freetext" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a><br>
    <br>
    </div>
  </blockquote>
  </div>
  <br>
  <div apple-content-edited="true"> <span class="Apple-style-span"
 style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
  <div style=""><span class="Apple-style-span"
 style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
  <div style=""><span class="Apple-style-span"
 style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
  <div style=""><span class="Apple-style-span"
 style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
  <div style="">
  <div><br>
  </div>
  <div><br>
  </div>
  </div>
  </span><br class="Apple-interchange-newline">
  </div>
  </span><br class="Apple-interchange-newline">
  </div>
  </span><br class="Apple-interchange-newline">
  </div>
  </span><br class="Apple-interchange-newline">
  </div>
  <br>
  <pre wrap="">
<hr size="4" width="90%">
_____________________________________
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>

Visit other Kitware open-source projects at
<a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>

Please keep messages on-topic and check the ITK FAQ at: <a class="moz-txt-link-freetext" href="http://www.itk.org/Wiki/ITK_FAQ">http://www.itk.org/Wiki/ITK_FAQ</a>

Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a>
  </pre>
</blockquote>
</body>
</html>