[Insight-users] FDF Reader

Glenn Pierce glennpierce at connectfree.co.uk
Tue, 09 Mar 2004 19:15:56 +0000


--=-wRdyV6LlbpMvn/bpYM95
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Mon, 2004-03-08 at 15:05, Luis Ibanez wrote: 
> Hi Glen,
> 
> First,
> The obvious question:  Have you succeded
> visualizing this FDF file with any other tool ?
> In other words: Do you trust this file ?

I did, but I am now not so sure. It is fine on the sun machine in work
but the files were then emailed to me perhaps a corruption during email
transit ?
I have not been able to read the data with any other programs due to a
lack of knowledge about programs that get open raw data or fdf files.
Although I did try with ImageJ with little luck so maybe it is the file.


> Are you sure that the pixel is encoded in floats
> in this file ?  a simple verification is that
> the file size should have a size of
> 
>         256 x 256 x 4 = 250880 bytes

After I manually stripped the header off, the file size was 262161 
compared to

  256*256*4 =262144

So a few bytes extra ?

> 
> Second:
> You may want to simplify your MetaHeader
> to be just
> 
> 
>     NDims = 2
>     DimSize = 256 256
>     ElementType = MET_FLOAT
>     ElementSpacing = 1.0 1.0
>     ElementByteOrderMSB = False
>     ElementDataFile = brain.raw
> 
> 
> That's the minimum number of entries needed
> in the header.

Tried this, but it didn't help

> 
> Third:
> Please post the section of code where you are
> instantiating the MetaImage reader and printing
> out its content.  The order of operations may
> be important.
> 

I have attached my code.

I am going to try to get other fdf files by methods other than email in
case the image is corrupt.

Thanks for the help! 



___________________________________________

Glenn Pierce
___________________________________________




--=-wRdyV6LlbpMvn/bpYM95
Content-Disposition: attachment; filename=ImageReadWrite.cxx
Content-Type: text/plain; name=ImageReadWrite.cxx; charset=iso-8859-1
Content-Transfer-Encoding: 7bit

#include "itkImageFileReader.h"
#include "itkImageToVTKImageFilter.h"
#include <vtkRenderWindowInteractor.h>

#include "itkFDFImageIO.h"

#include <vtkImageViewer.h>

#include "itkImage.h"

int main( int argc, char ** argv )
{
  typedef float      PixelType;
  const   unsigned int        Dimension = 2;
  typedef itk::Image< PixelType, Dimension >    ImageType;
  typedef itk::ImageFileReader< ImageType >  ReaderType;
  typedef itk::ImageToVTKImageFilter< ImageType > ImageToVTKType;
  //typedef itk::FDFImageIO ImageIOType;

  ReaderType::Pointer reader = ReaderType::New();
  //ImageIOType::Pointer fdfIO = ImageIOType::New();
  //fdfIO->SetFileTypeToBinary();
  //fdfIO->SetFileTypeToASCII();
  //fdfIO->SetByteOrderToBigEndian();
  //reader->SetImageIO( fdfIO );

  reader->SetFileName( "/home/glenn/development/reader/brain.mhd" );
  //reader->SetFileName( "/home/glenn/development/reader/test.fdf" );

  try {
      reader->Update();
  }
  catch( itk::ExceptionObject & exp )
  {
      std::cerr << "Exception caught" << std::endl;
      std::cerr << exp << std::endl;
  }

  std::cout << reader << std::endl;

  vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New(); 

  ImageToVTKType::Pointer bridge = ImageToVTKType::New();
  bridge->SetInput( reader->GetOutput() );

  vtkImageViewer *viewer = vtkImageViewer::New();
  viewer->SetInput( bridge->GetOutput() );
  viewer->SetColorWindow(255);
  viewer->SetColorLevel(128);
  //viewer->SetupInteractor(iren);

  while(1)
      viewer->Render();

  viewer->Delete();
  //iren->Delete();

  return 0;
}




--=-wRdyV6LlbpMvn/bpYM95--