Thanks Fucang.<br><br>-Kurt<br><br><div><span class="gmail_quote">On 3/1/07, <b class="gmail_sendername">jiafucang</b> &lt;<a href="mailto:jiafucang@anketech.com">jiafucang@anketech.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">






<div>
<div><font color="#000000" face="Verdana" size="2">Hi, Kurt,</font></div>
<div><font color="#000000" face="Verdana" size="2"></font>&nbsp;</div>
<div><font face="Verdana" size="2"><font color="#000000">This is a bug </font><a href="http://www.itk.org/Bug/bug.php?op=show&amp;bugid=3311&amp;pos=17" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
<font color="#000000">http://www.itk.org/Bug/bug.php?op=show&amp;bugid=3311&amp;pos=17</font></a></font></div>
<div><font color="#000000" face="Verdana" size="2"></font>&nbsp;</div>
<div><font color="#000000" face="Verdana" size="2">Hope that helps!</font></div>
<div><font color="#000000" face="Verdana" size="2"></font>&nbsp;</div>
<div><font color="#000000" face="Verdana" size="2">Fucang</font></div>
<div><font face="Verdana" size="2">
<hr>
</font></div>
<div><font face="Verdana"><font size="2"><strong>发件人:</strong> kurt 
Zhao</font></font></div>
<div><font face="Verdana"><font size="2"><strong>发送时间:</strong> 
2007-03-01&nbsp;09:02:17</font></font></div>
<div><font face="Verdana"><font size="2"><strong>收件人:</strong> 
<a href="mailto:insight-users@itk.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">insight-users@itk.org</a></font></font></div>
<div><font face="Verdana"><font size="2"><strong>抄送:</strong> </font></font></div>
<div><font face="Verdana"><font size="2"><strong>主题:</strong> [Insight-users] 
AnatomicalOrientation and OrientImageFilter</font></font></div><div><span class="e" id="q_1110c0916b78a1cd_1">
<div><font face="Verdana" size="2"></font>&nbsp;</div>
<div><font face="Verdana" size="2">Hi guys,<br><br>I am trying to convert the 
AnatomicalOrientation of a 3D MRI from RPI to RSA using OrientImageFilter. 
<br><br><br>However, the entry &quot;AnatomicalOrientation&quot; in the header of the 
output *mha file is always RPI. itkSNAP was not able to interpret the anatomical 
orientation as RSA either. <br><br>so my question is:<br><br>1. is it a bug in 
OrientImageFilter?<br><br>2. How to verify the AnatomicalOrientation of a *.nii 
or *.mha file? should I look at the header of meta data? or load them into 
Slicer3 or SNAP? <br><br>The data can be accessed at <a href="http://www.duke.edu/%7Ekurtzhao/RPI.zip" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.duke.edu/~kurtzhao/RPI.zip</a><br>The 
code is enclosed:<br><br>Thanks a lot!<br>-Kurt<br><br><br>#include 
&lt;iostream&gt;<br><br><br>#include &lt;metaCommand.h&gt;<br>#include 
&lt;itkImageFileWriter.h&gt;<br>#include 
&lt;itkImageFileReader.h&gt;<br>#include &lt;itkAnalyzeImageIO.h&gt;<br>#include 
&lt;itkNiftiImageIO.h&gt;<br>#include &lt;itkOrientImageFilter.h 
&gt;<br>#include &lt;itkSpatialOrientation.h&gt;<br><br><br><br>int main(int 
argc, char **argv)<br>&nbsp; {<br><br>&nbsp; /** <br>&nbsp;&nbsp; * Typedefs and 
test reading to determine correct image types.<br>&nbsp;&nbsp; * 
******************************************************************* 
<br>&nbsp;&nbsp; */<br><br>&nbsp; /** Initial image type. */<br>&nbsp; const 
unsigned int&nbsp;&nbsp;&nbsp; Dimension&nbsp; =&nbsp; 3;<br>&nbsp; //typedef 
float PixelType;<br>&nbsp; typedef short PixelType;<br><br>&nbsp; /** Some 
typedef&#39;s. */<br>&nbsp; typedef itk::Image&lt; PixelType, Dimension 
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ImageType; <br>&nbsp; typedef 
itk::ImageFileReader&lt; ImageType &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ReaderType;<br>&nbsp; typedef 
itk::ImageIOBase&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ImageIOBaseType;<br><br>&nbsp; ReaderType::Pointer reader = 
ReaderType::New();<br><br>&nbsp; itk::AnalyzeImageIO::Pointer io = 
itk::AnalyzeImageIO::New(); <br><br>&nbsp; //reader -&gt; SetImageIO ( io ) 
;<br>&nbsp; /** Setup the Reader. */<br>&nbsp; std::string inputFileName; 
<br>&nbsp; //inputFileName = &quot;C:/data/formatConversion/c1002a3T1.hdr&quot;;<br>&nbsp; 
inputFileName = &quot;C:/data/formatConversion/RPI.mha&quot;; <br><br>&nbsp; 
reader-&gt;SetFileName( inputFileName.c_str() );<br><br>&nbsp; /** Generate all 
information. <br>&nbsp; reader-&gt;GenerateOutputInformation();<br><br>&nbsp; 
ImageIOBaseType::Pointer testImageIOBase = testReader-&gt;GetImageIO(); 
<br><br>&nbsp; unsigned int inputDimension = 
testImageIOBase-&gt;GetNumberOfDimensions();<br>&nbsp; unsigned int 
numberOfComponents = testImageIOBase-&gt;GetNumberOfComponents();<br>&nbsp; 
std::string inputPixelComponentType = 
testImageIOBase-&gt;GetComponentTypeAsString( <br>&nbsp;&nbsp;&nbsp; 
testImageIOBase-&gt;GetComponentType() );<br>&nbsp; 
std::cout&lt;&lt;inputPixelComponentType&lt;&lt;std::endl;<br>&nbsp; std::string 
pixelType = testImageIOBase-&gt;GetPixelTypeAsString(<br>&nbsp;&nbsp;&nbsp; 
testImageIOBase-&gt;GetPixelType() ); <br>&nbsp; 
std::cout&lt;&lt;pixelType&lt;&lt;std::endl;<br><br>&nbsp; std::string&nbsp; 
outputPixelComponentType = inputPixelComponentType;<br>&nbsp; */<br><br>&nbsp; 
try <br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; reader -&gt; Update ( ) 
;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; catch( itk::ExceptionObject&nbsp; 
&amp;&nbsp; err&nbsp; ) <br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; 
std::cerr&nbsp; &lt;&lt; &quot;ExceptionObject caught !&quot;&nbsp; &lt;&lt; 
std::endl;<br>&nbsp;&nbsp;&nbsp; std::cerr&nbsp; &lt;&lt; err &lt;&lt;&nbsp; 
std::endl;<br>&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&nbsp;&nbsp;&nbsp; 
}<br><br>&nbsp; typedef itk::OrientImageFilter&lt;ImageType,ImageType&gt; 
OrienterType; <br>&nbsp; OrienterType::Pointer orienter =&nbsp; 
OrienterType::New();<br>&nbsp; orienter-&gt;UseImageDirectionOn();<br>&nbsp; 
//orienter-&gt;SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_LPS); 
<br>&nbsp; 
orienter-&gt;SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RSA); 
<br>&nbsp; 
//orienter-&gt;SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RPI); 
<br>&nbsp; orienter-&gt;SetInput( reader -&gt; GetOutput ( ) );<br>&nbsp; try 
<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; 
orienter-&gt;Update();<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; catch( 
itk::ExceptionObject&nbsp; &amp;&nbsp; err&nbsp; )<br>&nbsp;&nbsp;&nbsp; 
{<br>&nbsp;&nbsp;&nbsp; std::cerr&nbsp; &lt;&lt; &quot;ExceptionObject caught 
!&quot;&nbsp; &lt;&lt; std::endl;<br>&nbsp;&nbsp;&nbsp; std::cerr&nbsp; &lt;&lt; err 
&lt;&lt;&nbsp; std::endl;<br>&nbsp;&nbsp;&nbsp; return EXIT_FAILURE; 
<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp; typedef itk::ImageFileWriter &lt; 
ImageType &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WriterType;<br><br>&nbsp; 
WriterType::Pointer writer = WriterType::New();<br><br>&nbsp; 
itk::NiftiImageIO::Pointer niftIio = itk::NiftiImageIO::New();<br><br>&nbsp; 
//writer -&gt; SetImageIO ( niftIio ) ;<br><br>&nbsp; std::string 
outputFileName; <br><br>&nbsp; outputFileName = 
&quot;C:/data/formatConversion/RSA.mha&quot;;<br>&nbsp; //outputFileName = 
&quot;C:/data/formatConversion/LPS.mha&quot;; <br>&nbsp; //outputFileName = 
&quot;C:/data/formatConversion/RPI.mha&quot;;<br><br>&nbsp; writer -&gt;SetFileName( 
outputFileName.c_str() );<br><br>&nbsp; //writer -&gt; SetInput ( reader -&gt; 
GetOutput ( ) ) ;<br>&nbsp; writer -&gt; SetInput ( orienter -&gt; GetOutput ( ) 
) ; <br><br>&nbsp; writer -&gt; UseCompressionOn ( ) ;<br><br>&nbsp; try 
<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; writer -&gt; Update ( ) 
;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; catch( itk::ExceptionObject&nbsp; 
&amp;&nbsp; err&nbsp; )<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; 
std::cerr&nbsp; &lt;&lt; &quot;ExceptionObject caught !&quot;&nbsp; &lt;&lt; std::endl; 
<br>&nbsp;&nbsp;&nbsp; std::cerr&nbsp; &lt;&lt; err &lt;&lt;&nbsp; 
std::endl;<br>&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&nbsp;&nbsp;&nbsp; 
}<br><br>&nbsp; return EXIT_SUCCESS;<br>&nbsp; }<br></font></div></span></div></div>
</blockquote></div><br>