<br><br><div class="gmail_quote">On Thu, Jul 16, 2009 at 5:22 AM, gregthom <span dir="ltr"><<a href="mailto:gregthom99@yahoo.com">gregthom99@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Hi Wes, thanks for pointing out the vtkPCAAnalysis filter. It looks indeed<br>
more like what I want to achieve however I have two question.<br>
!) How exactly do I use GetParameterisedShape method for my case ? say I<br>
want to generate 100 new shapes. What b should I use ?</blockquote><div><br></div><div>There may be multiple ways, but a simple way would be:</div><div><br></div><div>vtkPolyData *temp</div><div>while (need more examples)</div>
<div>{</div><div> temp = vtkPolyData::New();</div><div> temp ->DeepCopy( firstInputPolydataJusttoGetSize );</div><div> PCA->GetParametrisedShape(shapevector, temp);</div><div> // Add temp to the list of things you are maintaining .....</div>
<div>}</div><div><br></div><div>You will need to appropriately manage releasing the memory for temp.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
2) concerning my last post, does doing PCA on the n polydatas themselfs<br>
differ from doing PCA on the differences (vectors) of all n-1 polydatas with<br>
respect to one reference polydata ?<br>
</blockquote><div><br></div><div>Moderately. The PCA on the n polydatas will give you the mean polydata and a set of eignvectors describing the modes of variation from the mean shape. PCA on the difference vectors will give you the mean variation from the chosen exemplar and a set of eigenvectors describing the variation of the difference vector. Both can be used to generate additional members of the set, but my suspicion is that the first is more stable unless you have a specific reason for preferring one of the polydatas (such as it is the "correct" answer and it is the deviations from it that are important rather than an analysis of the population as a whole.)</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
Thank you<br>
<br>
G<br>
<div><div></div><div class="h5"><br>
<br>
Wes Turner wrote:<br>
><br>
> Greg,<br>
> It looks like you are trying to calculate positional variation from a set<br>
> of<br>
> polydatas and synthesize other members of the family. Look at<br>
> vtkPCAAnalysis filter.<br>
><br>
> - Wes<br>
><br>
> On Tue, Jul 14, 2009 at 10:26 AM, gregthom <<a href="mailto:gregthom99@yahoo.com">gregthom99@yahoo.com</a>> wrote:<br>
><br>
>><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[] = "M0";<br>
>> vtkDoubleArray* dataset1Arr = vtkDoubleArray::New();<br>
>> dataset1Arr->SetNumberOfComponents( 1 );<br>
>> dataset1Arr->SetName( m0Name );<br>
>><br>
>> const char m1Name[] = "M1";<br>
>> vtkDoubleArray* dataset2Arr = vtkDoubleArray::New();<br>
>> dataset2Arr->SetNumberOfComponents( 1 );<br>
>> dataset2Arr->SetName( m1Name );<br>
>><br>
>> const char m2Name[] = "M2";<br>
>> vtkDoubleArray* dataset3Arr = vtkDoubleArray::New();<br>
>> dataset3Arr->SetNumberOfComponents( 1 );<br>
>> dataset3Arr->SetName( m2Name );<br>
>><br>
>> for ( int i = 0; i < nVals; ++ i )<br>
>> {<br>
>> int ti = i << 1;<br>
>> dataset1Arr->InsertNextValue( mingledData[ti] );<br>
>> dataset2Arr->InsertNextValue( mingledData[ti + 1] );<br>
>> dataset3Arr->InsertNextValue( i != 12 ? -1. : -1.001 );<br>
>> }<br>
>><br>
>> vtkTable* datasetTable = vtkTable::New();<br>
>> datasetTable->AddColumn( dataset1Arr );<br>
>> dataset1Arr->Delete();<br>
>> datasetTable->AddColumn( dataset2Arr );<br>
>> dataset2Arr->Delete();<br>
>> datasetTable->AddColumn( dataset3Arr );<br>
>> dataset3Arr->Delete();<br>
>><br>
>> vtkPCAStatistics* pcas = vtkPCAStatistics::New();<br>
>> pcas->SetInput( vtkStatisticsAlgorithm::INPUT_DATA, datasetTable );<br>
>> pcas->SetNormalizationSchemeByName( normScheme );<br>
>> pcas->SetBasisSchemeByName( "FixedBasisEnergy" );<br>
>> pcas->SetFixedBasisEnergy( 1. - 1e-8 );<br>
>><br>
>><br>
>> In my case, I have 10 polydata sets and I want to do PCA on these<br>
>> 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->SetNumberOfComponents( 3 );<br>
>> vectorsP0toP1array->SetName( "vectorsP0toP1" );<br>
>><br>
>> (...)<br>
>><br>
>> vtkDoubleArray* vectorsP0toP9array = vtkDoubleArray::New();<br>
>> vectorsP0toP9array->SetNumberOfComponents( 3 );<br>
>> vectorsP0toP9array->SetName( "vectorsP0toP9" );<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->AddColumn( vectorsP0toP1array );<br>
>> ...<br>
>> datasetTable->AddColumn( vectorsP0toP9array );<br>
>><br>
>> then<br>
>> vtkPCAStatistics* pcas = vtkPCAStatistics::New();<br>
>> pcas->SetInput( vtkStatisticsAlgorithm::INPUT_DATA, datasetTable );<br>
>> ????<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:<br>
>> <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<br>
>> <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:<br>
>> <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>
>><br>
><br>
><br>
><br>
> --<br>
> Wesley D. Turner, Ph.D.<br>
> Kitware, Inc.<br>
> R&D Engineer<br>
> 28 Corporate Drive<br>
> Clifton Park, NY 12065-8662<br>
> Phone: 518-371-3971 x120<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<br>
> <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:<br>
> <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>
><br>
><br>
<br>
--<br>
</div></div>View this message in context: <a href="http://www.nabble.com/vtkPCAStatistics-for-vectors-tp24480622p24513104.html" target="_blank">http://www.nabble.com/vtkPCAStatistics-for-vectors-tp24480622p24513104.html</a><br>
<div><div></div><div class="h5">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>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Wesley D. Turner, Ph.D.<br>Kitware, Inc.<br>R&D Engineer<br>28 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-371-3971 x120<br>