<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 <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 11:34:09 PM<br>Subject: Re: [Insight-users] A bug in itkAnalyzeImageIO?<br><br>
<div>Jian,</div>
<div> </div>
<div>There were a bunch of changes in the nifti code recently. Can you update and retry?</div>
<div> </div>
<div>Bill<br><br></div>
<div class="gmail_quote">On Thu, Feb 7, 2008 at 5:43 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: 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> Program: Insight Segmentation & Registration Toolkit<br></div> Module: 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> 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></div>
<div class="Ih2E3d"> ReaderType::Pointer reader = ReaderType::New();<br> WriterType::Pointer writer = WriterType::New();<br><br></div>
<div class="Ih2E3d"> 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></div>
<div class="Ih2E3d"> 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>
<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 <<a rel="nofollow" ymailto="mailto:bill.lorensen@gmail.com" target="_blank" href="mailto:bill.lorensen@gmail.com">bill.lorensen@gmail.com</a>><br>
To: Jian Wu <<a rel="nofollow" ymailto="mailto:eewujian@yahoo.com" target="_blank" href="mailto:eewujian@yahoo.com">eewujian@yahoo.com</a>><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 <<a rel="nofollow" ymailto="mailto:hans-johnson@uiowa.edu" target="_blank" href="mailto:hans-johnson@uiowa.edu">hans-johnson@uiowa.edu</a>>; kent williams <<a rel="nofollow" ymailto="mailto:nkwmailinglists@gmail.com" target="_blank" href="mailto:nkwmailinglists@gmail.com">nkwmailinglists@gmail.com</a>><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><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></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>