# Cortical labels power spectrum different approaches

**URL:** <https://mne.discourse.group/t/cortical-labels-power-spectrum-different-approaches/1600>\
**Category:** Mailing List Archive (read-only)\
**Tags:** list-archive\
**Created:** [August 29, 2018, 6:32pm UTC](https://mne.discourse.group/t/cortical-labels-power-spectrum-different-approaches/1600 "2018-08-29T18:32:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [August 29, 2018, 6:32pm UTC](https://mne.discourse.group/t/cortical-labels-power-spectrum-different-approaches/1600/1 "2018-08-29T18:32:39Z")

</div>

Hey all,

I'm calculating MEG cortical labels power spectrum (for resting state data) in two different ways. Can you help me understand the differences? The power spectrums are quite different (see attached).

1) Go through the source space time-series:

stcs = mne.minimum\_norm.apply\_inverse\_epochs(epochs, ...)  
labels\_ts = mne.extract\_label\_time\_course(stcs, labels, ...)  
for label\_ts:  
&nbsp;&nbsp;psds, freqs = mne.time\_frequency.psd\_array\_welch(label\_ts, ...)  
&nbsp;&nbsp;psds = 10 \* np.log10(psds)

2) Compute the PSD from the epochs:

for label\_ind, label in enumerate(labels):  
&nbsp;&nbsp;stcs = mne.minimum\_norm.compute\_source\_psd\_epochs(epochs, ...)  
&nbsp;&nbsp;for stc in stcs:  
&nbsp;&nbsp;&nbsp;&nbsp;psds = np.mean(stc.data, axis=0)

Thanks!

Noam

-------------- next part --------------  
An HTML attachment was scrubbed...  
URL: [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20180829/f20f7f3d/attachment-0001.html](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180829/f20f7f3d/attachment-0001.html)  
-------------- next part --------------  
A non-text attachment was scrubbed...  
Name: via\_epochs.png  
Type: image/png  
Size: 108924 bytes  
Desc: via\_epochs.png  
Url : [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20180829/f20f7f3d/attachment-0002.png](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180829/f20f7f3d/attachment-0002.png)  
-------------- next part --------------  
A non-text attachment was scrubbed...  
Name: via\_ts.png  
Type: image/png  
Size: 74593 bytes  
Desc: via\_ts.png  
Url : [http://mail.nmr.mgh.harvard.edu/pipermail/mne\_analysis/attachments/20180829/f20f7f3d/attachment-0003.png](http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180829/f20f7f3d/attachment-0003.png)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [August 29, 2018, 9:16pm UTC](https://mne.discourse.group/t/cortical-labels-power-spectrum-different-approaches/1600/2 "2018-08-29T21:16:16Z")

</div>

Let me be more specific/clear:

I'm analyzing data from a patient with an ECOG. I want to compare the power-spectrum of the electrodes and the MEG cortical labels I've created around each electrode.

It seems that calculating the time series in the source space of long enough MEG epochs (~10s), split the electrodes file to same length epochs, and use

mne.time\_frequency.psd\_array\_multitaper on both of them is the way to go, and also I know that both are in the same units (10\*log10 for [dB]).  
But I'm still a little bit confused by the different results I'm getting when using mne.minimum\_norm.compute\_source\_psd\_epochs instead.

Thanks,  
Noam

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [August 30, 2018, 1:27pm UTC](https://mne.discourse.group/t/cortical-labels-power-spectrum-different-approaches/1600/3 "2018-08-30T13:27:59Z")

</div>

External Email - Use Caution

hi,

It should be more in agreement.  
Can you share a script on one of the MNE datasets to figure out the  
cause of the difference?  
Also note that both units in your plots are very different (dB vs I am not sure)

Alex

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [August 31, 2018, 1:16am UTC](https://mne.discourse.group/t/cortical-labels-power-spectrum-different-approaches/1600/4 "2018-08-31T01:16:46Z")

</div>

Hey Alex,

Yes, you can find the script here\<[https://github.com/pelednoam/mmvt/blob/master/src/misc/power\_spectral\_density.py](https://github.com/pelednoam/mmvt/blob/master/src/misc/power_spectral_density.py)\>.

It's based on this mne example\<[https://martinos.org/mne/stable/auto\_examples/time\_frequency/plot\_compute\_source\_psd\_epochs.html](https://martinos.org/mne/stable/auto_examples/time_frequency/plot_compute_source_psd_epochs.html)\>.

One thing the pops immediately, is that only on the second approach (psd\_array\_multitaper on the label\_ts) you need to set the mode (I set it to mean\_flip)

Also, for both of them, I use 10 \* np.log10(x) to get dB. Not sure this correct in the first approach, mostly because it's not part of the mne example.

Thanks,

Noam

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [August 31, 2018, 12:47pm UTC](https://mne.discourse.group/t/cortical-labels-power-spectrum-different-approaches/1600/5 "2018-08-31T12:47:29Z")

</div>

We can debug it together today and update the mailing list.

Sheraz

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/mne/original/1X/85cc6bd2b69cb698a166dc6d880fb550510d0144.jpeg) [@system](https://mne.discourse.group/u/system)\
**Post date:** [August 31, 2018, 7:02pm UTC](https://mne.discourse.group/t/cortical-labels-power-spectrum-different-approaches/1600/6 "2018-08-31T19:02:16Z")

</div>

Hey all, thanks to Denis, it seems that setting the pick\_ori to 'normal' in apply\_inverse\_epochs did the trick.

Also, in both cases I added:

psd\_avg = 10 \* np.log10(psd\_avg)

To convert the results to [dB].

Now, the two power spectrums are much more similar, but the values in compute\_source\_psd\_epochs are bigger (see attached).

Thanks Denis!

Noam
