Merge Tree Barycenter with Path Mapping

Pipeline description
This example first loads a multi block of scalar fields from disk.
Then, the Split Tree is computed on each scalar field using the MergeTree module.
All these trees are passed to MergeTreeClustering to compute a barycenter in the metric space of merge trees defined by the path mapping distance (thus, the number of clusters has to be set to one and the underlying metric to the path mapping distance).
In addition, a distance matrix for the input trees is computed with MergeTreeDistanceMatrix.
The python script computes the barycenter and saves the resulting planar layout as well as the distance matrix in form of a table. The paraview state file additionally renders the matrix as a heatmap.
ParaView
To reproduce the above screenshots, go to your ttk-data directory and enter the following command:
paraview states/mergeTreeBarycenter_pathMapping.pvsm
Python code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 | #!/usr/bin/env python
# state file generated using paraview version 5.10.1
#### import the simple module from the paraview
from paraview.simple import *
# ----------------------------------------------------------------
# setup the data processing pipelines
# ----------------------------------------------------------------
# create a new 'XML MultiBlock Data Reader'
outliervtm = XMLMultiBlockDataReader(FileName=["bdied_outlier/outlier.vtm"])
# create a new 'TTK MergeTree'
tTKMergeandContourTreeFTM1 = TTKMergeTree(Input=outliervtm)
tTKMergeandContourTreeFTM1.ScalarField = ["POINTS", "test"]
tTKMergeandContourTreeFTM1.TreeType = "Split Tree"
tTKMergeandContourTreeFTM1.UseAllCores = 0
# create a new 'TTK BlockAggregator'
tTKBlockAggregator1 = TTKBlockAggregator(
Input=[
tTKMergeandContourTreeFTM1,
OutputPort(tTKMergeandContourTreeFTM1, 1),
OutputPort(tTKMergeandContourTreeFTM1, 2),
]
)
tTKBlockAggregator1.FlattenInput = 0
# create a new 'TTK MergeTreeDistanceMatrix'
tTKMergeTreeDistanceMatrix1 = TTKMergeTreeDistanceMatrix(
Input=tTKBlockAggregator1, OptionalInput=None
)
tTKMergeTreeDistanceMatrix1.Backend = "Path Mapping Distance (TopoInVis 2022)"
tTKMergeTreeDistanceMatrix1.DistanceSquareRoot = 0
tTKMergeTreeDistanceMatrix1.Epsilon1 = 0.0
tTKMergeTreeDistanceMatrix1.Epsilon2 = 100.0
tTKMergeTreeDistanceMatrix1.Epsilon3 = 100.0
# create a new 'TTK MergeTreeClustering'
tTKMergeTreeClustering1 = TTKMergeTreeClustering(
Input=tTKBlockAggregator1, OptionalInputclustering=None
)
tTKMergeTreeClustering1.Backend = "Path Mapping Distance (TopoInVis 2022)"
tTKMergeTreeClustering1.ComputeBarycenter = 1
tTKMergeTreeClustering1.Deterministic = 1
tTKMergeTreeClustering1.DimensionSpacing = 0.17
tTKMergeTreeClustering1.Epsilon1 = 0.0
tTKMergeTreeClustering1.Epsilon2 = 100.0
tTKMergeTreeClustering1.Epsilon3 = 100.0
tTKMergeTreeClustering1.ImportantPairs = 31.0
tTKMergeTreeClustering1.ImportantPairsSpacing = 32.0
tTKMergeTreeClustering1.NonImportantPairsSpacing = 8.0
# save the output
SaveData("merge_tree_barycenter.vtm", proxy=OutputPort(tTKMergeTreeClustering1, 1))
SaveData("distance_matrix.csv", tTKMergeTreeDistanceMatrix1)
|
To run the above Python script, go to your ttk-data directory and enter the following command:
pvpython python/mergeTreeBarycenter_pathMapping.py
- outlier.vtm: a vtk multiblock containing 10 regular grids.
Outputs
merge_tree_barycenter.vtm: the computed barycenter merge tree as a vtk multiblock.
distance_matrix.csv: the distance matrix as a csv table.
C++/Python API
BlockAggregator
MergeTree
MergeTreeClustering
MergeTreeDistanceMatrix