[vtkusers] vtkpcaanalysisfilter giving points of nans

David Doria daviddoria+vtk at gmail.com
Mon Dec 7 10:09:57 EST 2009


On Mon, Dec 7, 2009 at 10:01 AM, gregthom <gregthom99 at yahoo.com> wrote:
>
> Greetings
>
> I am working on pca analysis filter and have built everything to
> specifications.
>
> However when I write out a result from the pca analysisfilter I get all
> polydata with all nans for the points
>
> # vtk DataFile Version 3.0
> vtk output
> ASCII
> DATASET POLYDATA
> POINTS 544 float
> nan nan nan nan nan nan nan nan nan
> nan nan nan nan nan nan nan nan nan
> nan nan nan nan nan nan nan nan nan
> nan nan nan nan nan nan nan nan nan
> nan nan nan nan nan nan nan nan nan
>
>
>
>
> My Code looks like:
>
>
> meshSnew = pcaanalysisfilter(meshS1,meshS2,meshS3,meshS4,[-3 0.0 0.0 0]);
>
> where
>
> for (unsigned int j = 0;j<nrhs-1;j++)
>   {
>     MeshType::Pointer mymesh0  =  meshSstructToItkMesh(prhs[j]);
>     vtkPolyData* polydatainput = ITKMeshToVtkPolyData(mymesh0);
>     PCA->SetInput(j,polydatainput);
>   }
>
>   // update pca analysis filter
>   PCA->Update();
>
>   // debug
>   vtkIndent indent ;
>   ofstream ofile("pcaanalysislog.txt");
>   PCA -> PrintSelf(ofile,indent);
>
>
>   vtkFloatArray *params = vtkFloatArray::New();
>   params -> SetNumberOfComponents(1); // 1 per tuple
>   params -> SetNumberOfTuples(numparams); // 1 instance
>
>
>   // float val[1]; val[0] = variance_fact; params -> SetTuple(0, val);
>   for (unsigned int i = 0; i < numparams; i++)
>   {
>       params -> SetTuple1(i, paramsptr[i]);
>       double * res = params->GetTuple(i);
>       mexPrintf(">> params = %f\n", res[0] );
>   }
>
>
>
>   vtkPolyData *meshtmp       = vtkPolyData::New();
>   MeshType::Pointer mymesh0  =  meshSstructToItkMesh(prhs[0]);
>   meshtmp                    = ITKMeshToVtkPolyData(mymesh0);
>
>   PCA -> GetParameterisedShape(params, meshtmp);
>
>
>   vtkPolyDataWriter* pwriter = vtkPolyDataWriter::New();
>   pwriter->SetInput(meshtmp);
>   pwriter->SetFileName( "shapemode.vtk" );
>   pwriter->Update();
>
>
>
>
>   meshtmp->Delete();
>   pwriter->Delete();
>   PCA->Delete();

Are you aware of this?

http://www.vtk.org/doc/nightly/html/classvtkPCAAnalysisFilter.html

I haven't had a chance to make an example yet, but it might be worth a look.

I think you're going to have to provide a more compilable version of
you code if you want any help. There is a lot going on there - try to
isolate where the problem occurs.

Thanks,

David



More information about the vtkusers mailing list