Skip to content

infophysics/tda-toolkit

Repository files navigation

DOI

TDA

Topological Data Analysis Toolkit

Implementation of Persistent Homology algorithms, mostly by wrapping existing algorithms in python. The following algorithms are wrapped;

Implementation of an algorithm to compute the Persistent Homology Dimension associated to a barcode diagram based on the paper; "Measuring Shape with Topology" by Robert MacPherson and Benjamin Schweinhart - arXiv:1011.2258

Implementation of a Bottleneck Distance algorithm written by Miro Kramer (2013), modified/optimized by Kelvin Abrokwa (2016); https://github.com/kelvinabrokwa/bottleneck

Installing from source

Requirements: You must have CMake>=2.8.12 and a C++11 compatible compiler (GCC>=4.8) to build.

  git clone https://github.com/infophysics/TDA.git
  cd TDA
  sudo python3 setup.py install

Implementation

    grid = [[1,1,1,1,1],[1,0,0,0,1],[1,0,0,0,1],[1,0,0,0,1],[1,1,1,1,1]]
    with open("square.csv", 'w') as csvfile:
        writer = csv.writer(csvfile, delimiter=',')
        writer.writerows(grid)
    #   try 2D von neumann filter
    filt = Filter2D()
    filt.loadBinaryFromFile("square.csv")
    filt.filterBinaryVonNeumann(10)
    filt.saveBinaryFiltration("square2.csv")
    cube2D = CubicalRipser2D()
    convert_csv_to_dipha("square2.csv", "square_dipha.csv")
    cube2D.ComputeBarcode("square_dipha.csv", "test.csv", "DIPHA", "LINKFIND", 10, True)
    barcode = cube2D.getBarcode()
    plot_persistence_diagram(barcode)

    #   Now try with RIPSER directly
    rips = Ripser()
    # save as point cloud format
    save_binary_cells_to_point_cloud(grid, "square_cloud.csv")

    # Run ripser on this
    rips.ComputeBarcode("square_cloud.csv", 2, 10, 1, "point-cloud", 1)

    # Plot the barcode
    barcode2 = rips.getBarcode()
    plot_persistence_diagram(barcode2)

For more examples on possible calls, please see the Jupyter Notebook example.

Support

  • Bugs: Please report bugs to the issue tracker on Github such that we can keep track of them and eventually fix them. Please explain how to reproduce the issue (including code) and which system you are running on.
  • Help: Help can be provided also via the issue tracker by tagging your issue with 'question'
  • Contributing: Please fork this repository then make a pull request. In this pull request, explain the details of your change and include tests.

Technical implementation

This package is a pybind11 wrapper of several persistent homology algorithm implementations as well as general purpose plotting and a computation of the Persistent Homology Dimension

See AUTHORS.md for information on the developers.

Citation

When you use TDA, please say so in your slides or publications (for publications, see Zenodo link above). You can mention this in addition to how you cite TDA. This is important for us being able to get funding to support this project.

About

Topological Data Analysis Toolkit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published