This example segments medical image data based on topological persistence.
First, the PersistenceDiagram of the data is computed (top right view, above screenshot).
Then, only the 5 most persistent maxima are selected, corresponding to the toes of the foot.
Next, the input data is simplified based on the selected persistent features, via TopologicalSimplification.
Next, the Split tree of the simplified data is computed.
Finally, the geometry of the bones of the toes is extracted by selecting the regions (in the 3D data) attached to the leaves (RegionType equals 1) of the Split tree (center view, above screenshot).
To get a refined segmentation, change the persistence threshold from 180 down to 150.
Each toe will be subdivided into two segments, precisely along the joints.
#!/usr/bin/env pythonfromparaview.simpleimport*# create a new 'XML Image Data Reader'ctBonesvti=XMLImageDataReader(FileName=["ctBones.vti"])# create a new 'Calculator'calculator1=Calculator(Input=ctBonesvti)calculator1.ResultArrayName="Scalars_"calculator1.Function="-Scalars_"# create a new 'TTK PersistenceDiagram'tTKPersistenceDiagram1=TTKPersistenceDiagram(Input=calculator1)tTKPersistenceDiagram1.ScalarField=["POINTS","Scalars_"]tTKPersistenceDiagram1.Dimensions="Selected Dimensions (no infinite pairs)"tTKPersistenceDiagram1.Saddlesaddlediagramdimension1slowest=False# create a new 'Threshold'threshold1=Threshold(Input=tTKPersistenceDiagram1)threshold1.Scalars=["CELLS","PairIdentifier"]threshold1.ThresholdMethod="Between"threshold1.LowerThreshold=0.0threshold1.UpperThreshold=999999999# create a new 'Threshold'persistenceThreshold=Threshold(Input=threshold1)persistenceThreshold.Scalars=["CELLS","Persistence"]persistenceThreshold.ThresholdMethod="Between"persistenceThreshold.LowerThreshold=180.0persistenceThreshold.UpperThreshold=999999999# create a new 'TTK TopologicalSimplification'tTKTopologicalSimplification1=TTKTopologicalSimplification(Domain=calculator1,Constraints=persistenceThreshold)tTKTopologicalSimplification1.ScalarField=["POINTS","Scalars_"]# create a new 'TTK Merge and Contour Tree ()'tTKMergeandContourTree1=TTKMergeTree(Input=tTKTopologicalSimplification1)tTKMergeandContourTree1.ScalarField=["POINTS","Scalars_"]tTKMergeandContourTree1.TreeType="Join Tree"# create a new 'Threshold'threshold3=Threshold(Input=OutputPort(tTKMergeandContourTree1,2))threshold3.Scalars=["POINTS","RegionType"]threshold3.ThresholdMethod="Between"threshold3.LowerThreshold=0.0threshold3.UpperThreshold=0.0SaveData("CTBonesOutputSegmentation.vtu",threshold3)
To run the above Python script, go to your ttk-data directory and enter the following command:
CTBonesOutputSegmentation.vtu: the geometry of the volume of the bones of the toes, as extracted by the analysis pipeline (most persistent super-level set connected components).