<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">Hi, Bill,<br>I updated Nifti codes from CVS and got the same errors. But I found out what caused the problem. The data type of input image is unsigned short, which is not supported by Analyze 7.5. If the image was saved as Analyze format without type casting, the converted image could not be opened by the standard Analyze image reader. It would be nice if the NiftiImageIO could give a warning or an error message to prevent it from happening.<br><br>Jian<br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Bill Lorensen &lt;bill.lorensen@gmail.com&gt;<br>To: Jian Wu &lt;eewujian@yahoo.com&gt;<br>Cc: insight-users@itk.org; Hans Johnson
 &lt;hans-johnson@uiowa.edu&gt;; kent williams &lt;nkwmailinglists@gmail.com&gt;<br>Sent: Thursday, February 7, 2008 11:34:09 PM<br>Subject: Re: [Insight-users] A bug in itkAnalyzeImageIO?<br><br>
<div>Jian,</div>
<div>&nbsp;</div>
<div>There were a bunch of changes in the nifti code recently. Can you update and retry?</div>
<div>&nbsp;</div>
<div>Bill<br><br></div>
<div class="gmail_quote">On Thu, Feb 7, 2008 at 5:43 PM, Jian Wu &lt;<a rel="nofollow" ymailto="mailto:eewujian@yahoo.com" target="_blank" href="mailto:eewujian@yahoo.com">eewujian@yahoo.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">
<div>
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;">
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;">Hi, Bill,<br><br>Thanks for the prompt reply. Actually, I have tried to use itkNiftiImageIO. Without explicitly specifying an ImageIO class, the ITK would use itkNiftiImageIO by default if the images have the extension of 'hdr' or 'img'. I tried and failed in the first place. That's why I tried to explicitly use itkAnalyzeImageIO later. When itkNiftiImageIO was used, the Matlab reader gave me exactly the same error message. Even worse, the converted analyze image could not be opened by MIRcro. A simple test code is attached here, very similar to the previous one.<br>
<br>Jian<br><br>Command line:<br>ImageReadWrite brainweb1e1a10f20.mha brainweb1e1a10f20.img 
<div class="Ih2E3d"><br><br>Source Code:<br>/*=========================================================================<br><br>&nbsp; Program:&nbsp;&nbsp; Insight Segmentation &amp; Registration Toolkit<br></div>&nbsp; Module:&nbsp;&nbsp;&nbsp; ImageReadWrite.cxx,v $ 
<div class="Ih2E3d"><br><br>=========================================================================*/<br>#if defined(_MSC_VER)<br>#pragma warning ( disable : 4786 )<br>#endif<br><br>#ifdef __BORLANDC__<br>#define ITK_LEAN_AND_MEAN<br>
#endif<br><br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br></div>
<div class="Ih2E3d">#include "itkImage.h"<br><br>int main( int argc, char ** argv )<br>{<br>&nbsp; if( argc &lt; 3 )<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Usage: " &lt;&lt; std::endl;<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; argv[0] &lt;&lt; " inputImageFile&nbsp; outputImageFile " &lt;&lt; std::endl;<br>
&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp; typedef unsigned short&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PixelType;<br>&nbsp; const&nbsp;&nbsp; unsigned int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dimension = 3;<br>&nbsp; typedef itk::Image&lt; PixelType, Dimension &gt;&nbsp;&nbsp;&nbsp; ImageType;<br><br>&nbsp; typedef itk::ImageFileReader&lt; ImageType &gt;&nbsp; ReaderType;<br>
&nbsp; typedef itk::ImageFileWriter&lt; ImageType &gt;&nbsp; WriterType;<br><br></div>
<div class="Ih2E3d">&nbsp; ReaderType::Pointer reader = ReaderType::New();<br>&nbsp; WriterType::Pointer writer = WriterType::New();<br><br></div>
<div class="Ih2E3d">&nbsp; const char * inputFilename&nbsp; = argv[1];<br>&nbsp; const char * outputFilename = argv[2];<br><br>&nbsp; reader-&gt;SetFileName( inputFilename&nbsp; );<br>&nbsp; writer-&gt;SetFileName( outputFilename );<br><br>&nbsp; writer-&gt;SetInput( reader-&gt;GetOutput() );<br>
<br></div>
<div class="Ih2E3d">&nbsp; try <br>&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp; writer-&gt;Update(); <br>&nbsp;&nbsp;&nbsp; } <br>&nbsp; catch( itk::ExceptionObject &amp; err ) <br>&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "ExceptionObject caught !" &lt;&lt; std::endl; <br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; err &lt;&lt; std::endl; <br>
&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&nbsp;&nbsp;&nbsp; } <br><br>&nbsp; return EXIT_SUCCESS;<br>}<br><br><br><br></div>
<div>
<div></div>
<div class="Wj3C7c">
<div style="font-size: 12pt; font-family: times new roman,new york,times,serif;">----- Original Message ----<br>From: Bill Lorensen &lt;<a rel="nofollow" ymailto="mailto:bill.lorensen@gmail.com" target="_blank" href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>&gt;<br>
To: Jian Wu &lt;<a rel="nofollow" ymailto="mailto:eewujian@yahoo.com" target="_blank" href="mailto:eewujian@yahoo.com">eewujian@yahoo.com</a>&gt;<br>Cc: <a rel="nofollow" ymailto="mailto:insight-users@itk.org" target="_blank" href="mailto:insight-users@itk.org">insight-users@itk.org</a>; Hans Johnson &lt;<a rel="nofollow" ymailto="mailto:hans-johnson@uiowa.edu" target="_blank" href="mailto:hans-johnson@uiowa.edu">hans-johnson@uiowa.edu</a>&gt;; kent williams &lt;<a rel="nofollow" ymailto="mailto:nkwmailinglists@gmail.com" target="_blank" href="mailto:nkwmailinglists@gmail.com">nkwmailinglists@gmail.com</a>&gt;<br>
Sent: Thursday, February 7, 2008 2:50:30 PM<br>Subject: Re: [Insight-users] A bug in itkAnalyzeImageIO?<br><br>Jian,<br>Can you please try the same program with itkNiftiImageIO instead of itkAnalyzeImageIO? The nifti reader/writer should produce valid analyze files. We are looking at replacing itkAnalyzeImageIO's implementation with itkNiftiImageIO. Nifti is a file format with a substantial and active community. If we do this, we will keep the Analyze API.<br>
<br>Thanks,<br><br>Bill<br><br>
<div class="gmail_quote">On Thu, Feb 7, 2008 at 2:25 PM, Jian Wu &lt;<a rel="nofollow" ymailto="mailto:eewujian@yahoo.com" target="_blank" href="mailto:eewujian@yahoo.com">eewujian@yahoo.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>I'm doing image format conversion from other image types to Analyze 7.5. The program did not give me any error message. However I doubt it may not handle the image header information properly. The images I generated in Analyze 7.5 format can be viewed using MRIcro image viewer. But when I tried to opened it using Matlab function analyze75read, it gave me an error message "Reference to non-existent field 'ImgDataType'." I studies the ITK source code and found out the line 1128 of itkAnalyzeImageIO.cxx states:<br>
&nbsp; &nbsp;switch( this-&gt;m_Hdr.dime.datatype)<br>Here "this-&gt;m_Hdr" has not been filled with proper image information yet when the input image is not in Analyze image format. I think "this-&gt;m_ComponentType" should be referred instead. My test code is attached here. I used "brainweb1e1a10f20.mha" as the input image.<br>
<br>Jian<br><br>Command line:<br>ImageReadWriteAnalyze brainweb1e1a10f20.mha brainweb1e1a10f20.img<br><br>Source Code:<br><br>/*=========================================================================<br><br>&nbsp;Program: &nbsp; Insight Segmentation &amp; Registration Toolkit<br>
&nbsp;Module: &nbsp; &nbsp;$ ImageReadWriteAnalyze.cxx $<br>&nbsp;Language: &nbsp;C++<br>&nbsp;Date: &nbsp; &nbsp; &nbsp;$Date: 2008/02/07 $<br>&nbsp;Version: &nbsp; $Revision: 1.0 $<br>&nbsp;Author: &nbsp; &nbsp; Jian Wu<br><br>=========================================================================*/<br>
#if defined(_MSC_VER)<br>#pragma warning ( disable : 4786 )<br>#endif<br><br>#ifdef __BORLANDC__<br>#define ITK_LEAN_AND_MEAN<br>#endif<br><br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br>
#include "itkAnalyzeImageIO.h"<br><br>#include "itkImage.h"<br><br><br>int main( int argc, char ** argv )<br>{<br>&nbsp;if( argc &lt; 3 )<br>&nbsp; &nbsp;{<br>&nbsp; &nbsp;std::cerr &lt;&lt; "Usage: " &lt;&lt; std::endl;<br>
&nbsp; &nbsp;std::cerr &lt;&lt; argv[0] &lt;&lt; " inputImageFile &nbsp;outputImageFile " &lt;&lt; std::endl;<br>&nbsp; &nbsp;return EXIT_FAILURE;<br>&nbsp; &nbsp;}<br><br>&nbsp;typedef unsigned short &nbsp; &nbsp; &nbsp;PixelType;<br>&nbsp;const &nbsp; unsigned int &nbsp; &nbsp; &nbsp; &nbsp;Dimension = 3;<br>
&nbsp;typedef itk::Image&lt; PixelType, Dimension &gt; &nbsp; &nbsp;ImageType;<br><br>&nbsp;typedef itk::ImageFileReader&lt; ImageType &gt; &nbsp;ReaderType;<br>&nbsp;typedef itk::ImageFileWriter&lt; ImageType &gt; &nbsp;WriterType;<br>&nbsp;typedef itk::AnalyzeImageIO &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ImageIOType;<br>
<br><br>&nbsp;ReaderType::Pointer reader = ReaderType::New();<br>&nbsp;WriterType::Pointer writer = WriterType::New();<br>&nbsp;ImageIOType::Pointer analyzeIO = ImageIOType::New();<br><br>&nbsp;const char * inputFilename &nbsp;= argv[1];<br>&nbsp;const char * outputFilename = argv[2];<br>
<br>&nbsp;reader-&gt;SetFileName( inputFilename &nbsp;);<br>&nbsp;writer-&gt;SetFileName( outputFilename );<br><br>&nbsp;writer-&gt;SetInput( reader-&gt;GetOutput() );<br>&nbsp;writer-&gt;SetImageIO( analyzeIO );<br><br>&nbsp;try<br>&nbsp; &nbsp;{<br>&nbsp; &nbsp;writer-&gt;Update();<br>
&nbsp; &nbsp;}<br>&nbsp;catch( itk::ExceptionObject &amp; err )<br>&nbsp; &nbsp;{<br>&nbsp; &nbsp;std::cerr &lt;&lt; "ExceptionObject caught !" &lt;&lt; std::endl;<br>&nbsp; &nbsp;std::cerr &lt;&lt; err &lt;&lt; std::endl;<br>&nbsp; &nbsp;return EXIT_FAILURE;<br>&nbsp; &nbsp;}<br>
<br>&nbsp;return EXIT_SUCCESS;<br>}<br>
<div><br><br><br><br><br><br>&nbsp; &nbsp; &nbsp;____________________________________________________________________________________<br>Looking for last minute shopping deals?<br>Find them fast with Yahoo! Search. &nbsp;<a rel="nofollow" target="_blank" href="http://tools.search.yahoo.com/newsearch/category.php?category=shopping">http://tools.search.yahoo.com/newsearch/category.php?category=shopping</a><br>
_______________________________________________<br>Insight-users mailing list<br><a rel="nofollow" ymailto="mailto:Insight-users@itk.org" target="_blank" href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br><a rel="nofollow" target="_blank" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</div></blockquote></div><br></div><br></div></div></div></div>
<div class="WgoR0d"><br>
<hr size="1">
Never miss a thing. <a rel="nofollow" target="_blank" href="http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs">Make Yahoo your homepage.</a> </div></div></blockquote></div><br>
</div><br></div></div><br>
      <hr size=1>Looking for last minute shopping deals? <a href="http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping"> 
Find them fast with Yahoo! Search.</a></body></html>