<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><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<br>
<br>
Source Code:<br>
/*=========================================================================<br><br> Program: Insight Segmentation & Registration Toolkit<br> Module: ImageReadWrite.cxx,v $<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 "itkImage.h"<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><br> ReaderType::Pointer reader = ReaderType::New();<br> WriterType::Pointer writer = WriterType::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><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><br><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Bill Lorensen <bill.lorensen@gmail.com><br>To: Jian Wu <eewujian@yahoo.com><br>Cc: insight-users@itk.org; Hans Johnson <hans-johnson@uiowa.edu>; kent williams <nkwmailinglists@gmail.com><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 <<a rel="nofollow" ymailto="mailto:eewujian@yahoo.com" target="_blank" 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 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><br>
<hr size=1>Never miss a thing. <a href="http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs"> Make Yahoo your homepage.</a>
</body></html>