# EEG leadfield computation - On all ROI elements¶

The leadfield matrix can be computed on different source spaces in shamo. In this example, we consider all the elements of the region of interest as potential dipoles.

The first step is to load the finite element model created before.

[ ]:

from shamo import FEM


[ ]:

import logging
import sys

logger = logging.getLogger("shamo")
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(logging.Formatter("[{levelname}] {message}", style="{"))
logger.setLevel(logging.INFO)


Then we import the ProbEEGLeadfield class and instatiate it.

[ ]:

from shamo.eeg import ProbEEGLeadfield



## Electrical conductivity definition¶

The electrical conductivity of the tissues is stored in a CompTissueProp instance providing the set() and sets() methods that can be used to define the values of $$\sigma$$.

Note

The electrical conductivity is defined in Sm:math:^{-1}.

[ ]:

problem.sigmas.set("scalp", 0.4137)
problem.sigmas.set("gm", 0.4660)
problem.sigmas.set("wm", 0.2126)


## Electrodes definition¶

To compute the leadfield matrix on an element basis as described in 1, a reference electrode must be set. The reference is stored in a CompSensors instance and must be defined with the add() method.

[ ]:

problem.reference.add("IZ")


Optionally, inactive electrodes can be listed to make sure no computation is performed for them. As for the reference, they can be added with the add() method. If multiple markers must be added, the adds() function is also available.

[ ]:

problem.markers.adds(["NZ", "LeftEar", "RightEar"])


## Region of interest definition¶

The last parameter for the problem is the region of interest. The tissues to compute the leadfield for are stored in a CompTissues instance and can be added with the add() and adds() functions.

[ ]:

problem.rois.add("gm")


## Problem resolution¶

Now that the problem is fully defined, we just have to solve it and set a name and a directory for the output.

[ ]:

solution = problem.solve("single_ssp-elems", "../../derivatives/eeg_leadfield", model)


1

David Weinstein, Leonid Zhukov, and Chris Johnson. Lead Field Basis for FEM Source Localization. Annals of Biomedical Engineering, 28(9):1059–1065, 2000. doi:10.1114/1.1310220.