How can I run the Mesh statistics?

Hi 3Dslicer users,
I am working on a University project and I need to get the statistics (the distance between all the points in a colormap file (.vtk file).
This file was done with the two models of the hemimandibles which were firstly superimposed (voxel based registration) and then I used the Model to Model distance command to create it.
It is posible to get the file with all the numbers. I mean, the distance between every correspondent point to analyze them?

Thank you in advance

You can simply save the file in vtk or vtp file format and that will contain all the computed distances for each point.

Note that you can also access all the distance values in Python and compute statistics (histogram, etc). For example, this script shows how to compute and plot histogram:

modelNode = getNode('VTK Output File')

# Get distances from model node (stored in point data array)
import vtk.util.numpy_support
distanceArrayVtk =modelNode.GetPolyData().GetPointData().GetArray('Signed')
distanceArray = vtk.util.numpy_support.vtk_to_numpy(distanceArrayVtk) 

# Compute histogram values
import numpy as np
histogram = np.histogram(distanceArray, bins=50)

# Save results to a new table node
updateTableFromArray(tableNode, histogram)

# Create plot
plotSeriesNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLPlotSeriesNode", 'Distance histogram')
plotSeriesNode.SetColor(0, 0.6, 1.0)

# Create chart and add plot
plotChartNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLPlotChartNode")
#plotChartNode.SetYAxisRange(0, 500000)

# Show plot in layout


Andras, thank so much for your help.
I will try to do this and let you know.



I am trying to use your script to see the histogram of my vtk file but I am having some problems with the getNode(‘file.vtk’) instruction. I though that this method was inside the slicer.util package but when python3 raises me the error

AttributeError: module ‘slicer.slicer’ has no attribute ‘util’

I am using a simple python script outside the slider program. Should I use the python environment inside Slicer? Please, could do you help me?

It seems that you are calling slicer.slicer.util.getNode(). It should be slicer.util.getNode().

Thanks but the problem still remain.
I am trying to plot an histogram from the vtk saved file containing distances.
So, how can I use a python script outside the slicer program to do it?