I have a (maybe easy) basic question to the Python Interactor in 3D Slicer/ SlicerRT. I want to know, which kind of the average Hausdorff-Distance the SlicerRT extension calculate (e.g. directed average or undirected average or undirected max average Hausdorff-distance).
Therefore I try to calculate the HD with the Python Interactor in 3D Slicer with the commands of Plastimatch (and compare with my manual calculation), but it doesn’t work. May somebody show me, how can I use the Plastimatch-commands in the Interactor (e.g. get_avg_average_hausdorff)?
Unfortunately you can’t call plastimatch functions from python. Those functions are not python wrapped. But you can see which functions are called here:
So did I understood it right, that the average HD in Slicer represent the sum of all minimum distances from the external contour-pixels/ voxels of one contour/ segment to the pixel/ voxel of the external border of the other contour divided by the number of pixels from the first contour (or sum of all pixels of both contours?)? = directed average HD
After that the same steps are repeated for the other contour and the sum of both (directed) distances divided by 2 or did Slicer take the maximum of the two directed distances? = undirected average HD
Unfortunately I can’t call these SegmentComparison module logic’s (“std::string ComputeHausdorffDistances(vtkMRMLSegmentComparisonNode* parameterNode);”) in the Python-Interactor. First I included the “slicer includes”, after that I created a segmentation from a LabelMap-volume (created in segmentations-module) as you showed in a thread before: “https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Create_a_segmentation_from_a_labelmap_volume_and_display_in_3D” (is the “parameterNode” == this segmentation?).
May you can give me an example how I can input the syntax for this, please?
Please note the signature of the function. It takes a vtkMRMLSegmentComparisonNode, which is a parameter set node containing the parameters of a segment comparison run. Now if you look at this class
then you’ll see what inputs you can set to it and what outputs you gan get after the calculation.
Thanks for the help! Sorry, that I have to ask again to this…
First, I get every time an error message, when I want to get my reference segmentation node (segmentation* GetReferenceSegmentationNode();). Do I understood it right, that my “vtkMRMLSegmentationNode” = my active Segmentation (which contains the two segments for calculation of Hausdorff/ Dice…)?
Furthermore I get the error message, that the name “SetAndObserveReferenceSegmentationNode” is not defined, when I want to set my reference segmentation node…
May you show me my mistake or are there any special packages necessary, which I have to include/ install/ import?
I just have one more question to the segmentation node. May you explain me, what the “usSegmentationNode” or “mrSegmentationNode” is in your code:
self.segmentComparisonNode.SetAndObserveReferenceSegmentationNode(self.usSegmentationNode)
I thought this are the segments in the active segmentation…
ok, I mean what is the input of this module.
So how I get a “usSegmentationNode” and a “mrSegmentationNode”?
Do I need two different segmentations or is it enough to have two segments to compare in one segmentation?
Ah ok it is this module. Is there any way to compute the Hausdorff-distances with the “Segment Comparison” - module in the python interactor as you can see here:
I want to calculate the Hausdorff-distances for volume and not for boundary which is the default one in SlicerRT (in my example segment it would be probably the same as boundary HD, but I want to use the volume HD for an other case). Therefore I tried to do this with the python-interactor…
By definition, Hausdorff distance is between boundary surfaces, so you have to provide them as inputs. Even if you think that the boundary is a trivial one, such as bone surface or skin surface, you still need to specify it (for example, by creating a segment with thresholding).
I came across your discussion since I have a relative easy question to ask: I dowloaded the Plastimatch in 3D slicer and I would like to ask how I can use it to compare segmentations using the mean surface distance ?
I was trying to find a script online but I could not find any script which I can trust totally…
I assume this means that you installed the SlicerRT extension. I suggest you use the Segment Comparison module and use the mean Hausdorff metric to achieve the same result.
As you said,yes I installed the extension in Slicer.
So regarding your answer, why the mean Hausdorff distance is the same as the mean surface distance ? The answer might be obvious but since I have not searched it yet,that is why I am asking.