[vtkusers] vtkPCAStatistics for vectors

Wes Turner wes.turner at kitware.com
Tue Jul 14 10:50:01 EDT 2009


Greg,
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.

- Wes

On Tue, Jul 14, 2009 at 10:26 AM, gregthom <gregthom99 at yahoo.com> wrote:

>
> Hello VTK users
>
> I was wondering if vtkPCAStatistics can be used for vectors instead of
> scalars as in the example at:
>
> TestPCAStatistics.cxx.
>
> When looking at this example I see that scalar datas are added to a table
> before adding to the pca filter, ie
>
> const char m0Name[] = "M0";
>  vtkDoubleArray* dataset1Arr = vtkDoubleArray::New();
>  dataset1Arr->SetNumberOfComponents( 1 );
>  dataset1Arr->SetName( m0Name );
>
>  const char m1Name[] = "M1";
>  vtkDoubleArray* dataset2Arr = vtkDoubleArray::New();
>  dataset2Arr->SetNumberOfComponents( 1 );
>  dataset2Arr->SetName( m1Name );
>
>  const char m2Name[] = "M2";
>  vtkDoubleArray* dataset3Arr = vtkDoubleArray::New();
>  dataset3Arr->SetNumberOfComponents( 1 );
>  dataset3Arr->SetName( m2Name );
>
>  for ( int i = 0; i < nVals; ++ i )
>    {
>    int ti = i << 1;
>    dataset1Arr->InsertNextValue( mingledData[ti] );
>    dataset2Arr->InsertNextValue( mingledData[ti + 1] );
>    dataset3Arr->InsertNextValue( i != 12 ? -1. : -1.001 );
>    }
>
>  vtkTable* datasetTable = vtkTable::New();
>  datasetTable->AddColumn( dataset1Arr );
>  dataset1Arr->Delete();
>  datasetTable->AddColumn( dataset2Arr );
>  dataset2Arr->Delete();
>  datasetTable->AddColumn( dataset3Arr );
>  dataset3Arr->Delete();
>
>  vtkPCAStatistics* pcas = vtkPCAStatistics::New();
>  pcas->SetInput( vtkStatisticsAlgorithm::INPUT_DATA, datasetTable );
>  pcas->SetNormalizationSchemeByName( normScheme );
>  pcas->SetBasisSchemeByName( "FixedBasisEnergy" );
>  pcas->SetFixedBasisEnergy( 1. - 1e-8 );
>
>
> In my case, I have 10 polydata sets and I want to do PCA on these polydata
> with the end result of producing other polydatas by taking linea
> combinations of the eigen vectors from PCA analysis.
>
> Here is my approach,
>
>
> 1) use one polydata as reference (P0)
> 2) get differences between the points of P0 and each of the other 9
> polydatas
>    these vectors are stored as
>    vtkDoubleArray* vectorsP0toP1array = vtkDoubleArray::New();
>    vectorsP0toP1array->SetNumberOfComponents( 3 );
>    vectorsP0toP1array->SetName( "vectorsP0toP1" );
>
>    (...)
>
>   vtkDoubleArray* vectorsP0toP9array = vtkDoubleArray::New();
>    vectorsP0toP9array->SetNumberOfComponents( 3 );
>    vectorsP0toP9array->SetName( "vectorsP0toP9" );
>
> 3) run PCA on the vectors
>
> 4) obtain a new vector by taking combinations of the PCA eigen vectors
>    Add new vector to P0 polydata points to obtain a new polydata model
>
> Does anyone with experience think this will work ? Could you also please
> help with pseudocode for 3) and 4) ? That is where I am stuck right now.
> Will adding the vectors columns in a table as in the example work ?
>
> ie
>  vtkTable* datasetTable = vtkTable::New();
>  datasetTable->AddColumn( vectorsP0toP1array );
>  ...
>  datasetTable->AddColumn( vectorsP0toP9array );
>
> then
>  vtkPCAStatistics* pcas = vtkPCAStatistics::New();
>  pcas->SetInput( vtkStatisticsAlgorithm::INPUT_DATA, datasetTable );  ????
>
>
>
> Thanks for your help in advance
>
>
>
>
>
>
>
>
>
>
>
>
> --
> View this message in context:
> http://www.nabble.com/vtkPCAStatistics-for-vectors-tp24480622p24480622.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



-- 
Wesley D. Turner, Ph.D.
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x120
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090714/005b9fe0/attachment.htm>


More information about the vtkusers mailing list