revanalyzer.metrics.pd.BasicPDMetric

class revanalyzer.metrics.pd.BasicPDMetric(vectorizer, n_threads, show_time)

Bases: BasicMetric

Base class of PD-based metrics. (Don’t use it directly but derive from it).

Input:

vectorizer (SimpleBinningVectorizer, PersistenceImageVectorizer, LandscapeVectorizer or SilhouetteVectorizer object): vectorizer to be used for PD metric.

n_threads (int): number of threads used for data generation;

show_time (bool): flag to monitor time cost for large images.

Methods

generate

Generates PD metric for a specific subsample.

read

Read the metric data generated for a specific subsample.

show

Transforms generated PD data to the convenient fomat for the following visualization in subclasses.

vectorize

Vectorize the vector metric values for a given pair of subsamples using the method of vectorizer.

generate(cut, cut_name, outputdir, gendatadir=None)

Generates PD metric for a specific subsample.

Input:

cut (numpy.ndarray): 3D array representing a subsample;

cut_name (str): name of subsample;

outputdir (str): output folder;

read(inputdir, step, cut_id)

Read the metric data generated for a specific subsample.

Input:

inputdir (str): path to the folder containing image;

step (int): subsamples selection step;

cut_id (int: 0,..8): cut index.

Output:

metric value (float or np.array(dtype=’float’)).

show(inputdir, step, cut_id, title)

Transforms generated PD data to the convenient fomat for the following visualization in subclasses.

Input:

inputdir (str): path to the folder containing generated metric data for subsamples;

step (int): subsamples selection step;

cut_id (int: 0,..8): cut index;

title (str): image title.

vectorize(v1, v2)

Vectorize the vector metric values for a given pair of subsamples using the method of vectorizer.

Input:

v1 (list(dtype = float)): data for the first subsample;

v2 (list(dtype = float)): data for the second subsample.

Output:

(list(dtype = float), list(dtype = float), float) - a tuple, in which the first two elements are vectorized metric values for a given pair of subsamples, and the last one is the normalized distance between these vectors.