[vtkusers] PcaAnalysisFilter

Jonathan Bailleul Jonathan.Bailleul at greyc.ismra.fr
Wed Jun 16 03:37:24 EDT 2004


> Julie Pelletier wrote:
> 
> 
> 
> I have 16 landmarks for 30 peoples.  I want to do a PCA analysis with
> them.  I have tried to put my data in a polydata but it's not
> working.  How can I pass those data for the PCA analysis and what kind
> of input that I will have in return?
> 
> Thank you,
> 

Once your data is put in valid polydata files (I use 3d, no clue about
2d), you can use the following function to "set" a pca filter instance
to the result of your analysis (any comment welcome, also).

After this, you can use these two methods from the pca class:
void GetParameterisedShape (vtkFloatArray *b, vtkPointSet *shape)
void GetShapeParameters (vtkPointSet *shape, vtkFloatArray *b, int ...

The first one allows you to create deformed shapes in the allowable
domain in setting the allowed shape coefficients.
The second allows you to estimate the coefficients of any estimated
shape instance. In this case (please others, infirm or confirm), it is
possible that estimations fail depending on your data, that is assumed
here to have residuals following a Gaussiam distribution.

You should manage to do some work with that, now...


void
performPCA(vtkPCAAnalysisFilter *pca, char** tset_files, int nb_files)
{
  int i;
  char* filename_in;

  // allocate one reader per file since input pca filter source
  // are read in parallel when filter is executed
  vtkPolyDataReader **readers;
  assert(readers = (vtkPolyDataReader**)calloc(nb_files,
sizeof(vtkPolyDataReader*))); 
  for (i = 0; i < nb_files; i++)
    readers[i] = vtkPolyDataReader::New();


  pca -> SetNumberOfInputs(nb_files);
  

  if (DEBUG) {cout << "Inputfiles: " << nb_files << endl;}

  // assign pca inputs with landmark file readers  
  for (i = 0; i < nb_files; i++)
    {
      filename_in = tset_files[i];
      if (DEBUG) {cout << "infile: " << filename_in << endl;}
      
      readers[i] -> SetFileName(filename_in);
      readers[i] -> Update();

      pca -> SetInput(i, readers[i] -> GetOutput());
    }
  
  // execute pca
  pca -> Update();   
}

-- 
-----------------------------------
Jonathan BAILLEUL, Doctorant
GREYC Image - Université de Caen 
http://www.greyc.ismra.fr/~bailleul




More information about the vtkusers mailing list