Skip to content

Persistence Diagram Wasserstein Auto-Encoder

Persistence Diagram Wasserstein Auto-Encoder example Image

Pipeline description

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

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

Then the filter MergeTreeAutoencoderDecoding is used to reconstruct the input diagrams.

In terms of visualization, a scalar field is displayed for each cluster. The original diagrams are displayed alongside their reconstruction at their right. The persistence pairs of the diagrams 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.

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

ParaView

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

paraview states/persistenceDiagramWAEDecoding.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 may take a minute, depending on your hardware):

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

from paraview.simple import *

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

# create a new 'TTK CinemaProductReader'
tTKCinemaProductReader7 = TTKCinemaProductReader(Input=tTKCinemaReader2_Isabel)
tTKCinemaProductReader7.AddFieldDataRecursively = 1

# create a new 'TTK PersistenceDiagram'
tTKPersistenceDiagram1 = TTKPersistenceDiagram(Input=tTKCinemaProductReader7)
tTKPersistenceDiagram1.ScalarField = ["POINTS", "velocityMag"]
tTKPersistenceDiagram1.Backend = "FTM (IEEE TPSD 2019)"

# create a new 'TTK MergeTreeAutoencoder'
tTKMergeTreeAutoencoder1 = TTKMergeTreeAutoencoder(
    Input=tTKPersistenceDiagram1, OptionalInput=None, Info=None
)
tTKMergeTreeAutoencoder1.NormalizedWasserstein = 0
tTKMergeTreeAutoencoder1.ScaleLayerAfterLatent = 1
tTKMergeTreeAutoencoder1.InputOriginPrimeSizePercent = 12.0
tTKMergeTreeAutoencoder1.LatentSpaceNumberofAxes = 1
tTKMergeTreeAutoencoder1.LatentSpaceOriginPrimeSizePercent = 5.0
tTKMergeTreeAutoencoder1.BarycenterSizeLimitPercent = 0.0
tTKMergeTreeAutoencoder1.MinIteration = 500
tTKMergeTreeAutoencoder1.GradientStepSize = 0.15
tTKMergeTreeAutoencoder1.TrackingLossWeight = 1e-06
tTKMergeTreeAutoencoder1.ClusteringArrayName = ""
tTKMergeTreeAutoencoder1.InitOriginPrimeStructByCopy = 0
tTKMergeTreeAutoencoder1.PairTypeMixtureCoefficient = 0.0
tTKMergeTreeAutoencoder1.Epsilon1 = 100.0
tTKMergeTreeAutoencoder1.PersistenceThreshold = 5.0

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

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

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

pvpython python/persistenceDiagramWAE.py

Inputs

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

Outputs

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

C++/Python API

CinemaProductReader

CinemaReader

DataSetToTable

IcospheresFromPoints

PersistenceDiagram

MergeTreeAutoencoder

MergeTreeAutoencoderDecoding