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