[Insight-users] ImageSeriesReader Problems

Rhazes Spell rus1 at duke.edu
Wed Jan 12 18:14:54 EST 2005


I am an ITK newbie, and I am trying to learn the toolkit by doing some  
small things first.  I am having trouble loading a series of images.   
My test code is only loading 2 of the images from the series as a test,  
but I am not having success with that either.  I was able to load a  
single image, but no luck after that.  Enclosed is my sample code and  
the output messages.  Any assistance is greatly appreciated.  (Note, I  
am coding in Objective C++ and using XCode (OS X) as my IDE.  However,  
the only Objective C specific code in the example are the #import and  
setting up Autorelase. )

#include "imageViewer.h"

#import <Cocoa/Cocoa.h>
#include <vector>;
#include <string>;

#define id Id
#include "itkImage.h";
#include "itkImageSeriesReader.h";
#include "itkNumericSeriesFileNames.h";
#include "itkTIFFImageIO.h";
#undef id

using namespace std;
void fileSeriesTest();
void fileReaderTest();

//typedef unsigned short int itkPixelType;
typedef itk::RGBPixel<unsigned char> itkPixelType;
const unsigned int Dimension = 3;
	
typedef itk::Image< itkPixelType, Dimension > ImageType;
typedef itk::ImageFileReader< ImageType > ReaderType;
	
typedef itk::ImageSeriesReader<ImageType> SeriesReader;	
typedef itk::NumericSeriesFileNames NameGeneratorType;  //Generates  
file name series

int main( int argc, char *argv[] ) {
//	NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
	
//	fileReaderTest();  // Reading one tif works
	fileSeriesTest();  // Reading 2 or more tif files does not work ??
	
//	[pool release];
	return 0;
}

void fileReaderTest() {
//	NSString * fname = [NSString  
stringWithString:@"/Users/rhazes/Projects/Development/itk/tutorial/dat/ 
test002.tif"];
//	NSString * fname = [NSString  
stringWithString:@"/Users/rhazes/dat/wormtox/confocal/12_16_04/10x- 
CZ1197010.tif"];
	char * fname =  
"/Users/rhazes/dat/wormtox/confocal/12_16_04/10x-CZ1197010.tif";
	ReaderType::Pointer reader = ReaderType::New();
	
	reader->SetFileName(fname);
	reader->Update();
}


void fileSeriesTest() {
	SeriesReader::Pointer seriesReader = SeriesReader::New();
	
	NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
	
	nameGenerator->SetStartIndex( 10 );
	nameGenerator->SetEndIndex( 11 );
	nameGenerator->SetIncrementIndex(1);
	
//	nameGenerator->SetSeriesFormat(  
"/Users/rhazes/Projects/Development/itk/tutorial/dat/test%03d.tif" );
	nameGenerator->SetSeriesFormat(  
"/Users/rhazes/dat/wormtox/confocal/12_16_04/10x-CZ1197%03d.tif" );
			
	seriesReader->SetImageIO(itk::TIFFImageIO::New());
	seriesReader->SetFileNames(nameGenerator->GetFileNames());

	//Debug message printing
	
	vector<string> v;
	v = nameGenerator->GetFileNames();
	cout << v[0] << " ,\n " << v[1] << endl;
	/*  ***************					*/

	cout << "Before try/catch" << endl;
	try {
		seriesReader->Update();
		cout << "Series reader updated" << endl;	
	} catch(itk::ExceptionObject & excp) {
		std::cerr << "Error reading the file series " << std::endl;
		std::cerr << excp << std::endl;
	}

}

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Output - When calling 	fileReaderTest();

TestBed has exited with status 0.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Output - When calling 	fileSeriesTest();

/Users/rhazes/dat/wormtox/confocal/12_16_04/10x-CZ1197010.tif,
/Users/rhazes/dat/wormtox/confocal/12_16_04/10x-CZ1197011.tif
Before try/catch

TestBed has exited due to signal 10 (SIGBUS).
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



Cheers,

************************************************************************ 
***************
Rhazes Spell, Ph.D.
Duke University,
          -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=
Visualization Technology Group - http://vis.duke.edu
Ctr. for Environmental Genomics - http://www.envgenomics.duke.edu
Ctr. for Computational Science Engineering and Medicine -  
http://csem.duke.edu
          -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=
rhazes.spell at alumni.duke.edu
919.660.5595 (office)
************************************************************************ 
****************
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 6937 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/insight-users/attachments/20050112/ed78210f/attachment-0001.bin


More information about the Insight-users mailing list