ttk icon indicating copy to clipboard operation
ttk copied to clipboard

Principal Geodesic Analysis of Merge Trees (and Persistence Diagrams)

Open MatPont opened this issue 2 years ago • 1 comments

This PR adds the code corresponding to the following work:

Principal Geodesic Analysis of Merge Trees (and Persistence Diagrams) Mathieu Pont, Jules Vidal, Julien Tierny

It adds 2 filters to TTK : MergeTreePrincipalGeodesics and MergeTreePrincipalGeodesicsDecoding.

The first one, MergeTreePrincipalGeodesics, takes an ensemble of merge trees or persistence diagrams as input and compute an orthogonal geodesic basis that maximize the variance of the data projected onto it and hence minimize the reconstruction error. It outputs the barycenter of the ensemble (origin of the basis), the vectors defining the basis, the coefficients of the input (i.e. the coordinates of each data in this new basis) and a correlation matrix allowing to inspect the features that are the most responsible for the variability in the ensemble.

The second filter, MergeTreePrincipalGeodesicsDecoding, is used to reconstruct merge trees (or persistence diagrams) on this new basis, it can reconstruct the input and can construct other trees/diagrams like sampling uniformly the surface of the first two axes. It takes as input the outputs of the previous filter (the correlation matrix is optionnal) and output an ensemble of merge trees (or persistence diagrams).

This PR also adds some features to the Geometry module, like generalizing some functions to more than 3 dimensions and add some new functions like the projection of a vector into another.

It also adds some features to ttkFTMTreeUtils.h to convert a vtkUnstructuredGrid representing a diagram to a FTMTree_MT and adds features to the MergeTreeVisualization and ttkMergeTreeVisualization classes to output persistence diagrams (with the necessary information on points and cells like merge trees have to allow interpretability of the results).

MatPont avatar Sep 02 '22 08:09 MatPont

can you please git pull the main repo to get the MacOS CI hotfix on your PRs?

julien-tierny avatar Sep 05 '22 10:09 julien-tierny

could you please sync this PR (git pull the public ttk dev branch) to retrieve the CI fix (https://github.com/topology-tool-kit/ttk/pull/846 )?

julien-tierny avatar Oct 29 '22 06:10 julien-tierny

ping @MatPont :)

julien-tierny avatar Nov 01 '22 06:11 julien-tierny

done!

MatPont avatar Nov 02 '22 10:11 MatPont

alright \0/ it looks like we're good to go. thanks again for this awesome work!!!

julien-tierny avatar Nov 08 '22 08:11 julien-tierny

thanks for opening your PR on ttk-data with examples!!!!

julien-tierny avatar Nov 08 '22 08:11 julien-tierny

This PR is triggering many warnings with gcc 11. For instance:

/home/julien/Pro/git/github/tierny/private/ttk-tierny/core/base/mergeTreePrincipalGeodesics/MergeTreePrincipalGeodesicsBase.h:754:65: warning: comparison of unsigned expression in '>= 0' is always true [-Wtype-limits]
  754 |            and match1 < tree.tree.getNumberOfNodes() and match1 >= 0)

@MatPont could you fix those?

@pierre-guillou aren't these supposed to be caught by the CI?

julien-tierny avatar Nov 10 '22 06:11 julien-tierny

These warnings are specific to GCC and appear only on Ubuntu 22.04 and newer. The CI prevents warnings that are found with Clang + libstdc++. Actually, other warnings are also found in the macOS and Windows builds (I plan to fix them soon).

It is quite hard currently to enforce no warnings in the build tasks since the GCC of Ubuntu 18.04 mixes variables and functions in -Wshadow. Once Ubuntu 18.04 jobs are removed, we can build TTK with -Werror enabled (at least on Ubuntu).

pierre-guillou avatar Nov 10 '22 07:11 pierre-guillou

These warnings are specific to GCC and appear only on Ubuntu 22.04 and newer. The CI prevents warnings that are found with Clang + libstdc++. Actually, other warnings are also found in the macOS and Windows builds (I plan to fix them soon).

It is quite hard currently to enforce no warnings in the build tasks since the GCC of Ubuntu 18.04 mixes variables and functions in -Wshadow. Once Ubuntu 18.04 jobs are removed, we can build TTK with -Werror enabled (at least on Ubuntu).

I see, thanks for the clarification!

julien-tierny avatar Nov 10 '22 08:11 julien-tierny