Judith
(Judith)
January 19, 2021, 4:09pm
1
Hello everyone,
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’
Distance: signed_closest_point
Apply’
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,
Kind regards,
Judith
smrolfe
(Sara Rolfe)
January 19, 2021, 11:40pm
2
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.
1 Like
Hi @smrolfe :
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?
Thanks.
smrolfe
(Sara Rolfe)
July 13, 2022, 6:30pm
4
@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.
Thanks.
What’s interesting is when using this code, I receive segfault:
distanceFilter = vtk.vtkDistancePolyDataFilter()
distanceFilter.SetInputData(0, input1)
distanceFilter.SetInputData(1, input2)
distanceFilter.SignedDistanceOff()
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.
pieper
(Steve Pieper (Isomics, Inc.))
July 14, 2022, 6:37pm
6
@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 .
Hi there,
I wanted to follow up on this as I do not know how to use C++ – do I copy and paste that code into Slicer? Or use the “wrapper” ?
Thanks in advance.