[Insight-users] A bug in itkAnalyzeImageIO?

Bill Lorensen bill.lorensen at gmail.com
Fri Feb 8 18:27:02 EST 2008


Jian,

This looks like a bug to me. Can you make a bug report following the
instructions in:
http://itk.org/Wiki/ITK_Procedure_for_Contributing_Bug_Fixes

Thanks,

Bill
On Fri, Feb 8, 2008 at 5:46 PM, Jian Wu <eewujian at yahoo.com> wrote:

>  Hi, Bill,
> 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.
>
> Jian
>
>  ----- 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 11:34:09 PM
> Subject: Re: [Insight-users] A bug in itkAnalyzeImageIO?
>
> 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.cxxstates:
> > >    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>
> >
>
>
>
> ------------------------------
> Looking for last minute shopping deals? Find them fast with Yahoo! Search.<http://us.rd.yahoo.com/evt=51734/*http://tools.search.yahoo.com/newsearch/category.php?category=shopping>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20080208/b851c972/attachment.html


More information about the Insight-users mailing list