# Need to filter very small signal

I am measuring ECG signals on subjects and I am having issues filtering a very small signal from the inherent noise of the collecting device. I am using an 18 bit ADC to digitize the signal

Here is an example of the noisy signal I get:

I would like it to look like this:

I have tried different filters and the best signal yet has been from the 8-point mean averaging of the signal:

However, I am trying to find the p-wave, which is a small upward deflection just before the large QRS complex of the pulse. This p-wave is buried in the noise and I can't seem to get it out. I have tried creating a median beat of 300 heartbeats, and by doing this I can show that the p-wave does exist, but I need to show that it exists for every heartbeat.

Median beat:

Is there a more elaborate way to tease out the p-wave using the median beat, or could you point me to other strategies for improving the signal to noise ratio?

The first thing you should do is examine your signal collection hardware and do everything humanly possible to improve the signal-to-noise ratio of the analog signal applied to your A/D converter. I realize this is easier said than done, but do your very best to reduce the noise in your analog signal.

Next, you might consider the following process:

1. Based on the following figure, examine your noisy signal samples and identify the $$T_n$$ time instants of your QRS complex spikes.
2. Create multiple signal segments, $$S_n$$, where each segment comprises $$N$$ samples just prior to and including the QRS complex spike sample.
3. Average the $$S_n$$ signal segments.
4. Examine the "averaged" $$N$$-sample segment to see if your can detect an averaged p-wave.

This looks pretty bad, so this will be tricky. Here are a few suggestions

1. Make sure you fully understand where the noise is coming from and try to reduce it at the source as much as possible. It's very unliekly to be your A/D converter so it could be the sensor, bad sensor coupling, bad pre-amp, wiring issues, electro-magnetic interference, bad impedance matching, etc.
2. Make a noise-only data acquisition and analyze the noise. Are there any features in the time domain? What's the spectrum like? Is it stationary?
3. Try to get your hands on a reasonably clean signal and do the same analysis.
4. Design a filter scheme that leverages the Difference between the noise and the desired signal. If the noise has spectral content that's not in your desired signal, you can just filter that out. If the noise isn't stationary you could try a Wiener filter to optimize on the fly