# A Real-Time Remote Respiration Measurement Method with Improved Robustness Based on a CNN Model
## 3 Materials and Methods
### Performance Validation and Metrics  
We evaluated the accuracy of the proposed method in comparison with a reference respiratory rate. The respiratory rate must accumulate data for a specific time, after which a new bpm can be calculated for each new input frame. Therefore, in this study, based on the experimental results of Section 4.1, after accumulating data for 17 s, the bpm for all subsequent frames was calculated using the sliding window method. The following analysis methods were used to verify the respiration measurement performance. To verify the accuracy of the estimated respiratory rate, the mean absolute error (MAE) was used to determine the absolute difference between the two measurements (reference and measured bpm), as shown in Equation (4).  
\[\text{MAE}=\frac{1}{n}\sum_{i=1}^{n}\left|\text{RR}_{pred}^{i}-\text{RR}_{gt}^ {i}\right| \tag{4}\]  
Figure 9: Example of respiration dataset with motion and background noise.  
The Pearson correlation coefficient (r) between the two signals was used to determine the similarity between the estimated signal and the estimated respiratory rate to the original signal. This metric evaluates the correlation between two data points and can be used as an indicator to evaluate the similarity of the trends of the two signals. The following is implied by r: the closer r is to 1, the more positively the two data samples are correlated; the closer to \(-1\), the more negatively the two samples are correlated; and the closer to 0, the less correlated the samples are. This value can be calculated from Equation (5) for both respiratory signals, and we used the average as an indicator to determine the quality of the estimated respiratory signals.  
\[\mathrm{r}=\frac{\sum_{i=1}^{n}\left(s_{gt}^{i}-\overline{s_{gt}^{i}}\; \right)\left(s_{pred}^{i}-\overline{s_{pred}}^{\;\;\;}\right)}{\sqrt{\sum_{i=1} ^{n}\left(s_{gt}^{i}-\overline{s_{gt}}^{\;\;\;}\right)^{2}}}\sqrt{\sum_{i=1}^{ n}\left(s_{pred}^{i}-\overline{s_{pred}}^{\;\;\;}\right)^{2}} \tag{5}\]  
The intraclass correlation coefficient (ICC) was also calculated to analyze the degree of agreement between the reference bpm and bpm measured using the contactless respiration measurement method. ICC was calculated using Equations (6)-(8); the closer to 0, the lower the consistency, and vice versa.  
\[\overline{\mathrm{RR}}=\frac{1}{2n}\sum_{i=1}^{n}\left(\mathrm{RR}_{gt}^{i}+ \mathrm{RR}_{pred}^{i}\right) \tag{6}\]  
\[s^{2}=\frac{1}{2n}\left\{\sum_{i=1}^{n}\left(\mathrm{RR}_{gt}^{i}-\overline{ \mathrm{RR}}\right)^{2}+\sum_{i=1}^{n}\left(\mathrm{RR}_{pred}^{i}-\overline{ \mathrm{RR}}\right)^{2}\right\} \tag{7}\]  
\[\mathrm{ICC}=\frac{1}{n\mathrm{s}^{2}}\sum_{i=1}^{n}\left(\mathrm{RR}_{gt}^{i} -\overline{\mathrm{RR}}\right)\left(\mathrm{RR}_{pred}^{i}-\overline{ \mathrm{RR}}\right) \tag{8}\]  
In addition, we used a Bland-Altman plot to analyze whether error bias was present along with the mean of different (MOD) and limit of agreement (LOA) indicators for further performance analysis. We performed comparisons with existing methods to evaluate the relative performance of the proposed method. Two methods were used for the comparison, including an intensity variation-based method for RGB pixels [57] and an optical flow-based method [62]. The method of detecting respiratory volume from images followed the existing method, but the RoI detection method followed the method proposed in this study to prevent performance differences due to differences in RoI detection accuracy.