External Email - Use Caution
Dear MNE users,
We are trying to perform source localization at the single trial. For a reason we don't understand, the results we obtain when applying the inverse operator on each trial and then computing the average across trials do not really make sense when compared to applying the inverse operator to the averaged epochs. In other words, applying the inverse operator on the evoked object doesn't seem to be equivalent to averaging across trials the sources from each trial. We expected the two to be equivalent since the inverse operation is linear, but perhaps due to regularization, or another reason, the two shouldn't be the same.
If any of you had an example script for source localization at the single trial level it would help us to understand what we are doing wrong.
We have also looked at this example on mne website: "Compute MNE-dSPM inverse solution on single epochs", but didn't find the solution there.
Many thanks in advance
Best
S?bastien & Yair
Some details:
mne version: 0.16.dev0
OS: Ubuntu 16.04
Code:
'''
apply inverse operator and compare conditions
'''
import sys
import os
from os.path import join
import mne
from mne import morph_data
from mne.source_space import (setup_source_space, morph_source_spaces,
add_source_space_distances)
from mne.minimum_norm import (make_inverse_operator, read_inverse_operator, apply_inverse_epochs)
from sentcomp_epoching import get_condition
import numpy as np
import numpy.matlib
data_path = '/neurospin/meg/meg_tmp/sentcomp_Marti_2016/Seb/data'
subjects_dir = join(data_path, 'anatomy', 'subjects')
meg_dir = join(data_path, 'sss')
os.environ['SUBJECTS_DIR'] = subjects_dir
os.environ['MEG_DIR'] = meg_dir
speed_oi = 4
if speed_oi==1:
real_speed = .083
elif speed_oi==2:
real_speed = .116
elif speed_oi==3:
real_speed = .166
elif speed_oi==4:
real_speed = .301
# read epochs
epochs = mne.read_epochs(join(data_path, 'epochs', subject + '_speed'
+ str(speed) + '_V2-epo.fif'))
epochs.apply_baseline(baseline=(-0.76,-0.3), verbose=None)
# read inverse operator
inv_meg = read_inverse_operator(join(data_path, 'sources', subject +
'-meg-oct-6-meg-inv.fif'))
# get conditions
knames2, ep2 = get_condition(conditions=c2,epochs=epochs,startTime=-.2,
duration=1.5,real_speed=real_speed)
if timelock_to_word==True:
ev2 = ep2.average()
else:
ev2 = epochs[knames2].average()
ep2 = epochs[knames2]
snr = 3.0
lambda2 = 1./snr**2
# apply inverse operator
stc_meg2 = apply_inverse_epochs(ep2, inv_meg, lambda2=lambda2, method='MNE', pick_ori=None, nave=1)
av_stc_meg2 = np.mean(stc_meg2) # average of inverse
ev_stc_meg2 = apply_inverse(ev2, inv_meg, lambda2=lambda2, method='MNE', pick_ori=None) # inverse of average
av_stc_meg2.plot(subject='am150105', surface='inflated', hemi='lh', smoothing_steps=12, time_viewer=True, subjects_dir=subjects_dir, figure=None, views='lat', backend='mayavi', time_unit='ms', spacing='oct6')
ev_stc_meg2.plot(subject='am150105', surface='inflated', hemi='lh', smoothing_steps=12, time_viewer=True, subjects_dir=subjects_dir, figure=None, views='lat', backend='mayavi', time_unit='ms', spacing='oct6')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20180622/5bc2513d/attachment.html