Greg,<div><br></div><div>It looks like you are trying to calculate positional variation from a set of polydatas and synthesize other members of the family.  Look at vtkPCAAnalysis filter.</div><div><br></div><div>- Wes<br>
<br><div class="gmail_quote">On Tue, Jul 14, 2009 at 10:26 AM, gregthom <span dir="ltr">&lt;<a href="mailto:gregthom99@yahoo.com">gregthom99@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Hello VTK users<br>
<br>
I was wondering if vtkPCAStatistics can be used for vectors instead of<br>
scalars as in the example at:<br>
<br>
TestPCAStatistics.cxx.<br>
<br>
When looking at this example I see that scalar datas are added to a table<br>
before adding to the pca filter, ie<br>
<br>
const char m0Name[] = &quot;M0&quot;;<br>
  vtkDoubleArray* dataset1Arr = vtkDoubleArray::New();<br>
  dataset1Arr-&gt;SetNumberOfComponents( 1 );<br>
  dataset1Arr-&gt;SetName( m0Name );<br>
<br>
  const char m1Name[] = &quot;M1&quot;;<br>
  vtkDoubleArray* dataset2Arr = vtkDoubleArray::New();<br>
  dataset2Arr-&gt;SetNumberOfComponents( 1 );<br>
  dataset2Arr-&gt;SetName( m1Name );<br>
<br>
  const char m2Name[] = &quot;M2&quot;;<br>
  vtkDoubleArray* dataset3Arr = vtkDoubleArray::New();<br>
  dataset3Arr-&gt;SetNumberOfComponents( 1 );<br>
  dataset3Arr-&gt;SetName( m2Name );<br>
<br>
  for ( int i = 0; i &lt; nVals; ++ i )<br>
    {<br>
    int ti = i &lt;&lt; 1;<br>
    dataset1Arr-&gt;InsertNextValue( mingledData[ti] );<br>
    dataset2Arr-&gt;InsertNextValue( mingledData[ti + 1] );<br>
    dataset3Arr-&gt;InsertNextValue( i != 12 ? -1. : -1.001 );<br>
    }<br>
<br>
  vtkTable* datasetTable = vtkTable::New();<br>
  datasetTable-&gt;AddColumn( dataset1Arr );<br>
  dataset1Arr-&gt;Delete();<br>
  datasetTable-&gt;AddColumn( dataset2Arr );<br>
  dataset2Arr-&gt;Delete();<br>
  datasetTable-&gt;AddColumn( dataset3Arr );<br>
  dataset3Arr-&gt;Delete();<br>
<br>
  vtkPCAStatistics* pcas = vtkPCAStatistics::New();<br>
  pcas-&gt;SetInput( vtkStatisticsAlgorithm::INPUT_DATA, datasetTable );<br>
  pcas-&gt;SetNormalizationSchemeByName( normScheme );<br>
  pcas-&gt;SetBasisSchemeByName( &quot;FixedBasisEnergy&quot; );<br>
  pcas-&gt;SetFixedBasisEnergy( 1. - 1e-8 );<br>
<br>
<br>
In my case, I have 10 polydata sets and I want to do PCA on these polydata<br>
with the end result of producing other polydatas by taking linea<br>
combinations of the eigen vectors from PCA analysis.<br>
<br>
Here is my approach,<br>
<br>
<br>
1) use one polydata as reference (P0)<br>
2) get differences between the points of P0 and each of the other 9<br>
polydatas<br>
    these vectors are stored as<br>
    vtkDoubleArray* vectorsP0toP1array = vtkDoubleArray::New();<br>
    vectorsP0toP1array-&gt;SetNumberOfComponents( 3 );<br>
    vectorsP0toP1array-&gt;SetName( &quot;vectorsP0toP1&quot; );<br>
<br>
    (...)<br>
<br>
   vtkDoubleArray* vectorsP0toP9array = vtkDoubleArray::New();<br>
    vectorsP0toP9array-&gt;SetNumberOfComponents( 3 );<br>
    vectorsP0toP9array-&gt;SetName( &quot;vectorsP0toP9&quot; );<br>
<br>
3) run PCA on the vectors<br>
<br>
4) obtain a new vector by taking combinations of the PCA eigen vectors<br>
    Add new vector to P0 polydata points to obtain a new polydata model<br>
<br>
Does anyone with experience think this will work ? Could you also please<br>
help with pseudocode for 3) and 4) ? That is where I am stuck right now.<br>
Will adding the vectors columns in a table as in the example work ?<br>
<br>
ie<br>
  vtkTable* datasetTable = vtkTable::New();<br>
  datasetTable-&gt;AddColumn( vectorsP0toP1array );<br>
  ...<br>
  datasetTable-&gt;AddColumn( vectorsP0toP9array );<br>
<br>
then<br>
  vtkPCAStatistics* pcas = vtkPCAStatistics::New();<br>
  pcas-&gt;SetInput( vtkStatisticsAlgorithm::INPUT_DATA, datasetTable );  ????<br>
<br>
<br>
<br>
Thanks for your help in advance<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://www.nabble.com/vtkPCAStatistics-for-vectors-tp24480622p24480622.html" target="_blank">http://www.nabble.com/vtkPCAStatistics-for-vectors-tp24480622p24480622.html</a><br>
Sent from the VTK - Users mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Wesley D. Turner, Ph.D.<br>Kitware, Inc.<br>R&amp;D Engineer<br>28 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-371-3971 x120<br>
</div>