# [Eeglablist] help with power spectral density

Makoto Miyakoshi mmiyakoshi at ucsd.edu
Fri Feb 6 20:07:00 PST 2015

```Dear Jerry,

You are absolutely right! Thank you for pointing this out. I'll send
erratum mail to the past recipients.

Makoto

On Fri, Feb 6, 2015 at 2:01 PM, Jerry Zhu <jerryzhu at siu.edu> wrote:

> Hi Makoto,
> Thanks for your script!  I have been using it for our data analysis. But I
> came to realized that the calculation might be a bit different.  Here is
> how:
>
> the output from pop_spectopo or spectopo is in unit of 10*log10(absolute
> power) for each freq bin (say bins b1, b2, b3...  and their corresponding
> absolute powers are x1, x2, x3...)
>
> when averaging them directly as in mean(spectra()) that is essentially:
> (10*log10(x1) + 10*log10(x2) + 10*log10(x3) + ... )/n =
> 10*log10(x1*x2*x3...)/n  (because the rule of log, plus becomes
> multiplication)
>
> Ideally, this would be 10*log10( (x1+x2+x3+...)/n )
>
> -----------------Real example----------------
> The difference of the calculations is smaller with my real data (directly
> from spectopo function):
> m = [
> -11.0966824712145    -12.2067403734393    -13.1537220992757
> -13.7874266498803    -14.1237495677973    -14.0469685506013
> -13.6313946102344    -13.7130254954176    -14.5080218939225
> -15.2868369198729    -15.3919990544936    -15.3197288848941]
> the mean of above numbers directly is -13.8555, convert to absolute power
> is 10^(-13.8555/10) = 0.0412
>
> if we convert each number to absolute power first and then calculate mean
> would be mean(10.^(m/10)) =  0.0429
>
> Hope this makes sense to you.  whew! ...
>
> Can you comment on that?  Thanks!
>
> Jerry
>
> --
> Jian Zhu, M.A., Ph.D candidate
> Department of Psychology
> Southern Illinois University Carbondale
> Web: http://zhupsy.com
>
> We have two halves in the brain: left and right. Nothing is right in the
> left. Nothing is left in the right.
>
> On Sun, Nov 16, 2014 at 3:54 PM, Makoto Miyakoshi <mmiyakoshi at ucsd.edu>
> wrote:
>
>> Dear Omar,
>>
>> Sorry for slow response.
>> You have to use the spectopo() function in the command line to obtain the
>> raw values. There were related posts in the past in which I have been
>> repeatedly showing the following. Hope it helps.
>>
>> %%%%%%%%%%%%%%%%%%%
>> % 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 = 10^(mean(spectra(deltaIdx))/10);
>> thetaPower = 10^(mean(spectra(thetaIdx))/10);
>> alphaPower = 10^(mean(spectra(alphaIdx))/10);
>> betaPower  = 10^(mean(spectra(betaIdx))/10);
>> gammaPower = 10^(mean(spectra(gammaIdx))/10);
>> %%%%%%%%%%%%%%%%%
>>
>> If you don't want to code, maybe you want to try the following toolbox.
>> http://www.poil.dk/s/#.VDRGNZTWXNU
>>
>> Makoto
>>
>> On Mon, Nov 3, 2014 at 12:24 PM, Omar Ortega <tourette95 at gmail.com>
>> wrote:
>>
>>> Hi there!
>>>
>>> I have a question about computing psd,
>>>
>>> I loaded an neuroscan .ee file and I wan to compute the power spectral
>>> density, I saw in webpage that is possible to do that by using the plot
>>> function, the problemm is:
>>>
>>> I clicked on plot function, but how can i get that into numerical data?
>>>
>>> I need to export the psd in text file in order to work whit it, so first
>>> i hope using plot function from eeglab was enough to get the psd.
>>>
>>>
>>>
>>> _______________________________________________
>>> 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
>>
>> _______________________________________________
>> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sccn.ucsd.edu/pipermail/eeglablist/attachments/20150206/ed97226d/attachment.html>
```