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 <<a href="mailto:eewujian@yahoo.com">eewujian@yahoo.com</a>> 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>
switch( this->m_Hdr.dime.datatype)<br>
Here "this->m_Hdr" has not been filled with proper image information yet when the input image is not in Analyze image format. I think "this->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>
Program: Insight Segmentation & Registration Toolkit<br>
Module: $ ImageReadWriteAnalyze.cxx $<br>
Language: C++<br>
Date: $Date: 2008/02/07 $<br>
Version: $Revision: 1.0 $<br>
Author: 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>
if( argc < 3 )<br>
{<br>
std::cerr << "Usage: " << std::endl;<br>
std::cerr << argv[0] << " inputImageFile outputImageFile " << std::endl;<br>
return EXIT_FAILURE;<br>
}<br>
<br>
typedef unsigned short PixelType;<br>
const unsigned int Dimension = 3;<br>
typedef itk::Image< PixelType, Dimension > ImageType;<br>
<br>
typedef itk::ImageFileReader< ImageType > ReaderType;<br>
typedef itk::ImageFileWriter< ImageType > WriterType;<br>
typedef itk::AnalyzeImageIO ImageIOType;<br>
<br>
<br>
ReaderType::Pointer reader = ReaderType::New();<br>
WriterType::Pointer writer = WriterType::New();<br>
ImageIOType::Pointer analyzeIO = ImageIOType::New();<br>
<br>
const char * inputFilename = argv[1];<br>
const char * outputFilename = argv[2];<br>
<br>
reader->SetFileName( inputFilename );<br>
writer->SetFileName( outputFilename );<br>
<br>
writer->SetInput( reader->GetOutput() );<br>
writer->SetImageIO( analyzeIO );<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>
<div class="WgoR0d"><br>
<br>
<br>
<br>
<br>
<br>
____________________________________________________________________________________<br>
Looking for last minute shopping deals?<br>
Find them fast with Yahoo! Search. <a href="http://tools.search.yahoo.com/newsearch/category.php?category=shopping" target="_blank">http://tools.search.yahoo.com/newsearch/category.php?category=shopping</a><br>
_______________________________________________<br>
Insight-users mailing list<br>
<a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</div></blockquote></div><br>