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)

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()

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)

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.

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

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

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

BVP_to_BPM()

Return the BPM signal as a float32 cupy.ndarray with shape [num_estimators, ]. Remember that the value returned is on GPU, use cupy.asnumpy() to transform it to a Numpy ndarray.

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)

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)

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.

Parameters
  • 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)

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.

Parameters
  • 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.

pyVHR.BPM.BPM.BVP_to_BPM_PSD_clustering_cuda(bvps, fps, minHz=0.65, maxHz=4.0, out_fact=1)

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

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.

Parameters
  • 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.

pyVHR.BPM.BPM.BVP_to_BPM_cuda(bvps, fps, minHz=0.65, maxHz=4.0)

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

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.

Parameters
  • 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.

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

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)

Show the spectrogram of the BVP signal

getBPM(winsize=5)

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

spectrogram(winsize=5)

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

pyVHR.BPM.BPM.multi_est_BPM_median(bpms)

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

Parameters

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)

This function computes Welch’method for spectral density estimation.

Parameters
  • 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.Welch_cuda(bvps, fps, minHz=0.65, maxHz=4.0, nfft=2048)

This function computes Welch’method for spectral density estimation on CUDA GPU.

Parameters
  • bvps (flaot32 cupy.ndarray) – BVP signal as float32 Numpy.ndarray with shape [num_estimators, num_frames].

  • fps (cupy.float32) – frames per seconds.

  • minHz (cupy.float32) – frequency in Hz used to isolate a specific subband [minHz, maxHz] (esclusive).

  • maxHz (cupy.float32) – frequency in Hz used to isolate a specific subband [minHz, maxHz] (esclusive).

  • nfft (cupy.int32) – number of DFT points, specified as a positive integer.

Returns

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

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

TODO:documentare

Parameters

W (tipo) – spiegare W

Returns

spiegare , questa funzione restituisce: P, kjs, Q, hahdh

Return type

cosa ritorna (tipo)

Module contents