[Insight-users] A bug in itkAnalyzeImageIO?

Bill Lorensen bill.lorensen at gmail.com
Thu Feb 7 23:34:09 EST 2008


Jian,

There were a bunch of changes in the nifti code recently. Can you update and
retry?

Bill

On Thu, Feb 7, 2008 at 5:43 PM, Jian Wu <eewujian at yahoo.com> wrote:

>  Hi, Bill,
>
> 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.
>
> Jian
>
> Command line:
> ImageReadWrite brainweb1e1a10f20.mha brainweb1e1a10f20.img
>
> Source Code:
>
> /*=========================================================================
>
>   Program:   Insight Segmentation & Registration Toolkit
>   Module:    ImageReadWrite.cxx,v $
>
>
> =========================================================================*/
> #if defined(_MSC_VER)
> #pragma warning ( disable : 4786 )
> #endif
>
> #ifdef __BORLANDC__
> #define ITK_LEAN_AND_MEAN
> #endif
>
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkImage.h"
>
> int main( int argc, char ** argv )
> {
>   if( argc < 3 )
>     {
>     std::cerr << "Usage: " << std::endl;
>     std::cerr << argv[0] << " inputImageFile  outputImageFile " <<
> std::endl;
>     return EXIT_FAILURE;
>     }
>
>   typedef unsigned short      PixelType;
>   const   unsigned int        Dimension = 3;
>   typedef itk::Image< PixelType, Dimension >    ImageType;
>
>   typedef itk::ImageFileReader< ImageType >  ReaderType;
>   typedef itk::ImageFileWriter< ImageType >  WriterType;
>
>   ReaderType::Pointer reader = ReaderType::New();
>   WriterType::Pointer writer = WriterType::New();
>
>   const char * inputFilename  = argv[1];
>   const char * outputFilename = argv[2];
>
>   reader->SetFileName( inputFilename  );
>   writer->SetFileName( outputFilename );
>
>   writer->SetInput( reader->GetOutput() );
>
>   try
>     {
>     writer->Update();
>     }
>   catch( itk::ExceptionObject & err )
>     {
>     std::cerr << "ExceptionObject caught !" << std::endl;
>     std::cerr << err << std::endl;
>     return EXIT_FAILURE;
>     }
>
>   return EXIT_SUCCESS;
> }
>
>
>
>   ----- Original Message ----
> From: Bill Lorensen <bill.lorensen at gmail.com>
> To: Jian Wu <eewujian at yahoo.com>
> Cc: insight-users at itk.org; Hans Johnson <hans-johnson at uiowa.edu>; kent
> williams <nkwmailinglists at gmail.com>
> Sent: Thursday, February 7, 2008 2:50:30 PM
> Subject: Re: [Insight-users] A bug in itkAnalyzeImageIO?
>
> Jian,
> 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.
>
> Thanks,
>
> Bill
>
> On Thu, Feb 7, 2008 at 2:25 PM, Jian Wu <eewujian at yahoo.com> wrote:
>
> > Hi,
> > 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:
> >    switch( this->m_Hdr.dime.datatype)
> > 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.
> >
> > Jian
> >
> > Command line:
> > ImageReadWriteAnalyze brainweb1e1a10f20.mha brainweb1e1a10f20.img
> >
> > Source Code:
> >
> >
> > /*=========================================================================
> >
> >  Program:   Insight Segmentation & Registration Toolkit
> >  Module:    $ ImageReadWriteAnalyze.cxx $
> >  Language:  C++
> >  Date:      $Date: 2008/02/07 $
> >  Version:   $Revision: 1.0 $
> >  Author:     Jian Wu
> >
> >
> > =========================================================================*/
> > #if defined(_MSC_VER)
> > #pragma warning ( disable : 4786 )
> > #endif
> >
> > #ifdef __BORLANDC__
> > #define ITK_LEAN_AND_MEAN
> > #endif
> >
> > #include "itkImageFileReader.h"
> > #include "itkImageFileWriter.h"
> > #include "itkAnalyzeImageIO.h"
> >
> > #include "itkImage.h"
> >
> >
> > int main( int argc, char ** argv )
> > {
> >  if( argc < 3 )
> >    {
> >    std::cerr << "Usage: " << std::endl;
> >    std::cerr << argv[0] << " inputImageFile  outputImageFile " <<
> > std::endl;
> >    return EXIT_FAILURE;
> >    }
> >
> >  typedef unsigned short      PixelType;
> >  const   unsigned int        Dimension = 3;
> >  typedef itk::Image< PixelType, Dimension >    ImageType;
> >
> >  typedef itk::ImageFileReader< ImageType >  ReaderType;
> >  typedef itk::ImageFileWriter< ImageType >  WriterType;
> >  typedef itk::AnalyzeImageIO                 ImageIOType;
> >
> >
> >  ReaderType::Pointer reader = ReaderType::New();
> >  WriterType::Pointer writer = WriterType::New();
> >  ImageIOType::Pointer analyzeIO = ImageIOType::New();
> >
> >  const char * inputFilename  = argv[1];
> >  const char * outputFilename = argv[2];
> >
> >  reader->SetFileName( inputFilename  );
> >  writer->SetFileName( outputFilename );
> >
> >  writer->SetInput( reader->GetOutput() );
> >  writer->SetImageIO( analyzeIO );
> >
> >  try
> >    {
> >    writer->Update();
> >    }
> >  catch( itk::ExceptionObject & err )
> >    {
> >    std::cerr << "ExceptionObject caught !" << std::endl;
> >    std::cerr << err << std::endl;
> >    return EXIT_FAILURE;
> >    }
> >
> >  return EXIT_SUCCESS;
> > }
> >
> >
> >
> >
> >
> >
> >
> >  ____________________________________________________________________________________
> > Looking for last minute shopping deals?
> > Find them fast with Yahoo! Search.
> > http://tools.search.yahoo.com/newsearch/category.php?category=shopping
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
> >
>
>
>
> ------------------------------
> Never miss a thing. Make Yahoo your homepage.<http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20080207/86fe457e/attachment.html


More information about the Insight-users mailing list