[Insight-users] file reader

Luis Ibanez luis.ibanez@kitware.com
Mon, 13 Jan 2003 11:01:20 -0500


Hi Gwenael


Please print out the expression returned by the exception.

This will let you know what kind of problem prevents the
file from being read.


Your try/catch exception should look like


   try
   {
     Load( filename );
   }
   catch( itk::ExceptionObject & ecp )
   {
    std::cerr << "Exception caught" << std::endl;
    std::cerr << ecp << std::endl;
   }
   catch(...)
   {
   std::cerr << "Unknown exception caught !" << std::endl;
   }


Also, note that you no longer need to create the
MetaImageIO object nor set it to the reader. Now the
image filename extension is used to figure out what
kind of ImageIO object to use. As long as you use
".mha" or ".mhd" the reader will be able to find its
way.

Creating the MetaImageIO is only needed if you want
to select specific options of this format.


Please let us know what you find in the error message
of the exception.


    Thanks


       Luis


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



Gwenaël Guillard wrote:

> Hi,
> 
> Thank you for your answer. You are right, the Update( ) is after but the 
> problem is still there. It seems that the Update( ) method send an 
> exception
> The code is
>  
> 
> In the main method
>  
> 
>           try
>           {
>             Load( filename );
>           }
>           catch( ... )
>           {
>             fl_message("Problem reading the files");
>           }
> 
> 
> In Load( ) Method
>  
> 
>           VolumeReaderType::Pointer Reader = VolumeReaderType::New();
>          
>           itk::MetaImageIO::Pointer metaImageIO = itk::MetaImageIO::New();
>           Reader->SetImageIO( metaImageIO );
> 
>           Reader->SetFileName( filename );
>           printf("avant GetOutput\n");
>          
>           PixelType width, height;
>           width =
>         Reader->GetOutput()->GetLargestPossibleRegion().GetSize()[0];
>           height =
>         Reader->GetOutput()->GetLargestPossibleRegion().GetSize()[1];
> 
>           Reader->Update();
>           printf("after Update()\n");
> 
> 
> It never writes "after Update()" but it shows the alert message. I'm 
> able to get width and height  (0 for both because the update is not done 
> yet as you said). So the problem is when the update is called. I try my 
> data on gaussianFilter and there wasn't any problem.
> 
> Gwenael
>  
>