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
Macros | Functions
persistence1d_driver.cpp File Reference

Use this program to run Persistence1D on data in text files. More...

#include "persistence1d.hpp"
#include <fstream>
#include <string>

Go to the source code of this file.

Macros

#define MATLAB   "-MATLAB"
 

Functions

bool ReadFileToVector (char *filename, vector< float > &data)
 Tries to open the input file and read its contents to a float vector. More...
 
void WriteMinMaxPairsToFile (char *filename, vector< TPairedExtrema > pairs)
 Writes indices of extrema features to file, sorted according to their persistence. More...
 
bool ParseCmdLine (int argc, char *argv[], float &threshold, bool &matlabIndexing)
 Parses user command line. More...
 
int main (int argc, char *argv[])
 Main function - reads a file specified as a command line argument. More...
 

Detailed Description

Use this program to run Persistence1D on data in text files.

This file contains a sample code for using Persistence1D on data in text files, and can be used to directly run Persistence1D on data in a single text file.

Command line: persistence1d_driver.exe <filename> [threshold] [-MATLAB]

Definition in file persistence1d_driver.cpp.

Macro Definition Documentation

#define MATLAB   "-MATLAB"

Definition at line 28 of file persistence1d_driver.cpp.

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Main function - reads a file specified as a command line argument.

runs persistence, writes the indices of extrema to a file called inputfilename_res.txt.

Overwrites files with the same name.

Input file name is assumed to end with a three letter extension.

Definition at line 73 of file persistence1d_driver.cpp.

bool ParseCmdLine ( int  argc,
char *  argv[],
float &  threshold,
bool &  matlabIndexing 
)

Parses user command line.

Checks if the user set a threshold value or wants MATLAB indexing.

Definition at line 161 of file persistence1d_driver.cpp.

bool ReadFileToVector ( char *  filename,
vector< float > &  data 
)

Tries to open the input file and read its contents to a float vector.

Input is assumed to be formatted as one number per line, in float compatible notation.

Ignores any lines which do not conform to this assumption.

Number of data entries is assumed to be smaller than vector's class maximum size - this is not checked!

Parameters
[in]filenameName of input file with float data.
[out]dataData is written to this vector.

Definition at line 118 of file persistence1d_driver.cpp.

void WriteMinMaxPairsToFile ( char *  filename,
vector< TPairedExtrema pairs 
)

Writes indices of extrema features to file, sorted according to their persistence.

If no features were found, writes an empty file.

Overwrites any existing file with the same name.

Parameters
[in]filenameName of output file.
[out]pairsData to write.

Definition at line 142 of file persistence1d_driver.cpp.