# compute\_source\_psd in volume source spaces

**URL:** <https://mne.discourse.group/t/compute-source-psd-in-volume-source-spaces/4571>\
**Category:** Support & Discussions\
**Tags:** ﻿source-localization\
**Created:** [March 17, 2022, 9:37am UTC](https://mne.discourse.group/t/compute-source-psd-in-volume-source-spaces/4571 "2022-03-17T09:37:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeilaNS](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/leilans/32/123_2.png) [@LeilaNS](https://mne.discourse.group/u/LeilaNS)\
**Post date:** [March 17, 2022, 9:37am UTC](https://mne.discourse.group/t/compute-source-psd-in-volume-source-spaces/4571/1 "2022-03-17T09:37:08Z")

</div>

Hi,  
I would like to calculate the psds in volume source spaces.  
For the moment I have modified the example: : [Source reconstruction using an LCMV beamformer](https://mne.tools/stable/auto_tutorials/inverse/50_beamformer_lcmv.html#sphx-glr-auto-tutorials-inverse-50-beamformer-lcmv-py)  
and instead of evoked data I have used the psds in the sensor space.  
Here is my code:

- MNE version: e.g. 0.24.0
- operating system: Ubuntu 18.04

```python
psds, freqs = psd_multitaper(epochs, fmin,fmax, n_jobs=-1)
epochs.data=psds
evoked = epochs.average()
evoked.data=epochs.data.mean(0)
evoked.times=freqs
filters_vec = make_lcmv(evoked.info, forward, data_cov, reg=0.05,reduce_rank = True,
                        noise_cov=noise_cov, pick_ori='vector',
                        weight_norm='unit-noise-gain', rank=rank)
stc_vec = apply_lcmv(evoked, filters_vec, max_ori_out='signed')

```

Do you know a more direct method?  
Best,  
Leila

---

<div class="post-metadata">

**Author:** ![larsoner](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/larsoner/32/3_2.png) [@larsoner](https://mne.discourse.group/u/larsoner)\
**Post date:** [March 17, 2022, 2:41pm UTC](https://mne.discourse.group/t/compute-source-psd-in-volume-source-spaces/4571/2 "2022-03-17T14:41:53Z")

</div>

> [@LeilaNS](#):
>
> Here is my code:

Unfortunately this will not be correct – PSDs are _power_, i.e., a nonlinear transform has been applied. So applying the LCMV filters to these data will not give the correct result.

Even though it will be slow, you should apply your LCMV to the evoked data itself like `stc = apply_lcmv_epochs(epochs, ...)`, then compute the PSD of the resulting STCs using `psd_array_multitaper`, and average those.

Also keep in mind that it does matter when you take the average – the PSD of the average over epochs will be different from the average over the PSDs of each epoch. They tell you different things about your data. This is true whether you compute your PSDs in source or sensor space.

---

<div class="post-metadata">

**Author:** ![LeilaNS](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/leilans/32/123_2.png) [@LeilaNS](https://mne.discourse.group/u/LeilaNS)\
**Post date:** [March 18, 2022, 1:17pm UTC](https://mne.discourse.group/t/compute-source-psd-in-volume-source-spaces/4571/3 "2022-03-18T13:17:51Z")

</div>

Thank you very much Eric,  
I did as you suggested  
`stc = apply_lcmv_epochs(epochs, filters, max_ori_out='signed')`  
My goal is to get the Morph psds to fsaverage. Are you suggesting that I first compute psds and then morph to fsaverage or that I first morph stc to fsaverage and then compute psds?  
I understand the difference between Mean(psd) and psd(Mean)
