# [Eeglablist] How can I get the power of each frequency band?

Makoto Miyakoshi mmiyakoshi at ucsd.edu
Thu May 7 11:40:38 PDT 2015

```Dear Shan,

Correct me if I'm wrong--I guess you are concerned with the number of
sampling points in frequency. For example, if there are 4, 5, 6, 7 Hz in
theta, and 8, 9, 10, 11, 12, 13 Hz in alpha, the former has 4 points while
the latter has 6 points, therefore they should be normalized by the number
of the frequency sampling points (i.e. to use the mean value within each
frequency range 'bin'). If that's the case, yes I agree with you.

Makoto

On Tue, May 5, 2015 at 11:23 PM, #SHAN XIN# <SHAN0055 at e.ntu.edu.sg> wrote:

>  Dear Makoto,
>
>
>  Thank you for your explanation!!
>
>
>  For the "length of each discrete frequency", I mean the length of
> each frequency bin.  Let's say the density is "5uV^2/Hz" for one
> particular alphaIdx (one frequency bin), and assume the length of this
> frequency bin is ​0.5 Hz.  If we can directly sum all values, then actually
> you mean 5uV^2 is already the power in this frequency bin.  Or the power is
> actually 2.5uV^2, such that the density is 2.5uV^2/0.5Hz=5uV^2/Hz ? If it
> is the second case, then before summation we should first multiply the
> density by the length, right?  I don't know which one is correct...
>
>
>  Best wishes,
>
> SHAN Xin
>
>
>  ------------------------------
> *From:* Makoto Miyakoshi <mmiyakoshi at ucsd.edu>
> *Sent:* Tuesday, 5 May 2015 11:04 PM
>
> *To:* #SHAN XIN#
> *Cc:* eeglablist at sccn.ucsd.edu
> *Subject:* Re: [Eeglablist] How can I get the power of each frequency
> band?
>
>  Dear Shan,
>
>  > (1) Since dB is the log ratio of two same quantities, so in the
> spectopo plot 10log10(uV^2/Hz) , does EEGlab implicitly assume that the
> reference level is 1uV^2 ?
>
>  I once tested it myself.
> I generated a long sine wave with amplitude of 1 and 10 Hz and ran
> spectopo. The peak at 10 Hz was at 0. When I change the amplitude to 10,
> the peak level was at 20 (if I remember correctly).
>
>  > (2) The script line "deltaPower = mean(10.^(spectra(deltaIdx)/10)); "
> gives uV^2/Hz, which is the mean value of densities.  If I hope to get
> the total power within alpha band, what script should I write?  Intuitively
> it seems something like: total power=sum(10.^(spectra(alphaIdx)/10)*(length
> of each discrete frequency)).  Is this concept correct? If it is correct,
> then what should be the value for "length of each discrete
> frequency" (say for 128Hz sampling rate)? If not, then is there actually
> any method to get the total power?
>
>  I have never wished to have the total power so I'm not completely sure,
> but
>
>  > total power=sum(10.^(spectra(alphaIdx)/10)*(length of each discrete
> frequency))
>
>  What is the 'length of each discrete frequency' here? What 'length' is
> it referring to? Isn't it simply sum(10.^(spectra(alphaIdx)/10)?
>
>  Makoto
>
>
> On Thu, Apr 23, 2015 at 9:17 AM, #SHAN XIN# <SHAN0055 at e.ntu.edu.sg> wrote:
>
>>   Dear Makoto,
>>
>>
>>  Thank you so much for the link!!  I still have two questions:
>>
>>
>>  (1) Since dB is the log ratio of two same quantities, so in the
>> spectopo plot 10log10(uV^2/Hz) , does EEGlab implicitly assume that the
>> reference level is 1uV^2 ?
>>
>>
>>  (2) The script line "deltaPower = mean(10.^(spectra(deltaIdx)/10)); "
>> gives uV^2/Hz, which is the mean value of densities.  If I hope to get
>> the total power within alpha band, what script should I write?  Intuitively
>> it seems something like: total power=sum(10.^(spectra(alphaIdx)/10)*(length
>> of each discrete frequency)).  Is this concept correct? If it is
>> correct, then what should be the value for "length of each discrete
>> frequency" (say for 128Hz sampling rate)? If not, then is there actually
>> any method to get the total power?
>>
>>
>>  Best wishes,
>>
>> SHAN Xin
>>
>>
>>  ------------------------------
>> *From:* Makoto Miyakoshi <mmiyakoshi at ucsd.edu>
>> *Sent:* Wednesday, 22 April 2015 2:07 AM
>>
>> *To:* #SHAN XIN#
>> *Cc:* eeglablist at sccn.ucsd.edu
>> *Subject:* Re: [Eeglablist] How can I get the power of each frequency
>> band?
>>
>>   Dear Shan,
>>
>>  > Why divided by  Hz?
>>
>>  Here is (esoteric) discussion about the related topic.
>> http://sccn.ucsd.edu/pipermail/eeglablist/2014/008224.html
>>
>>  Makoto
>>
>> On Mon, Apr 20, 2015 at 3:58 AM, #SHAN XIN# <SHAN0055 at e.ntu.edu.sg>
>> wrote:
>>
>>>  Hi Makoto,
>>>
>>>  Oh I didn't realize the scale on the figure might already in dB...is
>>> it?  I know dB is defined as log ratio, but uV^2/Hz does not seem to be a
>>> ratio since the units (volt square and hz) do not match...  Also, do you
>>> therefore mean that the definition of absolute power is uV^2/Hz?
>>>
>>>  I've gone through the related topics in archives and still don't
>>> understand these... I also search on Google but still cannot find a clear
>>> explanation. Why divided by  Hz?
>>>
>>>  Thank you so much!!
>>>
>>>  Shan Xin
>>>
>>> #SHAN XIN# <SHAN0055 at e.ntu.edu.sg> 於 Apr 20, 2015 17:29 寫道：
>>>
>>>   Dear Makoto,
>>>
>>>
>>>  I have a doubt for the power unit. I read the "help spectopo" in
>>> Matlab, for the variable "spectra":
>>>
>>>
>>>  Outputs:
>>>          spectra  = (nchans,nfreqs) power spectra (mean power over
>>> epochs), in dB
>>>          freqs    = frequencies of spectra (Hz)
>>>
>>>  If the unit of variable "spectra" is in dB unit already, then when
>>> computing the absolute power, do we still need to do the transformation as
>>> you suggested (i.e. 10.^(spectra(deltaIdx)/10))?
>>>
>>>  I know when plotting the figure, the spectrum is plotted in log scale.
>>> But if the unit of spectra is in dB, then there's no need to transform,
>>> right?
>>>
>>>  I don't know if this is correct... Could you look more into it? Thank
>>> you so much!!
>>>
>>>  Shan Xin
>>>
>>>
>>>  ------------------------------
>>> *From:* Makoto Miyakoshi <mmiyakoshi at ucsd.edu>
>>> *Sent:* Thursday, 16 April 2015 11:11 AM
>>> *To:* #SHAN XIN#
>>> *Cc:* eeglablist at sccn.ucsd.edu
>>> *Subject:* Re: [Eeglablist] How can I get the power of each frequency
>>> band?
>>>
>>>   Dear Shan,
>>>
>>>  > I'm not very proficient in Matlab programming...
>>>
>>>  This could be a concern but you can try!
>>>
>>>  %%%%%%%%%%%%%%%%%%%
>>>  % for your epoched data, channel 2
>>> [spectra,freqs] = spectopo(EEG.data(2,:,:), 0, EEG.srate);
>>>
>>>  % delta=1-4, theta=4-8, alpha=8-13, beta=13-30, gamma=30-80
>>> deltaIdx = find(freqs>1 & freqs<4);
>>> thetaIdx = find(freqs>4 & freqs<8);
>>> alphaIdx = find(freqs>8 & freqs<13);
>>> betaIdx  = find(freqs>13 & freqs<30);
>>> gammaIdx = find(freqs>30 & freqs<80);
>>>
>>>  % compute absolute power
>>> deltaPower = mean(10.^(spectra(deltaIdx)/10));
>>> thetaPower = mean(10.^(spectra(thetaIdx)/10));
>>> alphaPower = mean(10.^(spectra(alphaIdx)/10));
>>> betaPower  = mean(10.^(spectra(betaIdx)/10));
>>> gammaPower = mean(10.^(spectra(gammaIdx)/10));
>>>  %%%%%%%%%%%%%%%%%
>>>
>>>  Makoto
>>>
>>>
>>> On Tue, Apr 14, 2015 at 6:23 AM, #SHAN XIN# <SHAN0055 at e.ntu.edu.sg>
>>> wrote:
>>>
>>>>  Hi EEGLab team,
>>>>
>>>> Does EEGlab has plugin or script so that I can get the power of
>>>> individual band (e.g. power of alpha band or beta band) from your
>>>> computation, instead of just a continuous line in the power
>>>> spectrum figure?  I'm not very proficient in Matlab programming...thank
>>>> you so much!!
>>>>
>>>>  Best wishes,
>>>>  SHAN Xin
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Eeglablist page: http://sccn.ucsd.edu/eeglab/eeglabmail.html
>>>> To unsubscribe, send an empty email to
>>>> eeglablist-unsubscribe at sccn.ucsd.edu
>>>> For digest mode, send an email with the subject "set digest mime" to
>>>> eeglablist-request at sccn.ucsd.edu
>>>>
>>>
>>>
>>>
>>>  --
>>>  Makoto Miyakoshi
>>> Swartz Center for Computational Neuroscience
>>> Institute for Neural Computation, University of California San Diego
>>>
>>>
>>
>>
>>  --
>>  Makoto Miyakoshi
>> Swartz Center for Computational Neuroscience
>> Institute for Neural Computation, University of California San Diego
>>
>
>
>
>  --
>  Makoto Miyakoshi
> Swartz Center for Computational Neuroscience
> Institute for Neural Computation, University of California San Diego
>

--
Makoto Miyakoshi
Swartz Center for Computational Neuroscience
Institute for Neural Computation, University of California San Diego
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20150507/8056bae3/attachment.html>
```