0

I've worked a fair amount with EEG signals, though I've never had formal training in signal processing, so please excuse my ignorance.

The problem is this: my signal has noise at many, many frequencies (6 Hz, 12 Hz, 38 Hz, ... 94 Hz, 100 Hz, 106 Hz...). See the following figure of the frequency-domain signal; the "real" signal is way at the bottom, not really visible at this scale. (Besides 100 Hz hum, I don't know what the sources of the noise are.)

% MATLAB code
L=2560;  %length of signal 
Fs = 256;  %sampling frequency

Y = fft( signal);

% create one-sided frequency-amplitude figure
P2 = abs( Y/L); 
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);

f = Fs*(0:(L/2)) / L;

plot( f, P1) 

enter image description here

What I would like to do is truncate all these noise peaks in the frequency domain, and then convert the signal back to the time domain, in effect filtering out all of those peaks. But I don't know if this makes sense, or is mathematically possible?

What I can do right now is, after the FFT, give each spectral component a random phase (following this post), thus "simulating" a signal with the given spectral properties.

% Assume I do the peak-truncation here 
%%

% reverse from one-sided to two-sided
P1(2:end-1) = P1(2:end-1) / 2;
P2 = [P1(1:end-1) P1(end-1:-1:1)];

% add random phases
phi = unifrnd( 0, 2*pi, 1, length(P2));  %vector of random phases between 0 and 2*pi
Y_simulated = P2 .* exp( 1i * phi);  %the "simulated" FFT

signal_simulated = ifft( Y_simulated);

This produces a nice simulated signal which is similar to the original input signal, but is not time-accurate; you see that the peaks and troughs don't line up. (Note: This example is a clean signal and I did not do any truncation of noise peaks.)

enter image description here enter image description here

I feel like there should be a way to take the phase information from the imaginary part of the FFT (Y) and reapply it at the end to recover a signal that is time-accurate. But how?

(Related question: Is this how filters work? Or do they work by a different principle?)

Vance
  • 1
  • @MarcusMüller Thanks! I didn't understand everything, but I think the overall message that it's not a good idea because it introduces artifacts (due to Gibbs phenomenon I think?). – Vance Oct 17 '19 at 08:31
  • Exactly! What you'd want is some notch filter for each of these things you need to cancel; or better even: make the algorithm that works with the signal robust against these spurs that you're trying to get rid of, instead! – Marcus Müller Oct 17 '19 at 14:44

0 Answers0