[Insight-users] Re: Does Problem persists with Insight 1.2 ? ( Reading MetaImages)

Luis Ibanez luis.ibanez@kitware.com
Fri, 14 Mar 2003 10:08:45 -0500


Hi Shilpa,

What is your platform ?

It looks like the reader is not finding the entry

     ElementType = MET_USHORT

even though it seems to be defined in your file...

---

I would suspect that your header text file has
some sort of formating problem. It could be wrong
end of lines, or strange caracters inserted.

Can you open the header in a plain text editor ?
Does it look right ?

Could you please send us the header attached to
an email.


Thanks


    Luis


---------------------

shilpa kinkar wrote:
> Hi Luis,
> 
> Thanks for answering my question.
> 
> Now, I have started using Insight 1.2 . I am trying to use 
> MetaImageReadWrite. I am using the same code i sent you eariler( using 
> just reader) but I use Insight 1.2 binary directory. I still having 
> problems for reading the pp37.raw image with header pp37.mhd created 
> using MetaImporter. *The error is  ----> *
> 
> *MetaImage: Read: Cannot open file
> itk::ERROR: MetaImageIO(010276A0): Unknown pixel type: 0
> *
> 
> This is the header file generated by MetaImporter --> ( fields in file 
> are at separate lines )
> 
> NDims = 2    DimSize = 512 512  ElementSpacing = 0.7 0.585 Position = 0 
> 0 ElementByteOrderMSB = True ElementType = MET_USHORT HeaderSize = -1 
> ElementDataFile = pp37.raw
> 
> What is going wrong ? I have have used proper header names, proper file 
> paths. Please help.
> 
> Here is the code - if in case needed ...
> 
> ***********************************************************************************************
> 
> typedef itk::Image<unsigned short, 2> ImageType;
> 
> int main(int argc, char **argv)
>   {  // Declare a reader
>   typedef itk::ImageFileReader< ImageType > VolumeReaderType;
>   VolumeReaderType::Pointer reader = VolumeReaderType::New();
> 
>   typedef  itk::MetaImageIO MetaReaderType;
>   MetaReaderType ::Pointer  metaReader  = MetaReaderType::New();
> 
>   reader->SetImageIO( metaReader );
> 
>   // Set the name of the file to read
>   reader->SetFileName( "pp37.mhd" ); // test.mhd/.mha
> 
>   // Set the image into which the results should be stored
>   /*ImageType::Pointer imOut;
>   imOut = reader->GetOutput(); // data will be set in image pointer.*/
>  
>   // See if the file can be read - "try" otherwise program will
>   // mysteriously exit on failure in the Object factory
>   try {  reader->Update();  }
> 
>   catch( std::exception & see )
>   {
>       std::cerr << see.what() << std::endl;
>       return -1;
>   }
>   catch( itk::ExceptionObject & eee )
>   {
>       std::cerr << eee << std::endl;
>       return -1;
>   }