[Insight-users] ImagePCAShapeModelEstimator question

Lucas Lorenzo lucas at cvrti.utah.edu
Mon, 23 Feb 2004 18:42:09 -0700


--Apple-Mail-5-495481991
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=US-ASCII;
	delsp=yes;
	format=flowed

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


--Apple-Mail-5-495481991
Content-Transfer-Encoding: 7bit
Content-Type: text/enriched;
	charset=US-ASCII

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:
<italic><fontfamily><param>Helvetica Neue</param>applyPCAShapeEstimator->GetOutput(
0 ) </fontfamily></italic>)  I want to write all N principal
components as images to files. For that I do:


		  
<italic><fontfamily><param>Helvetica Neue</param>//----------------------------------------------------------------------

		  // 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;

		        } 


		}	

</fontfamily></italic>

	When running the code the following exception is been caught when
trying to write component number N:


		<italic><fontfamily><param>Helvetica Neue</param>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!

</fontfamily></italic>

	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



--Apple-Mail-5-495481991--