Does anyone know where to find the underlying python code of the model-to-model distance module? I want to automate these parameters:
’ Source model: prostate
Target model: tumor
Vtkoutputfile: create new model as ‘whole_dist_pt’
I have to do this for 6 models, so it would be really convenient if I can just copy the python script instead of manually clicking every time.
Many thanks in advance,
The C++ source code for the model-to-model distance module is here.
It uses the vtkDistancePolyDataFilter which also has a Python wrapper. I have a Python module that uses this filter here which may help as an example.
thanks for the script.
I am wondering why is rmse used instead of mean in the code?
#meanDistance = np.average(distanceArray)
meanDistance = self.rmse(distanceArray)
Do the indices of the meshes nodes have to correspond, when calculating distance?
@BraveDistribution The mean error should not be used here since the script is using the signed distance option of the vtkDistancePolyDataFilter. The commented line is from a previous version, I will remove to avoid confusion.
In this implementation, the distance to the second model is computed for every point on the first model, so the mesh nodes are not required to correspond.
What’s interesting is when using this code, I receive segfault:
distanceFilter = vtk.vtkDistancePolyDataFilter()
distanceFilter.Update() # Calculate distance
at distanceFilter.Update() I receive:
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
I know that’s probably out of scope of slicer, just wanted to mention it, since its closely related.
@BraveDistribution the thing to do is to create a small complete script in pure VTK and submit it along with the data that replicates the issue to the VTK issue tracker.