Visualizing power spectrum density of sources on the brain

Hi,

I have a couple of questions about the psd of sources:

1) I used

stc = mne.minimum_norm.compute_source_psd

to get an stc file containing the psd of the sources. It seems like in
this stc file,
frequency has replaced time, but is still called 'time':

<SourceEstimate | ... tmin : 0.0 (ms), tmax : 55.0 (ms), tstep :
0.25 (ms) ...>

(I set the function to compute from 0 to 55 Hz; the time duration of the data is
actually a lot longer). I can use stc.plot or
mne.plot_source_estimates to visualize this, but it treats
the frequencies like times. How can I plot the psd at a particular
frequency on the brain?

2) What are the units of the psd of the sources? According to the
tutorial <http://martinos.org/mne/stable/auto_examples/time_frequency/plot_source_power_spectrum.html#sphx-glr-auto-examples-time-frequency-plot-source-power-spectrum-py>
the psd is in dB,
but what is the reference quantity being used when converting to dB?
(Ie. what is Pref in P_db = 10*log10(P/Pref)?)
Am I right that the source amplitudes are in units of ampere-metres?

Thanks and Best,
Gladia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20160630/34c16e41/attachment.html

I can answer in greater detail later, but 1) you need to "hack" the stc
object and figure out the right scale after putting the frequenies in
.times and accordingly scale ; by default our data containers assume time
domain data 2) if you use dSPM as method it is a pseudo F-statistic, for
interpretable power plots you should use MNE as method in the inverse
solver

I hope this helps a bit,

Denis

hi,

see the code:

https://github.com/mne-tools/mne-python/blob/master/mne/minimum_norm/time_frequency.py#L480

let us know if you see any bug or documentation problem.

thanks
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20160701/4cf7e910/attachment.html

Hi Denis,

I tried replacing stc.data and stc.times as such:

stc._data = stc.data[0] # Just look at the first frequency
stc.times = stc.times[0]

But trying to plot this gives 'ValueError: dimension mismatch'. Could you
explain a bit more about how I should hack the stc object? Also, how do I
figure out how much to scale the data by?

Thank you and Best Regards,
Gladia

Hi,

I fixed the error by using:

stc._data = stc.data[:,0:1] # First column of sources, instead of
stc.data[:,0] which gives wrong dimensions.

stc.times = stc.times[0:1] # Extract the first frequency, preserving the
array format (instead of stc.times[0], which is a single number).
# (Multiply this by 1000 to get frequency in Hz because compute_source_psd
converts time into milliseconds)

Now mne.viz.plot_source_estimates(stc,...) produces a plot on the brain at
a single frequency.

Could anyone explain why MNE should be used instead of dSPM to get the
power plots? The tutorial on the MNE website says to use dSPM as the solver.

Thanks and Best,
Gladia

Could anyone explain why MNE should be used instead of dSPM to get the power
plots? The tutorial on the MNE website says to use dSPM as the solver.

dSPM is just a normalized/scaled version of MNE (scaling is obtained
form the noise standard deviation derived from the noise cov). So
basically it's just a scaling factor. If you apply a baseline /
contrast with a log ratio of power then there is no diff between the
2.

HTH
Alex

Thanks Alex!

I am wondering why when I plot the psd on the brain I get a lot of activity
in the corpus callosum and white matter rather than in the grey matter,
which is where the sources are localized to. Here is a link to example
screenshots of the source distribution vs the psd distribution on the
brain, which don't seem to match:
https://www.dropbox.com/sh/blstn3xitewbg5t/AACia--q9mF6d0ZjluhXq_TGa?dl=0

How can I check that the source psd is being plotted correctly?

Thanks and Best,
Gladia

Sorry Gladia,

I was a bit unclear I fear. I was referring to the fact, that if you want
to see things in dB and want to look at the power spectrum in one ROI or
vertex the same way you want to look at it in the sensor space, you need to
use the MNE option. You can then intuitively take the decadic logarithm and
scale to dB.
Then for the surface plotting it is a bit tricky with regard to color maps.
Both dSPM and MNE can be intuitively used but the entire MNE viz system
sort of expects time domain data as you may have noticed, where data are
dont' have any tend.
With frequency domain data this is not the case, you have local peaks but a
global 1/f trend which will mess up your display. You then either need to
detrend the spectrum or choose fmin, fmid, fmax, carefully, essentially
setting them at each frequency where you make sure that your stc.times
vector is not longer than 1; by default histograms for determining viz
values are computed over all time points so the auto option won't work.
Lot's of manual tuning required unfortunately.
As to your plots I'm not fully sure I get your message. Intuitively make
sure you get the relationship between the time domain and the specteal data
right, maybe the time domain localization is driven by a certain band. And
as said, colormaps can be difficult and misleading. Plotting historgrams
along the way and looking at slices can help understand what you do.

I hope this helps a bit,
Denis

Hi Denis,

Thanks for your reply!

I noted that in the compute_source_psd code, the output is already scaled
to dB (psd = 10*np.log10(psd) is taken in line 486). Is it still necessary
to take 10*log10 of the output?

I tried detrending the data prior to computing the inverse solution and
noise covariance matrix, but I get a similar result in which most of the
power is localized in the white matter. An example of the average I get
over many epochs is at this link:
https://www.dropbox.com/s/vs7jjd8u2szjrbo/Screen%20Shot%202016-07-14%20at%202.19.20%20PM.png?dl=0

I tried plotting spectra (power vs frequency) of the sources and the
spectra look reasonable; it's just the spatial distribution that's strange.

This is roughly how I'm extracting power at a certain frequency:

# Compute psd of sources:
stc_psd = mne.minimum_norm.comptue_source_psd(...)

# Extract the frequency band of interest:
data = stc_psd.data[:,1:5] # Shape: numsources*4

# Sum the power in the frequency band of interest:
av_data = np.transpose(np.array([np.sum(data,1)])) # Shape: numsources*1

# Make a copy of the stc object and overwrite its data:
stc_psd1 = stc_psd.copy()
stc_psd1.times = stc_psd_slow.times[0:1] # Doesn't matter what this
number is; just get the dimensions right
stc_psd1._data = av_data

# Visualize:
mne.viz.plot_source_estimates(stc_psd1,...)

Is there any other troubleshooting method I can try?

Thanks and Best,
Gladia

I noted that in the compute_source_psd code, the output is already scaled

to dB (psd = 10*np.log10(psd) is taken in line 486). Is it still necessary
to take 10*log10 of the output?

Hum... probably not then. I have to go back to see on what my observation
was based, I clearly remember having seen regular unscaled PSDs as outputs
based on MNE normal orientation solutions. Basically make sure you check
histograms, they are informative.

# Sum the power in the frequency band of interest:
av_data = np.transpose(np.array([np.sum(data,1)])) # Shape: numsources*1

you can simplify:

av_data = np.sum(data,1)[:, np.newaxis] # make it 2d after averaging

or

av_data = np.sum(data, 1, keepdims=True) # make it 2d after averaging

btw. checkout `stc.average`

I cannot promise you to get back to you super quickly, but I would offer
you to share some average PSD data with me and I'd try to plot them to get
a better idea what they look like. We can proceed in private for this if
you prefer.

Cheers,
Denis