Gallery#
The Gallery showcases all solvers with an example inverse solution for a small source patch projected to 64 EEG channels with high signal-to-noise ratio. The code that generated the data, the inverse solutions and saved the results is given as follows:
Import functions and create a generic Forward Model:
%matplotlib inline
%load_ext autoreload
%autoreload 2
import sys; sys.path.insert(0, '../')
import numpy as np
from matplotlib import pyplot as plt
from scipy.stats import pearsonr
import mne
from invert.forward import get_info, create_forward_model
from invert.util import pos_from_forward
pp = dict(surface='inflated', hemi='both', clim=dict(kind="percent", pos_lims=(0, 99, 100)), colorbar=False, verbose=0)
info = get_info(kind='biosemi64')
fwd = create_forward_model(info=info, sampling='ico3')
pos = pos_from_forward(fwd)
leadfield = fwd["sol"]["data"]
n_chans, n_dipoles = leadfield.shape
source_model = fwd['src']
vertices = [source_model[0]['vertno'], source_model[1]['vertno']]
Next we simulate a sample using the invert data generator:
from invert.solvers.esinet import generator
sim_params = dict(
use_cov=False,
return_mask=False,
batch_repetitions=1,
batch_size=1,
n_sources=1,
n_orders=(2, 3),
snr_range=(100, 101),
n_timecourses=1,
scale_data=False)
gen = generator(fwd, **sim_params)
x, y = gen.__next__()
tmin = 0
tstep = 1/info["sfreq"]
subject = "fsaverage"
evoked = mne.EvokedArray(x[0].T, info, tmin=tmin)
stc = mne.SourceEstimate(y[0].T, vertices, tmin=tmin, tstep=tstep,
subject=subject, verbose=0)
Here we calculate all inverse solutions and plot them:
%matplotlib inline
from invert import Solver
from invert.config import all_solvers
# Plot Ground Truth
stc.data /= abs(stc.data[:, 0]).max()
clim = dict(kind="values", pos_lims=(0., 0.5, 1))
pp["clim"] = clim
brain = stc.plot(**pp, brain_kwargs=dict(title="Ground Truth"))
brain.add_text(0.1, 0.9, "Ground Truth", 'title', font_size=16)
img = brain.screenshot()
brain.close()
plt.figure()
plt.imshow(img)
plt.axis("off")
fname = f"../figures/solver_gallery/GroundTruth"
plt.savefig(fname, dpi=150)
plt.close()
# Plot Source Estimates
for solver_name in all_solvers[15:][::-1]:
solver = Solver(solver_name)
solver.make_inverse_operator(fwd, evoked)
stc_ = solver.apply_inverse_operator(evoked)
stc_.data /= abs(stc_.data[:, 0]).max()
clim = dict(kind="values", pos_lims=(0., 0.5, 1))
pp["clim"] = clim
brain = stc_.plot(**pp, brain_kwargs=dict(title=solver.name))
brain.add_text(0.1, 0.9, solver.name, 'title', font_size=16)
img = brain.screenshot()
brain.close()
fig = plt.figure()
plt.imshow(img)
plt.axis("off")
fname = f"../figures/solver_gallery/{solver.name}"
plt.savefig(fname, dpi=150)
plt.close()
Ground Truth#
Minimum Norm/Current Estimates#
solver = Solver("MNE")
solver = Solver("wMNE")
solver = Solver("dSPM")
solver = Solver("FISTA")
solver = Solver("L1L2")
LORETA#
solver = Solver("LORETA")
solver = Solver("sLORETA")
solver = Solver("eLORETA")
Bayes#
solver = Solver("Source-MAP")
solver = Solver("Gamma-MAP")
solver = Solver("Source-MAP-MSP")
solver = Solver("Gamma-MAP-MSP")
solver = Solver("Champagne")
solver = Solver("MM Champagne")
solver = Solver("LowSNR Champagne")
solver = Solver("MacKay Champagne")
solver = Solver("Convexity Champagne")
solver = Solver("Homoscedasticity Champagne")
solver = Solver("FUN")
solver = Solver("BCS")
Matching Pursuit#
solver = Solver("OMP")
solver = Solver("SOMP")
solver = Solver("CoSaMP")
solver = Solver("SSP")
solver = Solver("SP")
Smooth Matching Pursuit#
solver = Solver("SOMP")
solver = Solver("SSMP")
solver = Solver("SubSMP")
Artificial Neural Networks#
solver = Solver("FC")
solver = Solver("CNN")
solver = Solver("Cov-CNN")
solver = Solver("LSTM")
MUSIC#
solver = Solver("MUSIC")
solver = Solver("RAP-MUSIC")
solver = Solver("TRAP-MUSIC")
solver = Solver("FLEX-MUSIC")
Beamformers#
solver = Solver("MVAB")
solver = Solver("LCMV")
solver = Solver("SMV")
solver = Solver("WNMV")
solver = Solver("HOCMV")
solver = Solver("ESMV")
solver = Solver("MCMV")
solver = Solver("HOCMCMV")
solver = Solver("ReciPSIICOS")
solver = Solver("SAM")
MISC#
solver = Solver("Backus-Gilbert")
solver = Solver("GPT")
solver = Solver("EPIFOCUS")
solver = Solver("LAURA")
solver = Solver("S-MAP")