<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2900.3059" name=GENERATOR>
<STYLE>
<!--
/* Font Definitions */
@font-face
        {font-family:宋体;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@宋体";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        text-align:justify;
        text-justify:inter-ideograph;
        font-size:10.5pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:Verdana;
        color:windowtext;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
/* Page Definitions */
@page Section1
        {size:595.3pt 841.9pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;
        layout-grid:15.6pt;}
div.Section1
        {page:Section1;}
-->
</STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Verdana color=#000000 size=2>Hi, Kurt,</FONT></DIV>
<DIV><FONT face=Verdana color=#000000 size=2></FONT> </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&bugid=3311&pos=17"><FONT
color=#000000>http://www.itk.org/Bug/bug.php?op=show&bugid=3311&pos=17</FONT></A></FONT></DIV>
<DIV><FONT face=Verdana color=#000000 size=2></FONT> </DIV>
<DIV><FONT face=Verdana color=#000000 size=2>Hope that helps!</FONT></DIV>
<DIV><FONT face=Verdana color=#000000 size=2></FONT> </DIV>
<DIV><FONT face=Verdana color=#000000 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 09:02:17</FONT></FONT></DIV>
<DIV><FONT face=Verdana><FONT size=2><STRONG>收件人:</STRONG>
insight-users@itk.org</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><FONT face=Verdana size=2></FONT> </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 "AnatomicalOrientation" 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/~kurtzhao/RPI.zip">http://www.duke.edu/~kurtzhao/RPI.zip</A><BR>The
code is enclosed:<BR><BR>Thanks a lot!<BR>-Kurt<BR><BR><BR>#include
<iostream><BR><BR><BR>#include <metaCommand.h><BR>#include
<itkImageFileWriter.h><BR>#include
<itkImageFileReader.h><BR>#include <itkAnalyzeImageIO.h><BR>#include
<itkNiftiImageIO.h><BR>#include <itkOrientImageFilter.h
><BR>#include <itkSpatialOrientation.h><BR><BR><BR><BR>int main(int
argc, char **argv)<BR> {<BR><BR> /** <BR> * Typedefs and
test reading to determine correct image types.<BR> *
*******************************************************************
<BR> */<BR><BR> /** Initial image type. */<BR> const
unsigned int Dimension = 3;<BR> //typedef
float PixelType;<BR> typedef short PixelType;<BR><BR> /** Some
typedef's. */<BR> typedef itk::Image< PixelType, Dimension
> ImageType; <BR> typedef
itk::ImageFileReader< ImageType >
ReaderType;<BR> typedef
itk::ImageIOBase
ImageIOBaseType;<BR><BR> ReaderType::Pointer reader =
ReaderType::New();<BR><BR> itk::AnalyzeImageIO::Pointer io =
itk::AnalyzeImageIO::New(); <BR><BR> //reader -> SetImageIO ( io )
;<BR> /** Setup the Reader. */<BR> std::string inputFileName;
<BR> //inputFileName = "C:/data/formatConversion/c1002a3T1.hdr";<BR>
inputFileName = "C:/data/formatConversion/RPI.mha"; <BR><BR>
reader->SetFileName( inputFileName.c_str() );<BR><BR> /** Generate all
information. <BR> reader->GenerateOutputInformation();<BR><BR>
ImageIOBaseType::Pointer testImageIOBase = testReader->GetImageIO();
<BR><BR> unsigned int inputDimension =
testImageIOBase->GetNumberOfDimensions();<BR> unsigned int
numberOfComponents = testImageIOBase->GetNumberOfComponents();<BR>
std::string inputPixelComponentType =
testImageIOBase->GetComponentTypeAsString( <BR>
testImageIOBase->GetComponentType() );<BR>
std::cout<<inputPixelComponentType<<std::endl;<BR> std::string
pixelType = testImageIOBase->GetPixelTypeAsString(<BR>
testImageIOBase->GetPixelType() ); <BR>
std::cout<<pixelType<<std::endl;<BR><BR> std::string
outputPixelComponentType = inputPixelComponentType;<BR> */<BR><BR>
try <BR> {<BR> reader -> Update ( )
;<BR> }<BR> catch( itk::ExceptionObject
& err ) <BR> {<BR>
std::cerr << "ExceptionObject caught !" <<
std::endl;<BR> std::cerr << err <<
std::endl;<BR> return EXIT_FAILURE;<BR>
}<BR><BR> typedef itk::OrientImageFilter<ImageType,ImageType>
OrienterType; <BR> OrienterType::Pointer orienter =
OrienterType::New();<BR> orienter->UseImageDirectionOn();<BR>
//orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_LPS);
<BR>
orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RSA);
<BR>
//orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RPI);
<BR> orienter->SetInput( reader -> GetOutput ( ) );<BR> try
<BR> {<BR>
orienter->Update();<BR> }<BR> catch(
itk::ExceptionObject & err )<BR>
{<BR> std::cerr << "ExceptionObject caught
!" << std::endl;<BR> std::cerr << err
<< std::endl;<BR> return EXIT_FAILURE;
<BR> }<BR><BR> typedef itk::ImageFileWriter <
ImageType > WriterType;<BR><BR>
WriterType::Pointer writer = WriterType::New();<BR><BR>
itk::NiftiImageIO::Pointer niftIio = itk::NiftiImageIO::New();<BR><BR>
//writer -> SetImageIO ( niftIio ) ;<BR><BR> std::string
outputFileName; <BR><BR> outputFileName =
"C:/data/formatConversion/RSA.mha";<BR> //outputFileName =
"C:/data/formatConversion/LPS.mha"; <BR> //outputFileName =
"C:/data/formatConversion/RPI.mha";<BR><BR> writer ->SetFileName(
outputFileName.c_str() );<BR><BR> //writer -> SetInput ( reader ->
GetOutput ( ) ) ;<BR> writer -> SetInput ( orienter -> GetOutput ( )
) ; <BR><BR> writer -> UseCompressionOn ( ) ;<BR><BR> try
<BR> {<BR> writer -> Update ( )
;<BR> }<BR> catch( itk::ExceptionObject
& err )<BR> {<BR>
std::cerr << "ExceptionObject caught !" << std::endl;
<BR> std::cerr << err <<
std::endl;<BR> return EXIT_FAILURE;<BR>
}<BR><BR> return EXIT_SUCCESS;<BR> }<BR></FONT></DIV></BODY></HTML>