Volume Source Space Orientation

External Email - Use Caution

Hi there,

I tried to answer this question by searching the email list and github
discussions, but failed to find an solution. Please bear with me if this
has been answered before.

I am trying to compute the inverse solution for a volume source space. I
generated this space with the "mne.setup_volume_source_space" function.
Then I calculated the inverse solution using
"mne.minimum_norm.make_inverse_operator"
and set "loose" option to 1 for free orientation. After I did
"apply_inverse_raw", I expected to get three values for each source grid
because of the free orientation option, but I only found one. Is there a
way to get the vector value for each volume source grid?

I also tried to set the "pick_ori" option in
"mne.minimum_norm.apply_inverse_raw"
to 'vector', but the program reported "ValueError: Number of vertices
(11994) and stc.shape[0] (35982) must match".

Thank you in advance for the answer!

Best,
Zhongnan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180515/c8becabe/attachment.html

External Email - Use Caution

Hi Zhongnan,

I don't anyone has ever attempted what you tried. What you tried should
have worked.

Please open an issue with a full script to replicate the bug using the sample
dataset and we'll fit it asap.

Alex

External Email - Use Caution

I tried this recently and had to change a single line, I will make a PR to discuss further

External Email - Use Caution

here it is:

https://github.com/mne-tools/mne-python/pull/5209

A

External Email - Use Caution

Zhongnan, if you?re comfortable with installing a GitHub version you could check whether that solves your issue?

External Email - Use Caution

Hi all,

I first would like to thank you for the quick response!

I will try to code with the github version to see if it works for me. I
will keep you guys updated.

Thanks again!

Best,
Zhongnan

External Email - Use Caution

Hi all,

I tested Christian's commit and it works great for my need. I also tested
it with the following code adapted from the MNE example.

Thanks again everyone! You are AWESOME!

Best,
Zhongnan

import matplotlib.pyplot as plt

from nilearn.plotting import plot_stat_map
from nilearn.image import index_img

from mne.datasets import sample
from mne import read_evokeds
from mne.minimum_norm import apply_inverse, read_inverse_operator

import numpy as np

data_path = sample.data_path()
fname_inv = data_path + '/MEG/sample/sample_audvis-meg-vol-7-meg-inv.fif'
fname_evoked = data_path + '/MEG/sample/sample_audvis-ave.fif'

snr = 3.0
lambda2 = 1.0 / snr ** 2
method = "dSPM"

# Load data
evoked = read_evokeds(fname_evoked, condition=0, baseline=(None, 0))
inverse_operator = read_inverse_operator(fname_inv)

# Compute inverse solution

# Vector
stc_v = apply_inverse(evoked, inverse_operator, lambda2, method,
pick_ori='vector')
# Magnitude
stc_m = apply_inverse(evoked, inverse_operator, lambda2, method,
pick_ori=None)

# Data converted from vector to the magnitude data
stc_v2m_data = np.sqrt(np.sum(stc_v.data**2,axis=1))
# The magnitude data
stc_m_data = stc_m.data

# Difference between the two
diff = np.sqrt(np.sum(stc_v2m_data-stc_m_data)**2)

print(diff)

The output diff is 1.63549729315e-14