Averaging Model To Model Distances & Getting Value

Does anyone know if there is a straightforward way to average the calculated model to model distance models from several samples? This way you can show the average deformation? Also, can you use model to model distance to calculate the total distance between models as a single value?

You can retrieve displacement values as a numpy array using slicer.util.arrayFromModelPointData and average it using standard numpy operations.

Would it be possible for you to elaborate on this a bit? I’m confused as to what the “numpy array” is and where it is outputted after running that command in the Python Interactor

Thank you!


Could you please let us know your experimental set up?
i.e. i have X models with Y points, I want to do Z


Yes @bpaniagua, I have two models through which I successfully performed the ModelToModelDistance module and this outputted a third model which I have been analyzing using the ShapePopulationViewer module. Though viewing the results using a colormap generated through this process is helpful, I would like to access the numbers behind the colormap to perform further quantitative processing.

Thank you,

distances = slicer.util.arrayFromModelPointData(modelNode,'someArrayName') returns a numpy array that you can process any way you want. You can get point coordinates by calling point_coords = slicer.util.arrayFromModelPoints(modelNode).

Lots of analysis tools are available in VTK, SlicerSALT, Slicer, numpy, and various Python packages. We can help more if you can be more specific about what you want to compute.

@lassoan Thank you for your response. The code still does not work in the Python Interactor – it keeps saying that modelNode is not defined. Maybe the modelNode variable is not accessible just by the Interactor. What do you think?

Also, I am aware of the other modules, but I think that all the analysis I wish to perform can be done if we can get this numpy array to output properly

Thank you!

Another question I had about the Model To Model Distances module is what units does it measure distance in for the colorbar? I’m thinking pixels or micrometers, are either of these correct?

Update: I was able to generate an array by importing my .vtk file into ParaView and exporting as .csv. However, now I am confused as to what the array means. There are 3 columns and the amount of rows correspond to the amount of points in my vtk. I’m thinking they mean x, y, z but I am not sure, could you confirm this for me?

@lassoan @bpaniagua Could you please refer to my questions above? I just need to confirm units and the meanings behind each column of data. Thank you!

Replace modelNode with the variable that refers to your model node. In the Python interactor you typically get is using modelNode = slicer.util.getNode('Put your model node name here'), while in a scripted module you usually get it from a node selector widget.

Distances are computed in the same units as you used for point coordinates. In medical image computing, physical coordinate system unit is typically millimeter.

I don’t know what data you found in ParaView. You can get point coordinates, distances, etc. as I described above.