Optimized algorithm to replace R_peak_indices_channel_2 with the combined one to avoid a large copy