BPM Methods
BVP
CHROM(rgb_signal, **kwargs)
The chrome_pyvhr function receives an RGB signal and returns the Blood Vessel Pulse (BVP) signal calculated from the RGB signal.
Input
rgb_signal: A list of 3 numpy arrays, representing the red (R), green (G), and blue (B) signals, respectively. The arrays must have the same number of elements.
Output
bvp: A numpy array representing the Blood Vessel Pulse (BVP) signal calculated from the RGB signal.
Algorithm
The function first separates the red, green, and blue signals, represented by r, g, and b, respectively. Then, it computes the X and Y components using the formulas:
Xcomp = 3r - 2g #3R - 2G Ycomp = (1.5r) + g - (1.5b)#1.5R + G - 1.5B
Next, the standard deviations of X and Y components, represented by sX and sY, respectively, are calculated. The alpha value is then computed as:
alpha = (sX/sY).reshape(-1,1) alpha = np.repeat(alpha, Xcomp.shape[0])
Finally, the Blood Vessel Pulse (BVP) signal is calculated as:
bvp = Xcomp - np.multiply(alpha, Ycomp)
Returns
The Blood Vessel Pulse (BVP) signal is returned as a numpy array.
De Haan, G., & Jeanne, V. (2013). Robust pulse rate from chrominance-based rPPG. IEEE Transactions on Biomedical Engineering, 60(10), 2878-2886.
Source code in redesign_pipeline/BVP/bvp_methods.py
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
GREEN(rgb_signal, **kwargs)
GREEN method. Verkruysse, W., Svaasand, L. O., & Nelson, J. S. (2008). Remote plethysmographic imaging using ambient light. Optics express, 16(26), 21434-21445.
Source code in redesign_pipeline/BVP/bvp_methods.py
244 245 246 247 248 249 | |
GREEN_Legacy(rgb_signal, **kwargs)
Input
rgb_signal: A list of length 3 where each element is an array of float values representing red, green and blue values of a video frame.
Output
Returns a 1-D numpy array of the same length as rgb_signal[1] which contains the pulse signal obtained from the video frame.
Algorithm
- Initialize an empty list out_signal.
- Loop over the length of rgb_signal[1] to extract red, green and blue values at each index i.
- Compute res = g / (r + g + b), where r, g, and b are the red, green and blue values obtained in step 2.
- Append res to out_signal list.
- Return out_signal as a numpy array.
Source code in redesign_pipeline/BVP/bvp_methods.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | |
LGI(rgb_signal, **kwargs)
Input
rgb_signal: A list of length 3 where each element is an array of 256 float values representing red, green and blue values of a video frame.
Output
Returns a 1-D numpy array of length 256 which contains the pulse signal obtained from the video frame.
Algorithm
- Convert the input list rgb_signal into a 3x256 numpy array X.
- Perform a Singular Value Decomposition (SVD) on X. The result is a matrix U which is 3x3, , .
- Extract the first column of U and reshape it into a 2D numpy array of shape (1,3).
- Compute the projection matrix P as P = identity(3) - transpose(S) * S, where S is the numpy array obtained from step 3 and identity(3) is the 3x3 identity matrix.
- Project X onto the subspace spanned by the orthonormal basis obtained in step 4, by computing Y = P * X.
- Extract the 2nd row of Y and return it as the pulse signal.
LGI method on CPU using Numpy. Pilz, C. S., Zaunseder, S., Krajewski, J., & Blazek, V. (2018). Local group invariance for heart rate estimation from face videos in the wild. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition Workshops (pp. 1254-1262).
Source code in redesign_pipeline/BVP/bvp_methods.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
OMIT(rgb_signal, **kwargs)
OMIT method. Álvarez Casado, C., Bordallo López, M. (2022). Face2PPG: An unsupervised pipeline for blood volume pulse extraction from faces. arXiv (eprint 2202.04101).
Source code in redesign_pipeline/BVP/bvp_methods.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
PBV(rgb_signal, **kwargs)
PBV method. De Haan, G., & Van Leest, A. (2014). Improved motion robustness of remote-PPG by using the blood volume pulse signature. Physiological measurement, 35(9), 1913.
Source code in redesign_pipeline/BVP/bvp_methods.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
PCA_BVP(rgb_signal, **kwargs)
PCA method. The dictionary parameters are {'component':str}. Where 'component' can be 'second_comp' or 'all_comp'. Lewandowska, M., Rumiński, J., Kocejko, T., & Nowak, J. (2011, September). Measuring pulse rate with a webcam—a non-contact method for evaluating cardiac activity. In 2011 federated conference on computer science and information systems (FedCSIS) (pp. 405-410). IEEE.
Source code in redesign_pipeline/BVP/bvp_methods.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
POS(rgb_signal, **kwargs)
The pos_pyvhr function receives an RGB signal and returns the Blood Volume Pulse (BVP) signal calculated from the RGB signal.
Input
rgb_signal: A list of 3 numpy arrays, representing the red (R), green (G), and blue (B) signals, respectively. The arrays must have the same number of elements, equal to 256.
Output
h: A numpy array representing the Blood Volume Pulse (BVP) signal calculated from the RGB signal.
Algorithm
The function starts by creating a matrix X of shape (3, 256), where the rows represent the red, green, and blue signals, respectively. The values of the red, green, and blue signals are stored in the matrix.
Next, the projection matrix proj is defined:
proj = np.array([[0,1,-1],[-2,1,1]])
The Blood Volume Pulse (BVP) signal is stored in the h array. The following loop calculates the BVP signal:
for n in range(X.shape[1]): m = n - wlen + 1 if m >= 0: cn = X[:, m:(n+1)] cn = np.dot(get_normalization_matrix(cn), cn) s = np.dot(proj, cn) hn = np.add(s[0, :], np.std(s[0,:])/np.std(s[1,:])*s[1,:]) h[m:(n+1)] = np.add(h[m:(n+1)], hn - np.mean(hn)) In this loop, the wlen variable, which has a recommended value of 32 for 20 frames per second (fps), is used to calculate the range of values for each iteration of the loop. If m is greater than or equal to 0, then the function calls get_normalization_matrix on cn and stores the result in cn. s is then computed as the dot product of proj and cn. The value of hn is then computed and added to h.
Return
The Blood Volume Pulse (BVP) signal is returned as a numpy array.
POS method. The dictionary parameters are: {'fps':float}. Wang, W., den Brinker, A. C., Stuijk, S., & de Haan, G. (2016). Algorithmic principles of remote PPG. IEEE Transactions on Biomedical Engineering, 64(7), 1479-1491.
Source code in redesign_pipeline/BVP/bvp_methods.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |