simnibs.simulation.tdcs_leadfield

simnibs.simulation.tdcs_leadfield(mesh, cond, electrode_surface, fn_hdf5, dataset, current=1.0, roi=None, post_pro=None, field='E', solver_options=None, n_workers=1, input_type='tag', weigh_by_area=True)

Simulates tDCS fields using Neumann boundary conditions and writes the output electric fields to an HDF5 file.

Parameters:
  • mesh (simnibs.msh.mesh_io.Msh) – Mesh file with geometry information

  • cond (simnibs.msh.mesh_io.ElementData) – An ElementData field with conductivity information

  • electrode_surface (list) – If input_type is “tag”, then this is a list of the tags of the electrode surfaces. If input_type is “nodes”, then this is a list (or list of lists) of nodes. The first electrode is used as a reference.

  • fn_hdf5 (str) – Name of hdf5 where simulations will be saved

  • dataset (str) – Name of dataset where data is to be saved

  • current (float | iterable) – Specifies the current (in ampere) to use in each simulation. If float, this current will be used in all simulations. If iterable (where the length of the iterable is number of electrodes minus one as the reference is set to zero), it explicitly specifies the current in each simulation. (Default = 1).

  • roi (list or None (optional)) – Regions of interest where the fields is to be saved. If set to None, will save the electric field in all tissues. Default: None

  • field ('E' or 'J' (optional)) – Which field to save (electric field E or current density J). Default: ‘E’

  • post_pro (callable (optional)) – callable f_post = post_pro(f), where f is an input field in the ROI and f_post is an Nx3 ndarray. The postprocessing result will be saved instead of the field

  • solver_options (str (optional)) – Options to be used by the solver. Default: Hypre solver

  • n_workers (int) – Number of workers to use

  • input_type ('tag' or "nodes" (optional)) – Whether electrode_surface refers to surface tags (default) or nodes.

  • weigh_by_area (bool) – Weigh current by node area. If input_type == “tag” this is ignored and area weighting is implied.

Returns:

Writes the field resulting from each simulation to a dataset called fn_dataset in an hdf5 file called fn_hdf5.

Return type:

None

Notes

Possible combinations/uses of electrode_surface and current when input_type=”nodes”.

  1. One node per electrode (weigh_by_area has no effect)

    tdcs_leadfield(…, el=[1,2,3,4], current=1., input_type=”nodes”, …) tdcs_leadfield(…, el=[1,2,3,4], current=[1.,2.,1.], input_type=”nodes”, …)

  2. Several nodes per electrode

Set same current for all electrodes (or one value per electrode) and weigh according to area so that the total current per electrode is equal to the input current

tdcs_leadfield(…, el=[[1,2,3],[4,5,6],[7,8,9]], current=1., input_type=”nodes”, …) tdcs_leadfield(…, el=[[1,2,3],[4,5,6],[7,8,9]], current=[1., 2.], input_type=”nodes”, …)

Set the weighting eplicitly by specifying the current per node for all electrodes (disable weigh_by_area)

tdcs_leadfield(…,

el = [[1,2,3],[4,5,6],[7,8,9]], current = [[0.1,0.2,0.7],[0.2,0.3,0.5]], input_type = “nodes”, weigh_by_area = False,

…)