<p>I found this article very helpful <a href="https://raphaelvallat.com/bandpower.html" rel="nofollow noreferrer">https://raphaelvallat.com/bandpower.html</a>, there are some good graphs for visual.</p>
<p>I am trying to learn this content myself, but my understanding is that pwelch outputs power <em>density</em> [units^2/Hz] then you can calculate an area under that power density plot (integrate) to get just power [units^2] aka absolute power.<br />
(area = PSD[units^2/Hz]*Freq[Hz] = Power[units^2]).<br />
For example, integrate from 1-4Hz to get delta power. (there is a visual of this in the link above).</p>
<p>The last line of your code (deltaPower = mean(spectra(deltaIdx));) calculates the average of the power spectral <em>densities</em> within the defined range.</p>
<p>I believe when people say &quot;band power&quot; they are referring to the absolute power (integral of the PSD) across one of the bands (delta, theta, etc). I'm not sure if the PSD alone is commonly used with EEG, but I can't say.</p>
<p>Alternatively, pwelch has an input option spectrumtype='power' and it should output straight to power instead of PSD. (haven't tried it yet). Then I imagine you just sum the powers within your desired range.</p>
<p>Alternatively alternatively, you could also just do fft()^2 to get [units^2] which is power. I'm not sure the difference between that vs integrating a PSD. Just offering up ideas. Would also like an expert input!</p>

CC BY-SA 4.0
2023-04-07T22:12:26.357Z
2023-04-07T22:16:36.250Z
2023-04-07T22:16:36.250Z
jtlechem
<p>I had to do some searching to be able to answer this question. As a matter of fact, a similar questions was once asked on <a href="https://dsp.stackexchange.com/questions/2341/difference-between-power-spectral-density-spectral-power-and-power-ratios">Signal Processing</a>. </p>

<p>To make the explanation more laymen-like, I think the answer means the following:</p>

<p>With pwelch or an FFT analysis you can calculate the amplitude of sinusoids with particular frequencies (see <a href="https://cogsci.stackexchange.com/a/17006/11318">this answer</a> ). 
These amplitudes squared, result in the absolute power within these specific frequencies. The resulting power per frequency is the <a href="https://en.wikipedia.org/wiki/Spectral_density#Power_spectral_density" rel="nofollow noreferrer">power spectral density</a> (PSD). In neuroscience, people do not often work with individual frequencies but work with frequency bands, such as the alpha band (8-14 Hz). This can be calculated by taking the average or the integral.</p>

<p>The absolute power (W), you referred to, is the power of the entire signal. It thus does not make a distinction between the different frequencies. This can be calculated, by summing the power of each frequency (i.e. taking the integral of the signal). By summing, you have the total amount of power within the signal. 
The absolute power can be used to normalize the PSD, by dividing the PSD by the absolute power (as described in the answer on Signal Processing). </p>

<p><strong>Average vs integral</strong></p>

<p>It seems that it is possible to calculate either the average or the integral of a frequency band. But when would you take the integral and when would you take the average? The average is an easy way of calculating how high the power is in a specific frequency band. This way, it does not matter how large the range of a frequency band is. The alpha band average will not be more inflated then the delta band (0-4 Hz) because of a bigger range. </p>

<p>When you take the integral there will exist differences that are affected by the size of the frequency band, because you do not divide the sum by the amount of samples (i.e frequencies). However, it does allow you to normalize the PSD with the absolute power. Say, the integral of the alpha band results in <code>2W</code>, the integral of the delta band results in <code>1W</code>, and the absolute power of the entire spectrum equals <code>10W</code>. Then we know that the alpha band plays a 20% part and the delta band a 10% part in the total signal. With mere averaging, this would not be possible because we 'neglect' the size of the range. </p>

<p>I think it depends on what exactly you are after. I haven't work with the absolute power and am not familiar with it's user. Perhaps it has something to do with comparisons between exp. conditions (within frequency-bands, i.e. alpha vs alpha) or within exp. conditions (between frequency bands). <em>If an actual expert could elaborate on why one method is beneficial over the other, that would be great.</em> </p>

CC BY-SA 3.0
2017-04-24T15:33:11.367Z
Thanks for your explanation. I'm still a little bit confused about the calculation of band power. From the answer on Signal Processing, the absolute band power is calculated by summing the power over the frequency band. Why it's calculated by taking the average in neuroscience?
Frederica
CC BY-SA 3.0
2017-04-25T12:36:42.353Z
That is a good question. I looked into it and found that there actually is not a real difference between integrating and averaging. Where integrating is simply summing all the values, with averaging you sum all the values and divide it by the amount of values. I'll try to rephrase my answer a bit.
Robin Kramer-ten Have
CC BY-SA 3.0
2017-04-24T09:32:34.453Z
2017-04-25T13:31:20.543Z
2017-04-25T13:31:20.543Z
Robin Kramer-ten Have
<p>For example, I have power spectrum density calculated by pwelch</p>

<pre><code>f = EEG.data;
f = f(2, :);
N = EEG.pnts;
Fs = EEG.srate;
NFFT = 2^nextpow2(N);
NOVERLAP = 0;
WINDOW = 512;
[spectra, freqs] = pwelch(x, WINDOW, NOVERLAP, NFFT,Fs);
deltaIdx = find(freqs&gt;1 &amp; freqs&lt;4);
deltaPower = mean(spectra(deltaIdx));
</code></pre>

<p>The code comes from EEGLab, and can be found here: <a href="https://sccn.ucsd.edu/pipermail/eeglablist/2014/008043.html" rel="nofollow noreferrer">https://sccn.ucsd.edu/pipermail/eeglablist/2014/008043.html</a></p>

<p>How should I calculate absolute power from it? What's the relationship between absolute power and power spectrum density?</p>

CC BY-SA 3.0
2017-04-20T03:33:48.897Z
@RobinKramer?  seems like a good excuse for an exposition of power spectra
honi
CC BY-SA 3.0
2017-04-20T06:45:06.447Z
It seems so indeed. @Frederica, could you provide a little more context to your question. Where does that piece of code come from, and is there a reason you chose pwelch over FFT?
Robin Kramer-ten Have
CC BY-SA 3.0
2017-04-20T18:27:09.870Z
@RobinKramer I've updated my code and resources in my question. From what I know, pwelch returns power spectra density with unit W/HZ. How does the mean of it gives absolute power with unit W?
Frederica
<methodology><eeg><analysis>
How to calculate absolute power for EEG from power spectra density?
Frederica
# How to calculate absolute power for EEG from power spectra density?

(Asked by: username_0 on 2017-04-19)

For example, I have power spectrum density calculated by pwelch
f = EEG.data;
f = f(2, :);
N = EEG.pnts;
Fs = EEG.srate;
NFFT = 2^nextpow2(N);
NOVERLAP = 0;
WINDOW = 512;
[spectra, freqs] = pwelch(x, WINDOW, NOVERLAP, NFFT,Fs);
deltaIdx = find(freqs>1 & freqs<4);
deltaPower = mean(spectra(deltaIdx));

The code comes from EEGLab, and can be found here: https://sccn.ucsd.edu/pipermail/eeglablist/2014/008043.html
How should I calculate absolute power from it? What's the relationship between absolute power and power spectrum density?

**Tags:** methodology, eeg, analysis

> **Comments:**
> **username_1**: @RobinKramer?  seems like a good excuse for an exposition of power spectra  
> **username_2**: It seems so indeed. @username_0, could you provide a little more context to your question. Where does that piece of code come from, and is there a reason you chose pwelch over FFT?  
> **username_0**: @RobinKramer I've updated my code and resources in my question. From what I know, pwelch returns power spectra density with unit W/HZ. How does the mean of it gives absolute power with unit W?  

---

## 2 answers

### Answer by username_2 on 2017-04-24. Score: 5 | Accepted answer

I had to do some searching to be able to answer this question. As a matter of fact, a similar questions was once asked on [Signal Processing](https://dsp.stackexchange.com/questions/2341/difference-between-power-spectral-density-spectral-power-and-power-ratios).

To make the explanation more laymen-like, I think the answer means the following:

With pwelch or an FFT analysis you can calculate the amplitude of sinusoids with particular frequencies (see [this answer](https://cogsci.stackexchange.com/a/17006/11318) ).
These amplitudes squared, result in the absolute power within these specific frequencies. The resulting power per frequency is the [power spectral density](https://en.wikipedia.org/wiki/Spectral_density#Power_spectral_density) (PSD). In neuroscience, people do not often work with individual frequencies but work with frequency bands, such as the alpha band (8-14 Hz). This can be calculated by taking the average or the integral.

The absolute power (W), you referred to, is the power of the entire signal. It thus does not make a distinction between the different frequencies. This can be calculated, by summing the power of each frequency (i.e. taking the integral of the signal). By summing, you have the total amount of power within the signal.
The absolute power can be used to normalize the PSD, by dividing the PSD by the absolute power (as described in the answer on Signal Processing).

**Average vs integral**

It seems that it is possible to calculate either the average or the integral of a frequency band. But when would you take the integral and when would you take the average? The average is an easy way of calculating how high the power is in a specific frequency band. This way, it does not matter how large the range of a frequency band is. The alpha band average will not be more inflated then the delta band (0-4 Hz) because of a bigger range.

When you take the integral there will exist differences that are affected by the size of the frequency band, because you do not divide the sum by the amount of samples (i.e frequencies). However, it does allow you to normalize the PSD with the absolute power. Say, the integral of the alpha band results in `2W`, the integral of the delta band results in `1W`, and the absolute power of the entire spectrum equals `10W`. Then we know that the alpha band plays a 20% part and the delta band a 10% part in the total signal. With mere averaging, this would not be possible because we 'neglect' the size of the range.

I think it depends on what exactly you are after. I haven't work with the absolute power and am not familiar with it's user. Perhaps it has something to do with comparisons between exp. conditions (within frequency-bands, i.e. alpha vs alpha) or within exp. conditions (between frequency bands). *If an actual expert could elaborate on why one method is beneficial over the other, that would be great.*

> **Comments:**
> **username_0**: Thanks for your explanation. I'm still a little bit confused about the calculation of band power. From the answer on Signal Processing, the absolute band power is calculated by summing the power over the frequency band. Why it's calculated by taking the average in neuroscience?  
> **username_2**: That is a good question. I looked into it and found that there actually is not a real difference between integrating and averaging. Where integrating is simply summing all the values, with averaging you sum all the values and divide it by the amount of values. I'll try to rephrase my answer a bit.  

---

### Answer by username_3 on 2023-04-07. Score: 1

I found this article very helpful <https://raphaelvallat.com/bandpower.html>, there are some good graphs for visual.

I am trying to learn this content myself, but my understanding is that pwelch outputs power *density* [units^2/Hz] then you can calculate an area under that power density plot (integrate) to get just power [units^2] aka absolute power.  
(area = PSD[units^2/Hz]\*Freq[Hz] = Power[units^2]).  
For example, integrate from 1-4Hz to get delta power. (there is a visual of this in the link above).

The last line of your code (deltaPower = mean(spectra(deltaIdx));) calculates the average of the power spectral *densities* within the defined range.

I believe when people say "band power" they are referring to the absolute power (integral of the PSD) across one of the bands (delta, theta, etc). I'm not sure if the PSD alone is commonly used with EEG, but I can't say.

Alternatively, pwelch has an input option spectrumtype='power' and it should output straight to power instead of PSD. (haven't tried it yet). Then I imagine you just sum the powers within your desired range.

Alternatively alternatively, you could also just do fft()^2 to get [units^2] which is power. I'm not sure the difference between that vs integrating a PSD. Just offering up ideas. Would also like an expert input!


---

