I’m using Slicer 4.11 to compare the deviation between 2 dental models.
I used the model2model distance extension to compare the models.
The output created was VTK Output File.
I would like to get the values in mm in an array so I used the following lines in the python interactor:
distances = slicer.util.arrayFromModelPointData(modelNode,‘testArray’)
Traceback (most recent call last):
File “”, line 1, in
File “C:\Users\User\AppData\Local\NA-MIC\Slicer 4.11.20200930\bin\Python\slicer\util.py”, line 1293, in arrayFromModelPointData
narray = vtk.util.numpy_support.vtk_to_numpy(arrayVtk)
File “C:\Users\User\AppData\Local\NA-MIC\Slicer 4.11.20200930\bin\Lib\site-packages\vtkmodules\util\numpy_support.py”, line 216, in vtk_to_numpy
typ = vtk_array.GetDataType()
AttributeError: ‘NoneType’ object has no attribute ‘GetDataType’
You provided an incorrect array name. In recent Slicer versions, this error message is improved: you get the list of available arrays. You can also look up the available array names in Models module / Display / Scalars.
You get the values as a numpy array, so you can already do all the statistics that Excel can do using a few lines of Python code (using numpy, pandas, etc.). To browse values in a nicer environment than the plain Python console, you can use Jupyter notebooks or JupyterLab (using SlicerJupyter extension).
Anyway, you can save a numpy array into csv file format that Excel can load, for example using this command pandas.DataFrame(distances).to_csv(filename).
I’m also a newbie in scripting but I managed to follow @lassoan instructions above. You cannot use the “testArray” name for your array. You have to go to Models section, select you VTK Output File then navigate to Display/Scalars and choose a name from the active scalar list. For me this code worked:
The last line of code enables the export to csv file. You’ll get 3 columns of values in the sheet. However i’m not sure if every column refers to a dimension (x,y,z).
Thank you for your quick reply however I failed on MacOS specific spellings when copying the code, i.e.
the mistake was the incorrectly converted ’ when pasting the code.
and to export on mac:
pandas.DataFrame(distances).to_csv(r’~/Desktop/whatever/data.csv’, index=False)
Anyway, the question remains whether “Signed” or “PointToPointVector” is more suitable to describe distances between to meshes (e.g. two dental models).
So if I only want to describe the dimension of a vertical displacement between two models then second column (y) of the Pointtopointvector would fit best???
If I am interested in the maximum deviations (regardless of the axis) then “signed” would also fit…keeping in mind that I can have a look at the distance map to see where max. deviations were found.
Unfortunately it makes a difference which scalar you choose in terms of “mm” (signed vs. pointtopointvector)!
Other software to create distance maps where a scale bar is present seem to rely on “signed”…
I would recommend to create a new topic to get advice on which metric to use. Add a few annotated images because it is not possible to explain what exactly you would like to quantify in plain text.