<jupyter_start><jupyter_text>HD-tDCS simulation==================To simulate HD-tDCS is very easy in *shamo*.The first step is to load the finite element model created before.<jupyter_code>from shamo import FEM

model = FEM.load("../../derivatives/fem_from_labels/fem_from_labels.json")<jupyter_output><empty_output><jupyter_text>Next we import the :py:class:`~shamo.hd_tdcs.simulation.single.problem.ProbHDTDCSSim` class and create an instance of it.<jupyter_code>from shamo.hd_tdcs import ProbHDTDCSSim

problem = ProbHDTDCSSim()<jupyter_output><empty_output><jupyter_text>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).<jupyter_code>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)<jupyter_output><empty_output><jupyter_text>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.<jupyter_code>solution = problem.solve("single", "../../derivatives/hd_tdcs_simulation", model)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.015456989247311828, 'mean_word_length': 6.334975369458128, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '500304', 'license': 'MIT', 'n_tokens_mistral': 539, 'n_tokens_neox': 498, 'n_words': 138, 'path': 'code/hd_tdcs/hd_tdcs_simulation.ipynb', 'repo_name': 'CyclotronResearchCentre/shamo-tutorials', 'size': '1488'}