I have two volumetric liver meshes in vtk unstructured grid format (ground-truth and predicted versions) and I’d like to plot the error, i.e., the difference between the ground-truth and predicted liver meshes, on the predicted mesh / mesh coordinates with a different colour (colour code based on displacement magnitudes). The N-th point in the ground-truth mesh correspond to the N-th point in the predicted mesh.
I have attempted to do this by following script however I got an error message as attached below.
You need to create a vtk.vtkDoubleArray, fill it with zeros, set its name, and add it as a point data array to the polydata. You can then modify it using slicer.util.arrayFromModelPointData as you did it above.
Meshes are volumetric and have an unstructured grid vtk format. In that case, how can I assign a poly data object to these meshes, given that they are not surface meshes?
I just created poly data object as below with a vtk.vtkDoubleArray, fill it with zeros. However, I cannot add that to the volumetric mesh. Should I extract surface mesh from the volumetric mesh first ?
I got poly data from the GetMesh() function, but when I tried slicer.util.arrayFromModelPointData by passing the mesh and the displacement field array, I got ‘only integer scalar arrays can be converted to a scalar index’.
slicer.util.arrayFromModelPointData does not accept the numpy arrays as an arguement?
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Users\mnwoki\AppData\Local\NA-MIC\Slicer 5.1.0-2022-07-08\bin\Python\slicer\util.py", line 1722, in arrayFromModelPointData
arrayVtk = _vtkArrayFromModelData(modelNode, arrayName, 'point')
File "C:\Users\mnwoki\AppData\Local\NA-MIC\Slicer 5.1.0-2022-07-08\bin\Python\slicer\util.py", line 1706, in _vtkArrayFromModelData
arrayVtk = modelData.GetArray(arrayName)
TypeError: GetArray argument 1: only integer scalar arrays can be converted to a scalar index