for the linear filter involved bandpass filtering the ECG as a first step, in order to remove noise that is outside of the heart beat band. This is mostly a highpass filter about 5-10 Hz to remove effects from other physiological effects such as the respiratory system, and lowpass below 400 Hz to remove higher frequency electrical noise.
After this, some signals can be match filtered by specifying an example of a "good" pulse. However, this must be applied carefully, as in some ECG signals the heart QR period will change as a function of time, and pulses in other areas of the ECG will be filtered out.
All of the passes on the signal rely on the same algorithm for determining the pulse location, and thus frequency. The signal is processed to generate a threshold function, and all of the points where it the filtered ECG exceeds the threshold are marked. For all of the marked signals, the local maximum in the filtered output minus the threshold is stored. The local maximum actually takes the absolute maximum in a specified window, which corresponds to the physiological limits of mice.
The threshold for the first pass is determined by convolving the ECG with a boxcar that has the center few points set to a negative number. This creates a threshold that is usually above the level of the filtered ECG and dips down when the filtered ECG goes up. This allows spikes above the noise floor to be detected relatively easily.
In the second pass, the noise floor is canceled out by generating a vector of coefficients that are multiplied to each subsequent threshold function. These coefficients are the inverse of the means noise, defined as using the same boxcar convolution as above, except the center points are also 1. In addition, the mean amplitude of the peaks in a region allows you to curve the top of the threshold curve so it stays above the detected peaks.
Before the third and fourth pass, the filter banks are generated. Using the range of heart rates determined in the above passes, a set of comb filters running at N frequencies spaced in this range are generated. These are shaped with a maximum at 1, and where each pulse would occur there is a downward spike of definable width. In addition the spike centered on zero can either be emphasized or de-emphasized. The mean value of the comb is normalized to a settable value.
For the third pass the same method is used. Based on the previous frequencies detected in the signal, the threshold is selected out of the closest frequency bank. This is then used to detect the beats and a new heart rate calculated. This can be repeated more time to get the final heart rate.