[vtkusers] vtkPCAStatistics for vectors
Pebay, Philippe P
pppebay at sandia.gov
Tue Jul 14 13:32:29 EDT 2009
Greg,
We do not (yet) have an API that allows vectors to be passed. However, since you are in control of the creation of these vectors
(vectorsP0toP1array, ..., vectorsP0toP9array), what you may want to do is the following:
a. create 3 separate 1-component vtkDoubleArrays for each of the aforementioned vectors
b. select all of them as "columns of interest" of the PCA analysis
Philippe
--
Philippe Pébay
Sandia National Laboratories
________________________________________
From: vtkusers-bounces at vtk.org [vtkusers-bounces at vtk.org] On Behalf Of Wes Turner [wes.turner at kitware.com]
Sent: Tuesday, July 14, 2009 7:50 AM
To: gregthom
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] vtkPCAStatistics for vectors
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<mailto: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<http://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
More information about the vtkusers
mailing list