Merge Tree Principal Geodesic Analysis¶
This example first loads an ensemble of scalar fields inside a cinema database from disk. Then, the FTMTree is computed on each scalar field to compute the Split Tree.
All these trees are passed to MergeTreePrincipalGeodesics to compute principal geodesic analysis in the metric space of merge trees.
Then the filter MergeTreePrincipalGeodesicsDecoding is used to reconstruct the input trees, to sample evenly trees along the principal geodesics and to sample a discrete grid of merge trees of the PGA basis.
A distance matrix is then computed with MergeTreeDistanceMatrix with the trees of the grid. This distance matrix is used as input of DimensionReduction to compute a MultiDimensional Scaling (MDS), performing a dimensionality reduction in 3D (and 2D with a second DimensionReduction filter) respecting the most the input distance matrix.
Finally the PointSetToSurface and ProjectionFromTable are used to create the 3D surface (and the 2D surface). The ProjectionFromTable allows to project the points (reconstructed trees, geodesic trees etc.) to the 3D (or 2D) surface.
In terms of visualisation, a scalar field of each cluster is displayed with a zoom on their right of the important persistence pairs. The original 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 3D and 2D surface are 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 surface is drawn at the bottom right to show how we can interactivily explore the MT-PGA basis in user-defined locations.
The python script computes the MT-PGA basis. It saves the resulting coefficients of the input trees and the geodesics of the basis. Finally it saves the reconstructed trees given the basis and the coordinates of the trees in the basis.
To reproduce the above screenshot, go to your ttk-data directory and enter the following command:
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
To run the above Python script, go to your ttk-data directory and enter the following command:
- Earthquake.cdb: a cinema database containing 12 regular grids.
MT-PGA_coef.csv: the coefficients of the input trees corresponding to their coordinates in the PGA basis.