[Insight-users] reading raw data

Lucas Lorenzo lucas at cvrti . utah . edu
Thu, 30 Oct 2003 17:35:08 -0700


Hi all,
before starting I want to apologize for the basic content of my inquiry 
but I'm just learning ITK.

1) I'm trying to read some MRI data consisting of 20 slices of 250x256 
pixels each.
2) The data is stored as unsigned short.
3) I was previously using Matlab and this is the code I used to read it:

    ff=fopen('saCine.slice14.256x256x20','r','ieee-be');
    slice=fread(ff,'ushort');
    fclose(ff);
    number_of_slcs=length(slice)/(256^2);
    slice=reshape(slice,[256 256 number_of_slcs]);

4) I tried the following code in C++ (it's a copy of Image2.cxx except 
that I changed the PixelType

	#include "itkImage.h"
	#include "itkImageFileReader.h"

	int main( int argc, char *argv[])
	{
	  typedef unsigned short          PixelType;
	  const unsigned int             Dimension = 3;
	
	  typedef itk::Image< PixelType, Dimension >   ImageType;

	  typedef itk::ImageFileReader< ImageType >  ReaderType;

	  ReaderType::Pointer reader = ReaderType::New();

	  const char * filename = argv[1];
	  reader->SetFileName( filename );

	  reader->Update();

	  ImageType::Pointer image = reader->GetOutput();
	  return 0;
	}

But I'm having a run time error at "reader->Update()":

	  Abort trap

Could someone please point me what am I doing wrong ?
Thanks,

Lucas


Lucas Lorenzo

University of Utah
Nora Eccles Harrison CardioVascular Research and Training Institute
Fellows Room
95 South 2000 East
Salt Lake City, UT 84112-5000

e-mail:  lucas at cvrti . utah . edu
telephone: 801-587-9536