/*********************************************************** vpintv.c Algorithm(s) for ventricular rate stabilization. Author: Jie Lian ************************************************************/ #include #include #include #define MAXRATE 120 // maximum VP rate #define MINRATE 50 // minimum VP rate double GetVpIntv(double x,double y,double z,int i); double adaptive_VRS(double x, double y); double wittkampf_VRS(double x, double y); /********************************************************************* GetVpIntv: get next ventricular pace interval *********************************************************************/ double GetVpIntv(double RR,double BI,double VpIntv, int method) { double NextVpIntv; // apply appropriate ventricular rate smoothing algorithms below switch (method) { case 0: NextVpIntv = BI; break; case 1: NextVpIntv = adaptive_VRS(RR,VpIntv); break; case 2: NextVpIntv = wittkampf_VRS(RR,VpIntv); break; default: NextVpIntv = BI; break; } return NextVpIntv; } /********************************************************************* adaptive_VRS: adaptive VRS algorithm see Lian J et al., Proc IEEE-EMBS, 3881-3884, 2005. *********************************************************************/ double adaptive_VRS(double RR, double VpIntv) { double alpha,beta,delta; double PIZH,PIZL,TIH,TIL; static double NextVpIntv=0.6; char str[40]; alpha = 0.1; beta = 0.1; delta = 0.0; PIZH = 0.8; PIZL = 0.7; TIH = (60/MINRATE+PIZH)/2; TIL = (PIZL+PIZH)/2; if (RR=VpIntv) { delta = TIH-RR; NextVpIntv = RR+alpha*delta; sprintf(str,"Increase"); } else if (RR>PIZH) { delta = RR-TIL; NextVpIntv = RR-beta*delta; sprintf(str,"Decrease"); } else { NextVpIntv = VpIntv; sprintf(str,"unchanged"); } NextVpIntv = (int)(NextVpIntv*1000+0.5)/1000.0; // printf("RRI:%lf delta:%lf VpINTV:%lf %s\n",RR,delta,NextVpIntv,str); return NextVpIntv; } /********************************************************************* wittkampf_VRS: dynamic overdrive pacing VRS algorithm. see Wittkampf & Jongste, PACE, vol 9, no 6(pt.2) 1147-1153, 1986. *********************************************************************/ double wittkampf_VRS(double RR, double VpIntv) { static double NextVpIntv=0.6; char msg[40]; double dec, inc; dec = 0.01; // decrease 10 ms inc = 0.001; // increase 1 ms if (RR>=VpIntv) { // following a paced beat NextVpIntv = VpIntv+inc; sprintf(msg,"Vpace, increase VPI by 1 ms"); } else { // following a sensed beat NextVpIntv = VpIntv-dec; sprintf(msg,"Vsense, decrease VPI by 10 ms"); } NextVpIntv = (NextVpIntv>60/MINRATE)? 60/MINRATE:NextVpIntv; NextVpIntv = (NextVpIntv<60/MAXRATE)? 60/MAXRATE:NextVpIntv; NextVpIntv = (int)(NextVpIntv*1000+0.5)/1000.0; // printf("RRI:%lf, VpINTV:%lf %s\n",RR,NextVpIntv,msg); return NextVpIntv; }