Skip to content

Merge Tree Feature Tracking

Merge Tree Feature Tracking example Image

Pipeline description

This example first loads two pairs of timesteps of an ensemble of scalar fields inside a cinema database from disk.

Then, the MergeTree is computed on each scalar field for the Split Tree.

These two pairs of timesteps are given respectively to two MergeTreeClustering filters to compute a distance between them.

In terms of visualisation, the matching between the trees of the first pair and the trees of the second pair are visualized using their planar layout and their embedding in the data.

The python script computes the matchings and saves the result (for each pair of trees).

ParaView

To reproduce the above screenshot, go to your ttk-data directory and enter the following command:

paraview states/mergeTreeFeatureTracking.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python

from paraview.simple import *

# create a new 'TTK CinemaReader'
tTKCinemaReader1 = TTKCinemaReader(DatabasePath="./Isabel.cdb")

# create a new 'TTK CinemaQuery'
tTKCinemaQuery1 = TTKCinemaQuery(InputTable=tTKCinemaReader1)
tTKCinemaQuery1.SQLStatement = """SELECT * FROM InputTable0
WHERE TimeStep == 2 or TimeStep == 32"""

# create a new 'TTK CinemaProductReader'
tTKCinemaProductReader1 = TTKCinemaProductReader(Input=tTKCinemaQuery1)

# create a new 'TTK Merge and Contour Tree'
tTKMergeandContourTreeFTM4 = TTKMergeTree(Input=tTKCinemaProductReader1)
tTKMergeandContourTreeFTM4.ScalarField = ["POINTS", "velocityMag"]
tTKMergeandContourTreeFTM4.TreeType = "Split Tree"

# create a new 'TTK BlockAggregator'
tTKBlockAggregator1 = TTKBlockAggregator(
    Input=[
        tTKMergeandContourTreeFTM4,
        OutputPort(tTKMergeandContourTreeFTM4, 1),
        OutputPort(tTKMergeandContourTreeFTM4, 2),
    ]
)
tTKBlockAggregator1.FlattenInput = 0

# create a new 'TTK MergeTreeClustering'
tTKMergeTreeClustering3 = TTKMergeTreeClustering(
    Input=tTKBlockAggregator1, OptionalInputclustering=None
)
tTKMergeTreeClustering3.Deterministic = 1
tTKMergeTreeClustering3.DimensionSpacing = 0.1
tTKMergeTreeClustering3.DimensionToshift = "Y"
tTKMergeTreeClustering3.Epsilon1 = 20.0
tTKMergeTreeClustering3.Epsilon2 = 100.0
tTKMergeTreeClustering3.Epsilon3 = 100.0
tTKMergeTreeClustering3.PersistenceThreshold = 2.0
tTKMergeTreeClustering3.ImportantPairs = 20.0
tTKMergeTreeClustering3.ImportantPairsSpacing = 20.0
tTKMergeTreeClustering3.NonImportantPairsProximity = 0.2

# create a new 'TTK CinemaQuery'
tTKCinemaQuery2 = TTKCinemaQuery(InputTable=tTKCinemaReader1)
tTKCinemaQuery2.SQLStatement = """SELECT * FROM InputTable0
WHERE TimeStep == 32 or TimeStep == 45"""

# create a new 'TTK CinemaProductReader'
tTKCinemaProductReader2 = TTKCinemaProductReader(Input=tTKCinemaQuery2)
tTKCinemaProductReader2.AddFieldDataRecursively = 1

# create a new 'TTK Merge and Contour Tree'
tTKMergeandContourTreeFTM5 = TTKMergeTree(Input=tTKCinemaProductReader2)
tTKMergeandContourTreeFTM5.ScalarField = ["POINTS", "velocityMag"]
tTKMergeandContourTreeFTM5.TreeType = "Split Tree"

# create a new 'TTK BlockAggregator'
tTKBlockAggregator2 = TTKBlockAggregator(
    Input=[
        tTKMergeandContourTreeFTM5,
        OutputPort(tTKMergeandContourTreeFTM5, 1),
        OutputPort(tTKMergeandContourTreeFTM5, 2),
    ]
)
tTKBlockAggregator2.FlattenInput = 0

# create a new 'TTK MergeTreeClustering'
tTKMergeTreeClustering4 = TTKMergeTreeClustering(
    Input=tTKBlockAggregator2, OptionalInputclustering=None
)
tTKMergeTreeClustering4.Deterministic = 1
tTKMergeTreeClustering4.DimensionSpacing = 0.1
tTKMergeTreeClustering4.DimensionToshift = "Y"
tTKMergeTreeClustering4.PersistenceThreshold = 2.0
tTKMergeTreeClustering4.ImportantPairs = 23.0
tTKMergeTreeClustering4.ImportantPairsSpacing = 20.0
tTKMergeTreeClustering4.NonImportantPairsProximity = 0.2

# save the output
SaveData("matching_T2_T32.vtm", OutputPort(tTKMergeTreeClustering3, 2))
SaveData("matching_T32_T45.vtm", OutputPort(tTKMergeTreeClustering4, 2))

To run the above Python script, go to your ttk-data directory and enter the following command:

pvpython python/mergeTreeFeatureTracking.py

Inputs

  • Isabel.cdb: a cinema database containing 12 regular grids.

Outputs

  • matching_T2_T32.vtm: the output matching between timestep 2 and 32.
  • matching_T32_T45.vtm: the output matching between timestep 32 and 45.

C++/Python API

BlockAggregator

CinemaProductReader

CinemaQuery

CinemaReader

MergeTree

MergeTreeClustering