Pass Data to vtkDescritptiveStatistics and vtkOrderedStatistics

Heyy

I need to compute some statistics inside of sphere clips (mean, standard deviation, quantiles). One clip contains approx. 300 points with 5 variables of Interest each point. How do i pass my data to the statistics functions?

To get the single values I could use for example:
paraview.servermanager.Fetch(clip1).GetPointData().GetArray(0).GetTuple(2)

wich gives me the value of 1st metadata of the 3rd point.
It would be better though to pass the whole object with all data directly.

The DescriptiveStatistics-function i would start like this:

stat = vtk.vtkDescriptiveStatistics
stat.SetInputArrayToProcess(...)    (???)

Is it right to use SetInputArrayToProcess()? What would be the Input?

How do i continue?

Or would I use stat.SetInputData() ?

This would require a vtkDataObject as input. How can i transform my PointData/vtkDoubleArray?

If you are going to use the VTK classes directly instead of via ParaView’s filters, then you should construct a vtkTable (say table) and pass it to the filter stat.SetInputData(table). This is easy – just add the point-data arrays from your clip filter as columns to the table. Once you have set the input table, you need to configure the stat filter to indicate (1) which columns you want statistics on and (2) which phases you want to run (most probably Learn and Derive in your case) before calling stat.Update().

1 Like

Thank you David!

I tried:

ABarray = paraview.servermanager.Fetch(clip1).GetPointData().GetArray(0)
Table = vtk.vtkTable
Table.AddColumn(ABarray)

and got the error message:
Type Error: unbound method requires a vtkmodules.vtkCommonDataModel.vtkTable as the first argument

What can I do? the Array is type vtkDoubleArray
Sorry if I ask simple questions, I’m just a beginner :sweat_smile:

Ahh now it worked :smiley:
Just forgot the brackets

Thanks David

This is my code so far:

clip1 = GetActiveSource()
ABarray = paraview.servermanager.Fetch(clip1).GetPointData().GetArray('activation bipolar (ms)')
ABarray.SetName("activation bipolar (ms)")
AUarray = paraview.servermanager.Fetch(clip1).GetPointData().GetArray('activation unipolar (ms)')
AUarray.SetName("activation unipolar (ms)")
Table = vtk.vtkTable()
Table.AddColumn(ABarray)
Table.AddColumn(AUarray)

stat = vtk.vtkDescriptiveStatistics()
stat.SetInputData(Table)
stat.AddColumn('activation bipolar (ms)')
stat.AddColumn('activation unipolar (ms)')
stat.SetLearnOption(1)
stat.SetDeriveOption(1)
stat.Update()

How do i now get the output? (e.g. mean)