# CIBC:Documentation:SCIRun:Reference:SCIRun:BuildTDCSMatrix

## BuildTDCSMatrix

### Information

Package: SCIRun
Catagory: FiniteElements
Author(s): Moritz Dannhauer
Version: 4.7

### Description

The module BuildTDCSMatrix generates a matrix which formulates the forward problem of transcranial direct current stimulation (tDCS).

#### Detailed Description

The module has six inputs and one output. In order to formulate the tDCS forward problem the description of the FEM mesh, the associated FEM stiffness matrix, the definition of the injecting electrodes and surface impedance information are needed to perform this task.

All inputs can be generated by SCIRun, or created else where or loaded from Matlab files or the Matlab interface.

##### Inputs

1. FEM Stiffness Matrix: $S \in N \times N$, where N = number of nodes, which can be generated with the BuildFEMatrix module, the mesh (second input port) and conductivity information.

2. Tetrahedral Mesh Field:

3. Electrode Element definition Matrix: this column matrix $(E \times 1)$ maps electrode elements to the distinct electrodes that they belong to. Using a simple, artificial two electrode problem as an example, if electrode 1 has 5 elements and electrode 2 has 3 elements, the matrix (E = 8) would be:

$\begin{bmatrix} 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 1 \\ 1 \\ 1 \\ \end{bmatrix} $

4. Matrix Electrode Element Type: a column matrix $(E \times 1)$ which describes the mapping of each Electrode Element to a specific Element Type. Elements can be points (1), triangles (2) or tetrahedral elements (3). Continuing the sample problem, if electrode 1 contains tetrahedral elements and electrode 2 contains a set of points, the matrix (E = 8) would be:

$\begin{bmatrix} 3 \\ 3 \\ 3 \\ 3 \\ 3 \\ 1 \\ 1 \\ 1 \\ \end{bmatrix} $

5. Electrode Element Definition Matrix: this matrix $(E \times 4)$ has a fixed size which is independent of the Electrode Elements Types, and which describes the points that define (based on the mesh supplied to the module from the second input port) the Electrode element. Continuing the artificial sample problem, the matrix (E = 8) would be:

$\begin{bmatrix} 0 & 25 & 0 & 152 \\ 5 & 0 & 0 & 151 \\ 147 & 237 & 0 & 148 \\ 148 & 237 & 0 & 152 \\ 151 & 0 & 0 & 152 \\ 24 & 0 & 0 & 0 \\ 143 & 0 & 0 & 0 \\ 232 & 0 & 0 & 0 \\ \end{bmatrix} $

For last 3 lines only the first element is used, since it is defined as a point electrode. Therefore an arbitrary combination of electrode definitions can be used which should be part of of the input mesh.

6. Contact impedance Matrix: this column matrix $(E \times 1)$ describes the impedance of the electrodes to the surrounding material. For each electrode element a specific impedance can be used. Continuing the artificial sample problem, the matrix (E = 8) would be:

$\begin{bmatrix} 5 \\ 5 \\ 5 \\ 5 \\ 5 \\ 10 \\ 10 \\ 10 \\ \end{bmatrix} $

Hint: Use standard SI units for mesh and electrode definitions (i.e., meters (m)), stiffness matrix conductivity (S/m), contact impedance (Ohm).

##### Output

1. tDCS Forward Matrix

##### Computation

For the 2 electrode sample problem introduced in the previous section, the module generates the following matrices:

$tDCS = \begin{bmatrix} A* & B \\ B' & C \\ \end{bmatrix} $

$A* \in N \times N = S + A$

$B \in N \times 2$

$B' \in 2 \times N$

$C \in 2 \times 2$

$tDCS \in (N + 2) \times (N + 2)$

See this paper for more details.

The module checks the plausibility of the inputs, and looks to see if an reference node is set to 0 after output generation. In that case, an error message will be generated, and the tDCS matrix will not referenced. However, it also contains information how to set up a reference node.

After the tDCS matrix is generated, a linear equation solver (e.g. module: SolveLinearSystem) can be used to solve the unknown potentials u1 (at mesh nodes) for a given injected current pattern r2.

$tDCS * u = rhs$

$u = \begin{bmatrix} u1 & u2 \end{bmatrix}'$

The right hand side vector for the example could be:

$\begin{bmatrix} r1 & r2 \end{bmatrix}' \in (N + 2) \times 1$

$r1 = \begin{bmatrix} 0 & \cdots & 0 \end{bmatrix}' \in N \times 1$

$r2 = \begin{bmatrix} 1 & -1 \end{bmatrix}' \in 2 \times 1$

#### Summary

The very flexible module BuildTDCSMatrix computes the tDCS forward matrix using a serial algorithm.

### Recent Changes

Go back to Documentation:SCIRun:Reference:SCIRun