[Mne_analysis] Applying Inverse to Evoked vs Applying Inverse to Epochs and Averaging

Rockhill, Alexander P. AROCKHILL at mgh.harvard.edu
Fri Nov 3 11:29:28 EDT 2017
Search archives:

Hi Chris,

    Of course, here is the relevant code:

snr=1.0
method='dSPM'
set_log_level("critical")

set_config("SUBJECTS_DIR",fs_dir,set_env=True)

bem = read_bem_solution(os.path.join(fs_dir, data.name, 'bem',
                        '%s-5120-5120-5120-bem-sol.fif' % data.name))
source = read_source_spaces(os.path.join(fs_dir, data.name, 'bem',
                                         '%s-oct-6p-src.fif' % data.name))
coord_trans = read_trans(os.path.join(fs_dir, data.name, 'mri', 'T1-neuromag',
                                      'sets', 'COR-%s-%s.fif' %(data.name,data.task)))

# Source localization parameters.
lambda2 = 1.0 / snr ** 2
pick_ori = 'normal'

value_indices = data._get_indices(event,condition,values,bins)

epochs = data.epochs_current[event]
epochs.set_eeg_reference(None)
info = epochs.info

print('Making forward model...')
fwd = make_forward_solution(epochs.info,coord_trans,source,bem,
                            meg=False,eeg=True,mindist=1.0)

print('Making noise covariance matrices...')
data.epochs_current['baseline'].info['bads'] = epochs.info['bads']
data.epochs_current['baseline'].set_eeg_reference(None)
_,tmin,tmax = data.events['baseline']
noise_cov = compute_covariance(data.epochs_current['baseline'],
                                    tmin=tmin,tmax=tmax,
                                    method="shrunk")

print('Making inverse...')
inv = make_inverse_operator(epochs.info, fwd, noise_cov)
data.invs[event] = (inv,lambda2,method)

bl_epochs = data.epochs_current['baseline'].crop(tmin=tmin,tmax=tmax)
data.stcs['baseline'] = apply_inverse_epochs(bl_epochs,inv,lambda2=lambda2,method=method)
A = sum([ss.data for ss in data.stcs['baseline']])/len(data.stcs['baseline'])

bl_evoked = data.epochs_current['baseline'].crop(tmin=tmin,tmax=tmax).average()
B = apply_inverse(bl_evoked,inv,lambda2=lambda2,method=method).data

np.array_equal(A,B) # False

Hope that helps.

Alex

________________________________
From: mne_analysis-bounces at nmr.mgh.harvard.edu [mne_analysis-bounces at nmr.mgh.harvard.edu] on behalf of Christopher Bailey [cjb at cfin.au.dk]
Sent: Friday, November 03, 2017 11:20 AM
To: Discussion and support forum for the users of MNE Software
Subject: Re: [Mne_analysis] Applying Inverse to Evoked vs Applying Inverse to Epochs and Averaging

Hi Alex,

Would you mind sharing the code you used for this experiment? I have a feeling the answer might be of general relevance, and it might help to be concrete.

/Chris
/Aarhus, DK

On 3 Nov 2017, at 16.11, Rockhill, Alexander P. <AROCKHILL at mgh.harvard.edu<mailto:AROCKHILL at mgh.harvard.edu>> wrote:

Hi all,

    I tried applying an inverse model to the evoked data and also applying inverse epochs directly to the same epochs that were averaged to make the evoked data and then averaging the data from the list of source space time courses, and these matrices weren't the same. Does anyone have any insight as to why this would be?

Thanks,

Alex
_______________________________________________
Mne_analysis mailing list
Mne_analysis at nmr.mgh.harvard.edu<mailto:Mne_analysis at nmr.mgh.harvard.edu>
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/mne_analysis


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/mne_analysis/attachments/20171103/67584ba5/attachment-0001.html 


More information about the Mne_analysis mailing list