pyVHR.analysis package

Submodules

pyVHR.analysis.multi_method_suite module

class pyVHR.analysis.multi_method_suite.MultiMethodSuite(configFilename='default')[source]

Bases: object

This class performs tests on a video dataset using multiple rPPG methods. The suite uses these methods individually to calculate BVP and estimate BPM. After this all the BVP signals of the methods are combined into a single n-estimator signal, which is used to estimate a last BPM signal. Using multiple methods together allows you to have many estimators, so it can be useful to have a more precise BPM estimate. You can customize all the parameters using a configuration file (.cfg); in the analysis module you can find an example of cfg file named “multi_method_cfg.cfg”.

parse_cfg(configFilename)[source]

parses the given configuration file for loading the test’s parameters.

Args:

configFilename: configuation file (.cfg) name of path .

start(verb=0)[source]

Runs the tests as specified in the loaded config file.

Args:
verb:
  • 0 - not verbose

  • 1 - show the main steps

(use also combinations)

class pyVHR.analysis.multi_method_suite.TestResult(filename=None)[source]

Bases: object

This class is used by pyVHR.analysis.multi_method_suite.MultiMethodSuite to manage the results of a test for a given video dataset on multiple rPPG methods

addData(key, value)[source]
addDataSerie()[source]
newDataSerie()[source]
saveResults(outFilename=None)[source]

Save the test results in a HDF5 library that can be opened using pandas. You can analyze the results using pyVHR.analysis.stats.StatAnalysis

pyVHR.analysis.pipeline module

class pyVHR.analysis.pipeline.Pipeline[source]

Bases: object

This class runs the pyVHR pipeline on a single video or dataset

parse_cfg(configFilename)[source]

parses the given configuration file for loading the test’s parameters.

Args:

configFilename: configuation file (.cfg) name of path .

run_on_dataset(configFilename, verb=True)[source]

Runs the tests as specified in the loaded config file.

Args:
configFilename:
  • The path to the configuration file

verb:
  • False - not verbose

  • True - show the main steps

(use also combinations)

run_on_video(videoFileName, cuda=False, roi_method='convexhull', roi_approach='hol', method='cpu_POS', bpm_type='welch', pre_filt=False, post_filt=True, verb=True)[source]

Runs the pipeline on a specific video file.

Args:
videoFileName:
  • The path to the video file to analyse

cuda:
  • True - Enable computations on GPU

  • False - Use CPU only

roi_method:
  • ‘convexhull’ - Uses MediaPipe’s lanmarks to compute the convex hull of the face and segment the skin

  • ‘faceparsing’ - Uses BiseNet to parse face components and segment the skin

roi_approach:
  • ‘hol’ - Use the Holistic approach (one single ROI defined as the whole face skin region of the subject)

  • ‘patches’ - Use multiple patches as Regions of Interest

method:
  • One of the rPPG methods defined in pyVHR

bpm_type:
  • the method for computing the BPM estimate on a time window

pre_filt:
  • True - Use Band pass filtering on the windowed RGB signal

  • False - No pre-filtering

post_filt:
  • True - Use Band pass filtering on the estimated BVP signal

  • False - No post-filtering

verb:
  • False - not verbose

  • True - show the main steps

class pyVHR.analysis.pipeline.TestResult(filename=None)[source]

Bases: object

This class is used by pyVHR.analysis.newsuite.NewSuite to manage the results of a test for a given video dataset on multiple rPPG methods

addData(key, value)[source]
addDataSerie()[source]
newDataSerie()[source]
saveResults(outFilename=None)[source]

Save the test results in a HDF5 library that can be opened using pandas. You can analyze the results using pyVHR.analysis.stats.StatAnalysis

pyVHR.analysis.stats module

class pyVHR.analysis.stats.StatAnalysis(filepath, join_data=False, remove_ouliers=False)[source]

Bases: object

Statistic analyses for multiple datasets and multiple rPPG methods

FriedmanTest(methods=None, metric='MAE')[source]

Runs the Friedman Omnibus non parametric test for comparison of multiple populations

SignificancePlot(methods=None, metric='MAE')[source]

Plots the results of hypotesis testing with the significance plot

boxPlot(methods, metric, Y, scale, title)[source]

Creates the box plot

computeCD(avranks=None, numDatasets=None, alpha='0.05', display=True, approach='frequentist')[source]

Returns critical difference for Nemenyi or Bonferroni-Dunn test according to given alpha (either alpha=”0.05” or alpha=”0.1”) for average ranks and number of tested datasets N. Test can be either “nemenyi” for for Nemenyi two tailed test or “bonferroni-dunn” for Bonferroni-Dunn test. See Orange package docs.

displayBoxPlot(methods=None, metric='MAE', scale=None, title=True)[source]

Shows the distribution of populations with box-plots

getStatsData(methods=None, metric='MAE', printTable=True)[source]

Computes statistics of data

plot_bayesian_res(stat_result)[source]

Plots the results of bayesian significance testing

run_stats(methods=None, metric='CCC', approach='frequentist', print_report=True)[source]

Runs the statistical testing procedure by automatically selecting the appropriate test for the available data.

Args:
methods:
  • The rPPG methods to analyze

metric:
  • ‘MAE’ - Mean Absolute Error

  • ‘RMSE’ - Root Mean Squared Error

  • ‘PCC’ - Pearson’s Correlation Coefficient

  • ‘CCC’ - Concordance Correlation Coefficient

approach:
  • ‘frequentist’ - (default) Use frequentist hypotesis tests for the analysis

  • ‘bayesian’ - Use bayesian hypotesis tests for the analysis

print_report:
  • ‘True’ - (default) print a report of the hypotesis testing procedure

  • ‘False’ - Doesn’t print any report

saveStatsData(methods=None, metric='MAE', outfilename='statsData.csv')[source]

Saves statistics of data on disk

pyVHR.analysis.stats.compute_CD(avranks, n, alpha='0.05', test='nemenyi')[source]

Returns critical difference for Nemenyi or Bonferroni-Dunn test according to given alpha (either alpha=”0.05” or alpha=”0.1”) for average ranks and number of tested datasets N. Test has to be “nemenyi” for Nemenyi two tailed test.

pyVHR.analysis.stats.graph_ranks(avranks, names, cd=None, cdmethod=None, lowv=None, highv=None, width=6, textspace=1, reverse=False, filename=None, **kwargs)[source]

Draws a CD graph, which is used to display the differences in methods’ performance. See Janez Demsar, Statistical Comparisons of Classifiers over Multiple Data Sets, 7(Jan):1–30, 2006.

Needs matplotlib to work.

The image is ploted on plt imported using import matplotlib.pyplot as plt.

Args:

avranks (list of float): average ranks of methods. names (list of str): names of methods. cd (float): Critical difference used for statistically significance of

difference between methods.

cdmethod (int, optional): the method that is compared with other methods

If omitted, show pairwise comparison of methods

lowv (int, optional): the lowest shown rank highv (int, optional): the highest shown rank width (int, optional): default width in inches (default: 6) textspace (int, optional): space on figure sides (in inches) for the

method names (default: 1)

reverse (bool, optional): if set to True, the lowest rank is on the

right (default: False)

filename (str, optional): output file name (with extension). If not

given, the function does not write a file.

Module contents