1. Both, data and reference ECG data, have timestamps associated to each sample. Sampling period is higher than IBI estimation resolution, so the time vectors used for synchronization are cumulative IBI sums.

For example, if the IBIs are 1s, 1.05s, 0.99s, the used times will be 1s, 2.05s (1+1.05), and 3.04s (1+1.05+0.99) 

In the following, IBI are the intervals estimated from PPG, and RRI the reference intervals, estimated from ECG. 

2. After having the estimated IBI

- upsample the estimated IBI and the reference RRI to the same sampling frequency

- estimate the delay between the IBI vector and the RRI vector by minimizing the error between them

- compensate for eventual frequency offset and errors caused by imperfect device clocks

- align the IBI vector to the RRI vector

- associate each ppg IBI to the corresponding RRI

- compute error statistics, etc