[Insight-users] ImagePCAShapeModelEstimator question

Lucas Lorenzo lucas at cvrti.utah.edu
Tue, 24 Feb 2004 10:34:44 -0700


Thanks a lot Lydia ! I've already checked out a cvs copy and it works  
fine for me.

Lucas

On Feb 24, 2004, at 2:11 AM, Lydia Ng wrote:

> Hi Lucas,
>
> Thanks for your bug report.
> There was a bug with the way the filter was computing the number of  
> outputs
> to produce. It has now been fixed in the cvs version.
> See if this fixes your problem.
> Please also make sure you set the number of desired outputs via
> SetNumberOfPrincipalComponentsRequired( N )
>
> - Lydia
>
> 	-----Original Message-----
> 	From: Lucas Lorenzo [mailto:lucas at cvrti.utah.edu]
> 	Sent: Mon 2/23/2004 17:42
> 	To: ITK
> 	Cc:
> 	Subject: [Insight-users] ImagePCAShapeModelEstimator question
> 	
> 	
> 	Hi all,
>
> 	I have a doubt with the ImagePCAShapeModelEstimator class:
>
> 	Let's say that I have N training images and I want to generate the N
> principal components (I know I'm going to use only a few but I want to
> examine them). So, I have an ImagePCAShapeModelEstimator which I call
> applyPCAShapeEstimator. After specifiying the 19 training images, doing
> applyPCAShapeEstimator->Update(); and writing the mean to a file (I'm  
> getting
> it by applying the GetOutput method to applyPCAShapeEstimator with  
> index 0:
> applyPCAShapeEstimator->GetOutput( 0 ) ) I want to write all N  
> principal
> components as images to files. For that I do:
>
> 	
> / 
> /----------------------------------------------------------------------
> 	// generate the file names
> 	
> / 
> /----------------------------------------------------------------------
>
> 	typedef itk::NumericSeriesFileNames NumSerFNM;
> 	NumSerFNM::Pointer filenames_gen = NumSerFNM::New();
> 	filenames_gen->SetSeriesFormat("mode%02d.vtk");
> 	filenames_gen->SetStartIndex(1);
> 	filenames_gen->SetEndIndex(N);
> 	std::vector<std::string > mode_fln = filenames_gen->GetFileNames();
>
> 	
> / 
> /----------------------------------------------------------------------
> 	// Write the principal modes to disk
> 	
> / 
> /----------------------------------------------------------------------
>
> 	for(unsigned int i = 1; i <= N; i++ )
> 	{
> 	writer->SetFileName(mode_fln[i-1].c_str());
> 	writer->SetInput(applyPCAShapeEstimator->GetOutput( i ) );
>
> 	try
> 	{
> 	writer->Update();
> 	}
> 	catch( itk::ExceptionObject exp )
> 	{
> 	std::cerr << "Exception caught ! Mode writer number " << i <<
> std::endl;
> 	std::cerr << exp << std::endl;
> 	}
>
> 	}
> 	When running the code the following exception is been caught when
> trying to write component number N:
>
> 	Exception caught ! Mode writer number N
>
> 	itk::ExceptionObject (0xbffff6c0)
> 	Location: "Unknown"
> 	File: /ITK-1.6.0/include/InsightToolkit/IO/itkImageFileWriter.txx
> 	Line: 111
> 	Description: itk::ERROR: ImageFileWriter(0x601730): No input to
> writer!
> 	What is even more strange is that I'm been able to print the N
> eigenvalues.
> 	Does anyone know what's wrong here ?
> 	Thanks,
>
> 	Lucas Lorenzo
>
>
>
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