EEG parametric leadfield computation - On regular gridΒΆ
This example will not be explained as all the required information is already available in the other tutorials. It simply shows that the regular grid source space can be used for the parametric solution.
[ ]:
from shamo import FEM
model = FEM.load("../../derivatives/fem_from_labels/fem_from_labels.json")
[ ]:
from shamo.eeg import ProbParamEEGLeadfield
problem = ProbParamEEGLeadfield()
[ ]:
from shamo import DistUniform
problem.sigmas.set("scalp", DistUniform(0.137, 2.1))
problem.sigmas.set("gm", DistUniform(0.06, 2.47))
problem.sigmas.set("wm", DistUniform(0.0646, 0.81))
[ ]:
problem.reference.add("IZ")
[ ]:
problem.markers.adds(["NZ", "LeftEar", "RightEar"])
[ ]:
import nibabel as nib
from nilearn.image import crop_img
img = nib.load(model.nii_path)
mask = img.get_fdata() == 2
mask_img = nib.Nifti1Image(mask.astype(int), img.affine)
mask_img = crop_img(mask_img)
[ ]:
problem.grid.set(
mask_img.affine,
mask_img.shape,
mask=mask_img.get_fdata().astype(bool)
)
[ ]:
solution = problem.solve("parametric_ssp-grid", "../../derivatives/eeg_leadfield", model, n_evals=4, method="multiprocessing", n_proc=4)