Today we'll attempt to combine the subcortical volume source space with a cortical surface source space.
The code below is last week's code with a few modifications. Namely, I'm adding the cortical source space
and then computing the forward model.
import numpy as np
import mne
from mne.datasets import spm_face
from mne.minimum_norm import make_inverse_operator, apply_inverse_epochs
import matplotlib.pyplot as plt
%matplotlib inline
# supress text output
mne.set_log_level(False)
# set the data directories
data_path = spm_face.data_path()
subjects_dir = data_path + '/subjects'
subject = 'spm'
subject_dir = data_path + '/subjects/' + subject
meg_dir = data_path + '/MEG/spm'
# get the data files
bem_fname = subject_dir + '/bem/spm-5120-5120-5120-bem-sol.fif'
mri_fname = meg_dir + '/SPM_CTF_MEG_example_faces1_3D_raw-trans.fif'
epo_fname = meg_dir + '/SPM_CTF_MEG_example_faces1_3D_epo.fif'
# load the epoch data
epochs = mne.read_epochs(epo_fname)
# get positions and orientations of the right amygdala (subcortical)
pos = mne.source_space.get_segment_positions('spm', 'Right-Amygdala',
random_ori=True,
subjects_dir=subjects_dir)
# setup the right amygdala volume source space
vol_src = mne.setup_volume_source_space('spm', pos=pos)
# setup the cortical surface source space
src = mne.setup_source_space('spm', overwrite=True)
# combine the source spaces
src.append(vol_src[0])
# setup the forward model
forward = mne.make_forward_solution(epochs.info, mri=mri_fname, src=src,
bem=bem_fname)
forward = mne.convert_forward_solution(forward, surf_ori=True)
# Compute inverse solution
snr = 5.0
lambda2 = 1.0 / snr ** 2
method = 'dSPM'
# estimate noise covarariance
noise_cov = mne.compute_covariance(epochs.crop(None, 0, copy=True))
# make the inverse operator
inverse_operator = make_inverse_operator(epochs.info, forward, noise_cov,
loose=0.2, depth=0.8)
# Apply inverse solution to both stim types
stc_faces = apply_inverse_epochs(epochs['faces'], inverse_operator, lambda2,
method)
stc_scrambled = apply_inverse_epochs(epochs['scrambled'], inverse_operator,
lambda2, method)
As you can see, the program crashed.
Digging deeper into the mne code, it looks like the function is setup to read either a volume or a surface
source space, but not both. Fortunately, another mne contributor shared his processing stream for
combining source spaces. In his implementation, he combines the forward operators, not the source spaces.
More on that implementation tomorrow.
No comments:
Post a Comment