How to increase the resolution?

Hi @Sjoerd .

In short, your frequency resolution can be calculated by 1 / [your window size in seconds]. If you are calculating the PSD on your full epoch, then the window size is the same as your epoch length.

In that scenario, if your epochs are 1-second:
1 / 1 # equals 1 (Hz frequeny resolution)
2 seconds…
1 / 2 # equals 0.5 (Hz frequency resolution)
4 seconds …
1 / 4 # equals 0.25 (Hz frequency resolution)
…
20 seconds…
1 / 20 # equals 0.05 (Hz frequency resolution)

But with the welch method, which you are using, the n_fft parameter sets the window size (in samples)…

So in your example with a 2500Hz sfreq, n_fft=(2500 * (4 - 0.5)) , or 8,750 samples.

If we convert samples to seconds so we can use the calculation introduced above…
# convert samples to seconds.. FYI .0004 is the sampling interval (in seconds) for 2,500Hz
8,750 * .0004 # equals 3.5 (seconds window size).

and finally…
1 / 3.5 = 0.2857
This is why your frequency resolution is 0.2587.

To answer your question, your window size effectively needs to be 20 seconds to achieve a 0.05Hz frequency resolution… so given your example, you’d need to epoch your data into 20.5 seconds chunks, so that int(2500 * (20.5 - .5)) will give you a 20 second window size.

With that being said, a 0.05Hz frequency resolution seems unnecessarily precise to me. And typically, you set your window size to be long enough to encompass two full cycles of the lowest frequency of interest… So if the lowest frequency you want to calculate power for is 1Hz… Your window size would be 2-seconds.

this thread might also help you.

2 Likes