if(num_peaks_total<5){//Considering 5 peaks it's 4 RR intervals
stop_std=num_peaks_total-1;
}else{
stop_std=4;
}
for(inti=0;i<stop_std;i++){
rr[i]=(type_f)(x[num_peaks-i]-x[num_peaks-i-1]);
mean+=rr[i];
#ifdef PRINT_DEBUG_CL_STD
// printf("rr[i]: %f\n",rr[i] );
#endif
}
mean=mean/stop_std;
for(inti=0;i<stop_std;i++){
std=std+(rr[i]-mean)*(rr[i]-mean);
}
if(stop_std==1)
return0;
else
returnsqrtf(std/stop_std);// because the python version divides by N and not N-1
}
RT_L1_DATAintflag_initial_centr=0;
RT_L1_DATAintlabel=0;
RT_L1_DATAintzeroctr=0;
RT_L1_DATAtype_fhcentr=0.0f;
RT_L1_DATAtype_flcentr=1.0f;
RT_L1_DATAinth_el=1;
RT_L1_DATAintl_el=1;
RT_L1_DATAtype_fmu=200.0f;
RT_L1_DATAtype_fsd=25.0f;
RT_L1_DATAtype_ilast_peak=0;
RT_L1_DATAtype_inew_peak=0;
RT_L1_DATAtype_iend_last_peak=0;
RT_L1_DATAtype_fcentroids_state[4];
RT_L1_DATAtype_fbf=0.0f;
RT_L1_DATAtype_fbt=0.0f;
RT_L1_DATAtype_iin_qrs=0;
RT_L1_DATAtype_fst[52];// 52 elements because in_qrs starts after 51 samples max and then the array will always be reset. Once a QRS has been detected, we look for 120ms of 0 output (30 samples) or 200ms to consider that the QRS has finished.
*overlap=end_main_loop+*overlap-end_last_peak-1;// - qrs_init; // Using qrs_init gives some problems if the peak is a little bit before than qrs_init. This logically shouln't happen but unfortunately it happens because the python code is not perfect (probably needing some tweeking in the variable representing the duration of the qrs)