Ejemplo n.º 1
0
/******************************************************************************
* Syntax:
*	int QRSFilter(int datum, int init) ;
* Description:
*	QRSFilter() takes samples of an ECG signal as input and returns a sample of
*	a signal that is an estimate of the local energy in the QRS bandwidth.  In
*	other words, the signal has a lump in it whenever a QRS complex, or QRS
*	complex like artifact occurs.  The filters were originally designed for data
*  sampled at 200 samples per second, but they work nearly as well at sample
*	frequencies from 150 to 250 samples per second.
*
*	The filter buffers and static variables are reset if a value other than
*	0 is passed to QRSFilter through init.
*******************************************************************************/
int QRSFilter(int datum, int init)
{
	if (init) {
		hpfilt(0, 1);		// Initialize filters.
		lpfilt(0, 1);
		mvwint(0, 1);
		deriv1(0, 1);
		deriv2(0, 1);
	}

	datum = lpfilt(datum, 0);	// Low pass filter data.
	datum = hpfilt(datum, 0);	// High pass filter data.
	datum = deriv2(datum, 0);	// Take the derivative.
	datum = abs(datum);				// Take the absolute value.
	datum = mvwint(datum, 0);	// Average over an 80 ms window .

	return datum;
}
Ejemplo n.º 2
0
int qrsfilter( int datum, int init )
{
	int fdatum ;

	//初始化滤波器
	if(init)
	{
	    hpfilt( 0, 1 ) ;
		lpfilt( 0, 1 ) ;
		mvwint( 0, 1 ) ;
		deriv1( 0, 1 ) ;
		deriv2( 0, 1 ) ;
	}

	fdatum = lpfilt( datum, 0 );    //低通滤波
	fdatum = hpfilt( fdatum, 0 );    //高通滤波
	fdatum = deriv2( fdatum, 0 );    //差分滤波
	fdatum = abs( fdatum );    //取绝对值
	fdatum = mvwint( fdatum, 0 );    //积分窗求和

	return(fdatum);
}