pyVHR.BPM package

Submodules

pyVHR.BPM.BPM module

class pyVHR.BPM.BPM.BPM(data, fps, startTime=0, minHz=0.65, maxHz=4.0, verb=False)[source]

Bases: object

This class transforms a BVP signal in a BPM signal using CPU.

BVP signal must be a float32 numpy.ndarray with shape [num_estimators, num_frames].

BVP_to_BPM()[source]

Return the BPM signal as a float32 Numpy.ndarray with shape [num_estimators, ].

This method use the Welch’s method to estimate the spectral density of the BVP signal, then it chooses as BPM the maximum Amplitude frequency.

BVP_to_BPM_PSD_clustering(out_fact=1)[source]

Return the BPM signal as a numpy.float32.

TODO: cambiare descrizione. This method use the Welch’s method to estimate the spectral density of the BVP signal; in case of multiple estimators the method sum all the Power Spectums, then it chooses as BPM the maximum Amplitude frequency.

pyVHR.BPM.BPM.BVP_to_BPM(bvps, fps, minHz=0.65, maxHz=4.0)[source]

Transform a BVP windowed signal in a BPM signal using CPU.

This method use the Welch’s method to estimate the spectral density of the BVP signal, then it chooses as BPM the maximum Amplitude frequency.

Args:

bvps (list): list of length num_windows of BVP signal defined as float32 Numpy.ndarray with shape [num_estimators, num_frames]. fps (float): frames per seconds. minHz (float): frequency in Hz used to isolate a specific subband [minHz, maxHz] (esclusive). maxHz (float): frequency in Hz used to isolate a specific subband [minHz, maxHz] (esclusive).

Returns:

A list of length num_windows of BPM signals defined as a float32 Numpy.ndarray with shape [num_estimators, ]. If any BPM can’t be found in a window, then the ndarray has num_estimators == 0.

pyVHR.BPM.BPM.BVP_to_BPM_PSD_clustering(bvps, fps, minHz=0.65, maxHz=4.0, out_fact=1)[source]

Transform a BVP windowed signal in a BPM signal using CPU.

TODO: riscrivere descrizione This method use the Welch’s method to estimate the spectral density of the BVP signal; in case of multiple estimators the method sum all the Power Spectums, then it chooses as BPM the maximum Amplitude frequency.

Args:

bvps (list): list of length num_windows of BVP signal defined as float32 Numpy.ndarray with shape [num_estimators, num_frames]. fps (float): frames per seconds. minHz (float): frequency in Hz used to isolate a specific subband [minHz, maxHz] (esclusive). maxHz (float): frequency in Hz used to isolate a specific subband [minHz, maxHz] (esclusive).

Returns:

A list of length num_windows of BPM signals defined as a numpy.float32. If any BPM can’t be found in a window, then the BPM is 0.0.

class pyVHR.BPM.BPM.BVPsignal(data, fs, startTime=0, minHz=0.75, maxHz=4.0, verb=False)[source]

Bases: object

Manage (multi-channel, row-wise) BVP signals, and transforms it in BPM. This class is used to obtain BPM signal from ground truth BVP signal.

displaySpectrum(display=False, dims=3)[source]

Show the spectrogram of the BVP signal

getBPM(winsize=5)[source]

Get the BPM signal extracted from the ground truth BVP signal.

nFFT = 2048
spectrogram(winsize=5)[source]

Compute the BVP signal spectrogram restricted to the band 42-240 BPM by using winsize (in sec) samples.

step = 1
pyVHR.BPM.BPM.multi_est_BPM_median(bpms)[source]

This method is used for computing the median of a multi-estimators BPM windowed signal.

Args:
bpms (list): list of lenght num_windows of BPM signals, each defined as a Numpy.ndarray with shape [num_estimators, ],

or 1D Numpy.ndarray in case of a single estimator;

Returns:

The median of the multi-estimators BPM signal defined as a float32 Numpy.ndarray with shape [num_windows,]; if a window has num_estimators == 0, then the median value is set to 0.0 . The Median Absolute Deviation (MAD) of the multi-estimators BPM signal

pyVHR.BPM.utils module

pyVHR.BPM.utils.Welch(bvps, fps, minHz=0.65, maxHz=4.0, nfft=2048)[source]

This function computes Welch’method for spectral density estimation.

Args:

bvps(flaot32 numpy.ndarray): BVP signal as float32 Numpy.ndarray with shape [num_estimators, num_frames]. fps (float): frames per seconds. minHz (float): frequency in Hz used to isolate a specific subband [minHz, maxHz] (esclusive). maxHz (float): frequency in Hz used to isolate a specific subband [minHz, maxHz] (esclusive). nfft (int): number of DFT points, specified as a positive integer.

Returns:

Sample frequencies as float32 numpy.ndarray, and Power spectral density or power spectrum as float32 numpy.ndarray.

pyVHR.BPM.utils.circle_clustering(W, eps=0.01, theta0=None, normalize=False)[source]

TODO:documentare

Args:

W (tipo): spiegare W

Returns:

cosa ritorna (tipo): spiegare , questa funzione restituisce: P, kjs, Q, hahdh

pyVHR.BPM.utils.gaussian(x, a, mu, sigma)[source]
pyVHR.BPM.utils.gaussian_fit(model, p, x, mu, max)[source]
pyVHR.BPM.utils.optimize_partition(theta, out_fact=1)[source]

Module contents