Skip to content

analysis

analysis

Welch(bvps, fps, minHz=0.7, maxHz=4.0, nfft=2048)

This function computes Welch'method for spectral density estimation.

Parameters:

Name Type Description Default
bvps(flaot32 numpy.ndarray

BVP signal as float32 Numpy.ndarray with shape [num_estimators, num_frames].

required
fps float

frames per seconds.

required
minHz float

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

0.7
maxHz float

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

4.0
nfft int

number of DFT points, specified as a positive integer.

2048

Returns:

Type Description

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

Source code in redesign_pipeline/signal_processing/analysis.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
def Welch(bvps, fps, minHz=0.7, maxHz=4.0, nfft=2048):
    """
     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.
    """


    _, n = bvps.shape

    if n < 256:
        seglength = n
        overlap = int(0.8*n)  # fixed overlapping
    else:
        seglength = 256
        overlap = 200

    fs = fps 

    F, P = welch(bvps, nperseg=seglength, noverlap=overlap, fs=fs, nfft=nfft)

    F = F.astype(np.float32)
    P = P.astype(np.float32)

    band = np.argwhere((F > minHz) & (F < maxHz)).flatten()

    Pfreqs = 60*F[band]
    Power = P[:, band]

    return Pfreqs, Power