Filter then PSD vs PSD then filter

How is Raw.filter and then psd_welch better than psd_welch and then filtering the resulting spectra directly?

Thank you.

you can make these two things equivalent with proper adjusted parameters

I find raw.filter() and then psd_welch easier to do personally

Alex

Could you please elaborate?

you can do:

psd_welch(raw.filter())

to get your results. No need to post-process PSD estimates with some filtering attenuation
parameters

HTH
Alex

Yes, I understand that.

My question is: filter is a relatively sophisticated operation that introduced distortions around its high/low pass.

Why not take PSD from the un-filtered signal and then drop undesirable frequencies?
This appears to be a simpler and thus more reliable approach.

Thank you!

Typically, that approach is incorrect and you would like to filter first. The reason for that is if you simply apply the FFT and remove frequency bins, this leads to unwanted distortions in the temporal domain visible as sinc functions, even in the silent parts. The equivalent of a rectangular function of the frequency domain is the sinc function.

It is better to apply the filters on the time domain function first and then to inspect the frequency response (in dB) to verify the unwanted frequencies have been attenuated. It does not have to be perfect, but a 20dB reduction is usually already good enough in most cases for example…

5 Likes