HD-tDCS simulationΒΆ

To simulate HD-tDCS is very easy in shamo.

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

[ ]:
from shamo import FEM

model = FEM.load("../../derivatives/fem_from_labels_sensors-circle/fem_from_labels_sensors-circle.json")

Next we import the ProbHDTDCSSim class and create an instance of it.

[ ]:
from shamo.hd_tdcs import ProbHDTDCSSim

problem = ProbHDTDCSSim()

Then, as for the EEG leadfield computation, we set the electrical conductivity of the tissues, setup the reference electrodes and source. We also set the injected current (A).

[ ]:
problem.sigmas.set("scalp", 0.4137)
problem.sigmas.set("gm", 0.4660)
problem.sigmas.set("wm", 0.2126)
[ ]:
problem.source.add("P3")
[ ]:
problem.references.adds(["T5", "C3", "PZ", "O1"])
[ ]:
problem.current = (0.004)
[ ]:
import nibabel as nib

img = nib.load(model.path / f"{model.name}.nii")
problem.grid.set(img.affine, img.shape)

Finally, we solve the problem and obtain the different field generated in the whole brain both in the form of POS files that can be opened in Gmsh and in the form of NII files that can be visualised in FSLeyes or any other nifti file opener.

[ ]:
solution = problem.solve("single", "../../derivatives/hd_tdcs_simulation_sensors-circle", model)