I want to do volume source estimation with template MRI provided by MNE
library. All I have is EEG data which is sampled with standard_1020
montage.
I successfully plotted source estimation with template MRI by referencing these documents:
However, the figure like this is not what I want:
I checked these documents to get solutions by tweaking solutions from EEG forward operator with a template MRI but, found out that I first have to get volume source estimate
, not source estimate
.
I also checked the The typical M/EEG workflow and got the general idea of workflow.
I guess if I cannot utilize template MRI, I think I can use a sample dataset from MNE
, but I have no idea where to start. I read and read the documents, but couldn't find hints.
Here are the documents I found out related to my problem so far:
Example gallery
Tutorials
I figured it out. It was painful to piece things together though.
# %% Importing libraries
import os.path as op
import mne
from mne.datasets import fetch_fsaverage
from mne.minimum_norm import apply_inverse
####################################
## data manipulation part omitted ##
####################################
# %% Template MRI
fs_dir = fetch_fsaverage(verbose=True)
subjects_dir = op.dirname(fs_dir)
# Trans, and BEM
subject = 'fsaverage'
trans = 'fsaverage'
bem = op.join(fs_dir, 'bem', 'fsaverage-5120-5120-5120-bem-sol.fif')
mri = op.join(fs_dir, 'mri', 'T1.mgz')
# %% Setup volumn source space (This is the part how to create volSourceEstimate)
vol_src = mne.setup_volume_source_space(
subject, mri=mri, pos=10.0, bem=bem,
subjects_dir=subjects_dir,
add_interpolator=True,
verbose=True)
# %% Forward solution
fwd = mne.make_forward_solution(raw.info, trans=trans, src=vol_src,
bem=bem, eeg=True, meg=False, mindist=5.0, n_jobs=1)
# %% Inverse operator
info = evoked.info
inv = mne.minimum_norm.make_inverse_operator(info, fwd, noise_cov,
loose=1, depth=0.8)
# %% Source space
snr = 3.0
lambda2 = 1.0 / snr ** 2
method = "dSPM"
stc = apply_inverse(evoked, inv, lambda2, method)
stc.crop(0.0, 0.2)
stc.plot(vol_src, subject='fsaverage', subjects_dir=subjects_dir)