# Correlation Mapping of Perfusion Patterns in Cutaneous Tissue
## 2 Materials and Methods
### Data Processing
Next, the PPG data from the BIOPAC unit were downsampled so that the resulting sampling rate corresponded to the camera frame rate. During the measurement, different types of artifacts affected the recording, such as motion artifacts, and the change of ambient light in the room. These ambient influences were suppressed by appropriate methods (tracking algorithm, dark room measurement). Assuming that this noise was constant, the PPG signal acquired by the BIOPAC device did not contain significant noise, and the only parameter that varied was the amplitude of the acquired signal; we could apply the correlation mapping method to the acquired data. Using Equation (4) (_xcorr_() function in MATLAB), the cross-correlation between the PPG signal and PPGI signals stored in a 3D matrix carrying information about the spatio-temporal changes of the perfusion of the imaged area was sequentially calculated. Assuming a possible phase shift between PPGI and PPG signals, we set the offset (_scaleopt_ parameter) to half of the camera frame rate:  
\[\hat{R}_{xy}(l)=\left\{ \begin{array}{cc}\sum_{k=0}^{N-l-1}x_{k+l}y_{k}^{*},& \quad l\geq 0,\\ \hat{R}_{yx}^{*}(-l)&\quad l<0,\end{array} \right. \tag{4}\]  
where \(x\) and \(y\) are the input signals, \(\hat{R}_{xy}\) is the coefficient representing the correlation measure, the asterisk denotes complex conjugation, \(k\) is the sample number, and \(l\) is the offset. The values of the calculated correlations were normalized in the interval from zero to one using Equation (5) (Figure 3, stage 5):  
\[\hat{R}_{xy,\text{norm}}(l)=\frac{1}{\sqrt{\hat{R}_{xx}(0)\hat{R}_{yy}(0)}}\hat{R} _{xy}(l). \tag{5}\]  
The calculation result is a matrix depicting the limb locations where the signal captured by the camera is most similar to the recorded PPG signal from the little toe using the BIOPAC unit in reflective mode. The resulting correlation coefficient depended mainly on the quality of the recorded PPG signal. The quality of the signal can be influenced by the way the image data is processed. Averaging the pixel values contributes significantly to the SNR increase, so it is a good question what size of averaging mask to use. For this reason, we extracted the signals from the beginning of the recording and the part when the deep breathing test took place for the limb locations depicted in Figure 4 (right). Then, we filtered these signals, and subsequently, we detected the heart rate. As a heart rate reference value, we chose the ECG signal recorded by the BIOPAC unit. Therefore, we used the Pan-Tompkins algorithm to obtain the number of QRS complexes [34]. The algorithm involves band-pass filtering (5 Hz-16 Hz), derivation, bringing to square (removing negative values), averaging with a window length of 80 ms, and local maxima detection with thresholding. Subsequently, we compared the heart rate (HR) estimated from ECG with HR obtained from PPGI signals while the averaging masks from 3 to 31 pixels were analyzed. The first mentioned showed an error rate of approximately 6 beats per minute. A mask with a size of 19 \(\times\) 19 px\({}^{2}\) seemed the optimal option for pixel averaging kernel. In this case, the error was 2.6 beats per minute (see Figure 4, left).