# Can Kalman filter remove 50 Hz noise?

I'm dealing with a brain stimulation.

My EEG contains large spikes (>3 mV) when stimulation occurs. I want to remove the 50 Hz noise, but I can't use notch filter because it creates large artifacts.

Do you think that Kalman Filter could remove the 50 Hz noise?

If i apply a notch filter i will have ringing artifacts due to the large spikes.If so I can't use the signal anymore. So my point is : i have to remove the 50hz component without using a notch filter.( I cannot delete the spikes with interpolation) My idea is to estimate the signal rappresenting the 50 hz component with the kalman filter and then subtracting from the original signal

• Hm, what you need at least behaves like a 50 Hz notch filter, so I'd argue your problem is not generally notch filters, but the particular way your particular notch filter worked. Can you elaborate on how you built that notch filter, and what the artifacts are? Jul 23, 2019 at 10:08
• (and, yes, you can use Kalman filters to track oscillations and then subtract them from an input signal, but I don't really think it's the way to go here; you'd have to find a signal representation where the development of the phase of your interfering 50 Hz signal is a linear function of state, essentially, and that boils down to a frequency domain transform, which in turn boils down to a complicated way of building an adaptive notch filter) Jul 23, 2019 at 10:09
• @MarcusMüller hmm what's the advantage of adaptive notch compared to the fixed one, when the frequency is fixed at 50 Hz? Jul 23, 2019 at 10:57
• @Fat32 exactly my point: none! (N.B: grid frequency is not fixed over the long term; there's a couple permille variation) Jul 23, 2019 at 11:22
• my understanding is that people who make ekg monitors will use the power main as a reference for the notch
– user28715
Jul 23, 2019 at 14:17

With your edit it becomes clear that you've modeled your problem incorrectly:

While the offending signal appears shortly with a frequency of 50 Hz, that is by no means the frequency content of the interference!

(also, your filter isn't well-designed, probably too short, judging from the impulse response it displays, to filter out 50 Hz)

You'll find that interference to look more or less like dirac impulses – and these have a very high bandwidth! So, in spectral domain (plot a PSD!) you'll notice that there's not only a peak at 50 Hz, but wideband interference.

Technically, you seem to have a comb of such, and that would actually lead to a line spectrum again, which you could "kill" with a multi-notch filter.
But then again, these aren't really diracs, and you'd need a very long filter to even come close to being able to notch these out.

I think a time-domain solution is much more promising than filtering:

Simply build a threshold that detects when a burst interferer starts and ends, and zero out all samples in between.

If you want to be really elegant, you could try to use for example linear prediction to fill these gaps instead of zeroing, but my guess is that you'd only win a tiny degree of signal quality.