Persistence 1D inc. Reconstruct1D  1.1
Finding extrema in one dimensional data, filtering them by persistence and reconstructing smooth functions
 All Classes Namespaces Files Functions Variables Macros Pages
Persistence 1D inc. Reconstruct1D Documentation

Persistence1D is a class for finding local extrema and their persistence in one-dimensional data.Local minima and local maxima are extracted, paired, and sorted according to their persistence.

The code runs in O(n log n) time, where n is the number of input points.

Persistence1D has been written by Yeara Kozlov and Tino Weinkauf, Max Planck Institute for Informatics, Saarbrücken, Germany. You may use it as you wish, it is in the public domain.

persistence1d_example_sine.png

Getting Started

The code can be used in a C++ project by just including a header file, or from within Matlab via mex.

Check out the C++ examples and Matlab examples. There is also a little command line program persistence1d_driver.cpp to quickly process text files with data.

All relevant code (apart from examples and such) is found in a single header file (persistence1d.hpp) for simple inclusion in other projects. The only dependency is the C++ standard library. Everything is encapsulated into the namespace p1d. The main class is p1d::Persistence1D.

A detailed documentation of the Matlab interface is available.

For the sake of simplicity, only float data is supported, but supporting other data types should be straight-forward.

Input

Output

If desired, the output can be filtered by a persistence threshold and adjusted to use the 1-indexing convention (e.g., for Matlab).

Usage

C++

The work flow with the class is as follows:

  1. Create a data vector and an instance of the class p1d::Persistence1D.
  2. Call p1d::Persistence1D::RunPersistence() to run the main algorithm of the class.
  3. Retrieve and filter results. The unfiltered results are saved in the class instance - retrieving results for different threshold values is cheap. Results can be retrieved using any of the following functions:

Matlab

The work flow is similar to C++, with the only difference that the user gets a copy of all possible results and filtering is done Matlab-side. Index values are, of course, returned in Matlab 1-indexing convention.

  1. Compile the Mex file.
  2. Create some data vector.
  3. Call [output arguments] = run_persistence1d(data) to run the main algorithm of the class and retrieve all possible output.
  4. Filtering is done Matlab-side, either manually by logical indexing or using the provided supporting Matlab functionalityy.

See the documentation of the Matlab interface for more details.

Some (actually not so peculiar) Peculiarities

Data values are ordered first according to their value, and then according to their indices (if the data value is the same). This has the following consequences:

Note that due to our interpretation of the data, local maxima cannot appear at the domain edges.

Reconstruct1D

threshold_animation.gif
data_weights_animation.gif

Reconstruct1D is an extension of Persistence1D, for reconstructing smooth functions based on persistent features in noisy data.

Reconstruct1D is written in Matlab and relies on Matlab's optimizers to reconstruct smooth functions which approximate the original data.

It is recommended to use MOSEK optimizers.

Check Reconstruct1D documentation for detailed documentation and examples.