Skip to content

Persistence Diagram Principal Geodesic Analysis

Persistence Diagram Principal Geodesic Analysis example Image

Pipeline description

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

All these diagrams are passed to MergeTreePrincipalGeodesics to compute Principal Geodesic Analysis (PGA) in the metric space of persistence diagrams.

Then the filter MergeTreePrincipalGeodesicsDecoding is used to reconstruct the input diagrams, to sample evenly diagrams along the principal geodesics and to sample a discrete grid of persistence diagrams of the PGA basis.

A distance matrix is then computed with MergeTreeDistanceMatrix with the diagrams of the grid. This distance matrix is used as input of DimensionReduction to compute a MultiDimensional Scaling (MDS), performing a dimensionality reduction in 3D, thus representing the Wasserstein metric space as a curved surface (top right view, using the PointSetToSurface module). A planar representation of the ensemble is also available (bottom, using the ProjectionFromTable module from the PGA coefficients).

In terms of visualisation, a scalar field of each cluster is displayed. The original diagrams are displayed alongside their reconstruction on their right. The persistence pairs of the diagrams are colored by ID to see what features they correspond to in the scalar field.

The 3D and 2D surfaces are displayed with the persistence correlation view on the right. The 12 scalar fields are colored by Cluster ID.

The python script computes the PD-PGA and saves the resulting coefficients of the input diagrams.

ParaView

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

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

from paraview.simple import *

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

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

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

# create a new 'TTK MergeTreePrincipalGeodesics'
tTKMergeTreePrincipalGeodesics1 = TTKMergeTreePrincipalGeodesics(
    Input=tTKPersistenceDiagram1
)
tTKMergeTreePrincipalGeodesics1.NormalizedWasserstein = 0
tTKMergeTreePrincipalGeodesics1.BarycenterSizeLimitPercent = 20.0
tTKMergeTreePrincipalGeodesics1.Deterministic = 1
tTKMergeTreePrincipalGeodesics1.PairTypeMixtureCoefficient = 0.0
tTKMergeTreePrincipalGeodesics1.PersistenceThreshold = 2.0

# save the output
SaveData("PD-PGA_coef.csv", OutputPort(tTKMergeTreePrincipalGeodesics1, 1))

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

pvpython python/persistenceDiagramPGA.py

Inputs

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

Outputs

  • PD-PGA_coef.csv: the coefficients of the input diagrams corresponding to their coordinates in the PGA basis.

C++/Python API

BlockAggregator

CinemaProductReader

CinemaReader

DataSetToTable

DimensionReduction

FlattenMultiBlock

GeometrySmoother

IcospheresFromPoints

IdentifyByScalarField

MergeBockTables

MergeTreeDistanceMatrix

MergeTreePrincipalGeodesics

MergeTreePrincipalGeodesicsDecoding

PersistenceDiagram

PointSetToCurve

PointSetToSurface

ProjectionFromTable