# Pass Data to vtkDescritptiveStatistics and vtkOrderedStatistics

**URL:** https://discourse.paraview.org/t/pass-data-to-vtkdescritptivestatistics-and-vtkorderedstatistics/4472
**Category:** ParaView Support
**Tags:** vtk
**Created:** [June 2, 2020, 7:58am UTC](https://discourse.paraview.org/t/pass-data-to-vtkdescritptivestatistics-and-vtkorderedstatistics/4472 "2020-06-02T07:58:48Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Resa](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@Resa](https://discourse.paraview.org/u/Resa)
#### Post date: [June 2, 2020, 7:58am UTC](https://discourse.paraview.org/t/pass-data-to-vtkdescritptivestatistics-and-vtkorderedstatistics/4472/1 "2020-06-02T07:58:48Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Resa](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@Resa](https://discourse.paraview.org/u/Resa)
#### Post date: [June 3, 2020, 11:01am UTC](https://discourse.paraview.org/t/pass-data-to-vtkdescritptivestatistics-and-vtkorderedstatistics/4472/3 "2020-06-03T11:01:51Z")

</div>

Or would I use `stat.SetInputData()` ?

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

---

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.paraview.org/user_avatar/discourse.paraview.org/dcthomp/32/20_2.png) [@dcthomp](https://discourse.paraview.org/u/dcthomp)
#### Post date: [June 3, 2020, 1:48pm UTC](https://discourse.paraview.org/t/pass-data-to-vtkdescritptivestatistics-and-vtkorderedstatistics/4472/4 "2020-06-03T13:48:22Z")

</div>

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()`.

---

<div class="post-metadata">

### Author: ![Resa](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@Resa](https://discourse.paraview.org/u/Resa)
#### Post date: [June 3, 2020, 2:50pm UTC](https://discourse.paraview.org/t/pass-data-to-vtkdescritptivestatistics-and-vtkorderedstatistics/4472/5 "2020-06-03T14:50:10Z")

</div>

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 😅

---

<div class="post-metadata">

### Author: ![Resa](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@Resa](https://discourse.paraview.org/u/Resa)
#### Post date: [June 3, 2020, 2:54pm UTC](https://discourse.paraview.org/t/pass-data-to-vtkdescritptivestatistics-and-vtkorderedstatistics/4472/6 "2020-06-03T14:54:44Z")

</div>

Ahh now it worked 😃  
Just forgot the brackets

---

<div class="post-metadata">

### Author: ![Resa](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@Resa](https://discourse.paraview.org/u/Resa)
#### Post date: [June 3, 2020, 3:37pm UTC](https://discourse.paraview.org/t/pass-data-to-vtkdescritptivestatistics-and-vtkorderedstatistics/4472/7 "2020-06-03T15:37:58Z")

</div>

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)
