Skip to content

Merge Tree Wasserstein Auto-Encoder

Merge Tree Wasserstein Auto-Encoder example Image

Pipeline description

This example first loads an ensemble of scalar fields inside a cinema database from disk. Then, the MergeTree is computed on each scalar field to compute the Split Tree.

All these trees are passed to MergeTreeAutoencoder to compute a wasserstein auto-encoding in the metric space of merge trees.

Then the filter MergeTreeAutoencoderDecoding is used to reconstruct the input merge trees.

In terms of visualization, a scalar field is displayed for each cluster, with a zoom on their right of the important persistence pairs. The original merge trees are displayed alongside their reconstruction at their right. The persistence pairs of the trees are colored by ID to see what features they correspond to in the scalar field.

The 2D planar layout is displayed with the persistence correlation view at the top right. The 12 scalar fields are colored by Cluster ID. Finally, a path drawn with PolyLineSource on the layout is drawn at the bottom right to show how we can interactivily explore the MT-WAE latent space with user-defined locations.

The python script computes the MT-WAE basis. This computation is not deterministic and it may take several minutes (depending on your hardware). It saves the resulting coefficients of the input merge trees and the axes of the bases and their origins. Finally it saves the reconstructed merge trees given the bases and the coordinates of the merge trees in the basis.

ParaView

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

paraview states/mergeTreeWAEDecoding.pvsm

To reproduce the above analysis pipeline as well as the (non-deterministic) training procedure, go to your ttk-data directory and enter the following command (the computation will take several minutes, depending on your hardware):

paraview states/mergeTreeWAE.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
#!/usr/bin/env python

from paraview.simple import *

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

# create a new 'TTK CinemaProductReader'
tTKCinemaProductReader1 = TTKCinemaProductReader(Input=tTKCinemaReader1)
tTKCinemaProductReader1.AddFieldDataRecursively = 1

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

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

# create a new 'TTK MergeTreeAutoencoder'
tTKMergeTreeAutoencoder1 = TTKMergeTreeAutoencoder(
    Input=tTKBlockAggregator1, OptionalInput=None, Info=tTKCinemaReader1
)
tTKMergeTreeAutoencoder1.ScaleLayerAfterLatent = 1
tTKMergeTreeAutoencoder1.InputOriginPrimeSizePercent = 7.0
tTKMergeTreeAutoencoder1.LatentSpaceOriginPrimeSizePercent = 1.0
tTKMergeTreeAutoencoder1.MinIteration = 300
tTKMergeTreeAutoencoder1.MaxIteration = 1000
tTKMergeTreeAutoencoder1.GradientStepSize = 0.0005
tTKMergeTreeAutoencoder1.TrackingLossWeight = 1e-06
tTKMergeTreeAutoencoder1.ClusteringLossWeight = 0.02
tTKMergeTreeAutoencoder1.ClusteringArrayName = "ClusterID"
tTKMergeTreeAutoencoder1.PairTypeMixtureCoefficient = 0.0
tTKMergeTreeAutoencoder1.DeleteMultiPersistencePairs = 1
tTKMergeTreeAutoencoder1.Epsilon1 = 0.5
tTKMergeTreeAutoencoder1.Epsilon2 = 35.0
tTKMergeTreeAutoencoder1.Epsilon3 = 34.0
tTKMergeTreeAutoencoder1.PersistenceThreshold = 2.0

# create a new 'TTK MergeTreeAutoencoderDecoding'
tTKMergeTreeAutoencoderDecoding1 = TTKMergeTreeAutoencoderDecoding(
    Origins=OutputPort(tTKMergeTreeAutoencoder1, 0),
    BasesVectors=OutputPort(tTKMergeTreeAutoencoder1, 1),
    Coefficients=OutputPort(tTKMergeTreeAutoencoder1, 2),
)

# save the output
SaveData("MT-WAE_processed_diagrams.vtm", OutputPort(tTKMergeTreeAutoencoder1, 0))
SaveData("MT-WAE_origins.vtm", OutputPort(tTKMergeTreeAutoencoder1, 1))
SaveData("MT-WAE_axes.vtm", OutputPort(tTKMergeTreeAutoencoder1, 2))
SaveData("MT-WAE_coef.vtm", OutputPort(tTKMergeTreeAutoencoder1, 3))
SaveData("MT-WAE_reconstructed_diagrams.vtm", tTKMergeTreeAutoencoderDecoding1)

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

pvpython python/mergeTreeWAE.py

Inputs

Outputs

  • MT-WAE_processed_diagrams.vtm: the processed input merge trees.
  • MT-WAE_origins.vtm: the origins of each basis.
  • MT-WAE_axes.vtm: the axes of each basis.
  • MT-WAE_coef.vtm: the coefficients of the input merge trees corresponding to their coordinates in each basis.
  • MT-WAE_reconstructed_diagrams.vtm: the reconstructed input merge trees.

C++/Python API

ArrayEditor

BlockAggregator

CinemaProductReader

CinemaReader

DataSetToTable

FlattenMultiBlock

GeometrySmoother

IcospheresFromPoints

MergeTree

MergeTreeAutoencoder

MergeTreeAutoencoderDecoding

MergeTreeClustering