Introduction

New developments in brain imaging technology have enabled substantial advances in our understanding of human brain function. In the last years, one of the brain imaging techniques that has attracted increasing interest in the neuroscientific community is electroencephalography (EEG). This technique permits studying neural dynamics with high temporal resolution, using electric potentials measured over the scalp. EEG has been widely used for basic and clinical neuroscience research. In most EEG studies, the analysis is conducted on task-induced or spontaneous signal modulations at the sensor level. In some studies, however, it is necessary to reconstruct active sources in the brain from EEG signals (Michel and Murray 2012). This “source localization” or electrical source imaging (ESI) step requires the integration of detailed information about the geometry and physical properties of the head tissues that are between neural sources and EEG sensors (Grech et al. 2008; Castaño-Candamil et al. 2015). In particular, ESI algorithms require as input a “leadfield” matrix expressing the relationship between dipolar currents in the brain and the corresponding electric potentials measured over the scalp (Sarvas 1987; Tadel et al. 2011; Salmelin and Baillet 2009; Vatta et al. 2010; Akalin Acar et al. 2016; Vorwerk et al. 2014). The leadfield matrix can be obtained by solving the quasi-static approximation of Maxwell’s equations for any given current density distribution (Clark and Plonsey 1968; Sarvas 1987). Simplified head models using spherical geometries were initially used. In this case, solutions for Maxwell’s equations can be calculated both numerically and analytically (Herrendorf et al. 2000; DeMunck 1988; Irimia and Bradshaw 2005).

Magnetic resonance (MR) and computed tomography (CT) are noninvasive imaging techniques that can provide detailed structural information. This can be used to build a more detailed and anatomically realistic head models. In particular, individual MR and CT images can be segmented into different tissue types, such as white and gray matter (WM/GM), cerebrospinal fluid (CSF), compact and spongy bone, and skin, among others. Recently, diffusion-weighted and diffusion-tensor imaging (DWI/DTI) has also been used to determine the anisotropy profile of brain structures based on the movement of water molecules (Le Bihan and Johansen-Berg 2012). DWI/DTI is particularly important for modelling anisotropic properties in the WM (Bashar et al. 2008). Whereas anisotropy in the head can be estimated across voxels by combining information from DWI/DTI, it is still an open issue how to extract local conductivity information for head tissues. A commonly used approach is to assign specific conductivity values to each segmented tissue (Michel and Murray 2012; Liu et al. 2017). It is worth noting that the accuracy of EEG source localization strongly relies on the precision of the conductivity values used for the different tissues in the head model (Irimia et al. 2013a, b).

Notably, the calculation of the leadfield matrix for realistic free-form head volumes is only possible by numerically solving Maxwell’s equations. To this end, different computational approaches have been proposed. The most commonly used are the boundary element methods (BEMs), primarily due to their low computational requirements. In BEMs, head compartments need to be nested and to have smooth boundaries. Note that conventional BEM head models are built with brain, skull, and scalp as major tissues, without distinguishing between GM and WM compartments. Additionally, the CSF is often not included, and the propagation of electric currents is assumed to be isotropic within any head tissue. These approximations limit the precision of head modelling using BEMs (Haueisen et al. 1997; Vorwerk et al. 2014).

For more accurate head modelling, it may be more appropriate to use other approaches that rely on realistically shaped head tissue geometry, as well as anisotropy. These techniques can be divided into three main categories: finite element methods (FEMs) (Schimpf et al. 2002; Wolters et al. 2006), finite difference methods (FDMs) (Hallez et al. 2005; Turovets et al. 2014) and finite volume methods (FVMs) (Cook and Koles 2006). FEMs are based on volumetric meshes (e.g., using tetrahedra), which can have arbitrary dimension. Their precision and computational demands can be adjusted by varying the mesh resolution (Vorwerk et al. 2017; Ziegler et al. 2014). In contrast to FEMs, FDMs and FVMs partition the head volume in a homogeneous voxel grid. Thus, a typical element in the FDM/FVM grid is surrounded by other elements that in general have anisotropic conductivity properties. According to the method of the fictitious domain (FD) (Turovets et al. 2014), extremely low conductivity values are assigned to regions outside the head, modelling the surrounding air, such that appropriate boundary conditions are implicitly set for the current flow. Notably, the number of unknowns in FEMs, FDMs and FVMs is extremely high, leading to large but sparse linear equation systems. As such, iterative solvers need to be used to solve Maxwell’s equations. Most popular iterative solvers include the successive over-relaxation (SOR), conjugate gradient method, algebraic multigrid, and biconjugate gradient (BiCG) methods (Hallez et al. 2005).

A fundamental feature of FDMs is its straightforward integration with structural imaging data (CT/MR and DWI/DTI). Using FDMs, it would be possible to model anisotropy and across-voxel differences in conductivity without relying on any meshing step. However, no such FDM solution is currently available. In this study, our aim is to develop a computationally efficient FDM that can flexibly integrate across-voxel conductivity and anisotropy information.

Methods

Theory and Method Description

EEG Forward Problem

The EEG forward problem entails the calculation of the electric potentials \(\phi \in {\mathbb{R}}\) on the scalp surface \({\Gamma _\Omega } \in {{\mathbb{R}}^2}\) for each single source position within the head volume \(\Omega \in {{\mathbb{R}}^3}\) (Panizo et al. 1977). Since the EEG spectrum largely contains frequencies below 100 Hz, the quasi-static approximation of Maxwell’s equations is used. Mathematically, the solution of the forward problem requires the solution of the Poisson equation:

$$\nabla \cdot \left( {\sigma (x,y,z)\nabla \phi (x,y,z)} \right)= - \nabla \cdot J({x_{{\iota _f}}},{y_{{\iota _f}}},{z_{{\iota _f}}})\;{\text{on}}\;(x,y,z) \in \Omega$$
(1)

where \(J \in {\mathbb{R}}\) is the electric current density in the position \(({x_{{\iota _f}}},{y_{{\iota _f}}},{z_{{\iota _f}}}) \in \Omega\), \((x,y,z) \in \Omega\) are voxel positions within the head, and \(\sigma (x,y,z) \in {{\mathbb{R}}^{3 \times 3}}\) is the local conductivity in a inhomogeneous anisotropic medium.

The solution of Eq. (1) can be found by imposing boundary conditions between compartments having different conductivity (Saleheen and Ng 1997). Broadly speaking, two conditions hold at the interface between two compartments. The first one relates to the inability to accumulate charge at the interface \({\Gamma _{{\sigma _1},{\sigma _2}}}\), which implies that all the charge leaving one compartment must enter the second compartment (Neumann statement):

$$({\sigma _1}\nabla {\phi _1}) \cdot {\widehat {e}_n}=({\sigma _2}\nabla {\phi _2}) \cdot {\widehat {e}_n}$$
(2)

where \({\sigma _1}\) and \({\sigma _2}\) are the conductivity of the first and second compartment, respectively, and \({\widehat {e}_n}\) is a vector normal to the interface surface \(\Gamma\). As a special case, no current can flow outside the head volume due to the very low conductivity of the air. Therefore, the current density at the head surface boundary (scalp) \({\Gamma _\Omega }\) becomes:

$${\left. {(\sigma \nabla \phi ) \cdot {{\widehat {e}}_n}} \right|_{{\Gamma _\Omega }}}=0$$
(3)

The second condition is only valid for interfaces that are not connected with air. By crossing an interface \({\Gamma _{{\sigma _1},{\sigma _2}}}\) the potential cannot have discontinuities (Dirichlet boundary condition):

$${\phi _1}={\phi _2}$$
(4)

Anisotropic FDM (AFDM)

Considering an anisotropic symmetric conductivity tensor \(\varvec{\sigma} \in {{\mathbb{R}}^{3 \times 3}}\), Eq. (1) can be rewritten as follows (Sarvas 1987):

$${\sigma _{11}}\frac{{{\partial ^2}\phi }}{{\partial {x^2}}}+{\sigma _{22}}\frac{{{\partial ^2}\phi }}{{\partial {y^2}}}+{\sigma _{33}}\frac{{{\partial ^2}\phi }}{{\partial {z^2}}}+2\left( {{\sigma _{12}}\frac{{{\partial ^2}\phi }}{{\partial x\partial y}}+{\sigma _{13}}\frac{{{\partial ^2}\phi }}{{\partial x\partial z}}+{\sigma _{23}}\frac{{{\partial ^2}\phi }}{{\partial y\partial z}}} \right)+\left( {\frac{{\partial {\sigma _{11}}}}{{\partial x}}+\frac{{\partial {\sigma _{12}}}}{{\partial y}}+\frac{{\partial {\sigma _{13}}}}{{\partial z}}} \right)\frac{{\partial \phi }}{{\partial x}}+\left( {\frac{{\partial {\sigma _{12}}}}{{\partial x}}+\frac{{\partial {\sigma _{22}}}}{{\partial y}}+\frac{{\partial {\sigma _{23}}}}{{\partial z}}} \right)\frac{{\partial \phi }}{{\partial y}}+\left( {\frac{{\partial {\sigma _{13}}}}{{\partial x}}+\frac{{\partial {\sigma _{23}}}}{{\partial y}}+\frac{{\partial {\sigma _{33}}}}{{\partial z}}} \right)\frac{{\partial \phi }}{{\partial z}}={\iota _f}({x_{{\iota _f}}},{y_{{\iota _f}}},{z_{{\iota _f}}})$$
(5)

where \({\sigma _{ij}}\) are the elements of the conductivity tensor \(\varvec{\sigma}\), and \({\iota _f}({x_{{\iota _f}}},{y_{{\iota _f}}},{z_{{\iota _f}}})\) is a current dipole in the head volume \(\Omega\). The current source density in Eq. (1) can be defined as a function \({\iota _f}({x_{{\iota _f}}},{y_{{\iota _f}}},{z_{{\iota _f}}})\), representing a current dipole in the position \(({x_{{\iota _f}}},{y_{{\iota _f}}},{z_{{\iota _f}}}) \in \Omega\) (Hallez et al. 2007). For the solution of Poisson equation, we use the approach introduced in Hallez et al. (2005) and named finite difference method in anisotropic media (AFDM). Following the AFDM approach, Eq. (5) is discretized in a 18-point stencil with 8 voxels sharing the same vertex \(\phi _{0}^{j}\). This choice leads to a linear equation for the vertex \(j\) in the stencil \({S_j}\) around \(\phi _{0}^{j}\) (see Fig. 1) as follows:

$$\sum\limits_{{i \in {S_j}}} {\alpha _{i}^{j}\phi _{i}^{j}} - \left( {\sum\limits_{{i \in {S_j}}} {\alpha _{i}^{j}} } \right)\phi _{0}^{j}={\iota _f}({x_{{\iota _f}}},{y_{{\iota _f}}},{z_{{\iota _f}}})$$
(6)

where \(\phi _{i}^{j} \in {\mathbb{R}}\) is the scalar-valued potential at the \(i\)-th neighbour voxel of the \(j\)-th node in the stencil \({S_j}\). \({\iota _f} \in {\mathbb{R}}\) is the dipole current magnitude, and \(\alpha _{i}^{j} \in {\mathbb{R}}\) are the FDM coefficients (Saleheen and Ng 1998), which depend on the conductivity tensor \(\varvec{\sigma}\) and the internode distance \(h \in {\mathbb{R}}\) (Fig. 1). Additionally, a transition layer is included, which removes the singularities in the spatial derivatives between two compartments with different conductivity (Saleheen and Ng 1998). This layer acts as a buffer that allows a smooth potential transition from one medium with conductivity \({\sigma _1}\) to another with conductivity \({\sigma _2}\).

Fig. 1
figure 1

AFDM stencil structure. The 18-point stencil for the AFDM Saleheen formulation is shown, in which each node is surrounded by eight voxels with anisotropic, homogeneous conductivity properties

In all cases under consideration, the finite difference equations for the stencil (Fig. 1) can be expressed in a linear equation system as follows:

$${\varvec{A}}\varvec{\phi}={\varvec{\iota}_f}$$
(7)

where \(\phi \in {{\mathbb{R}}^N}\) is a vector with \(N\) unknown potentials, \({\varvec{A}} \in {{\mathbb{R}}^{N \times N}}\) is a non-singular coefficient matrix and \({\varvec{\iota}_f} \in {{\mathbb{R}}^N}\) is a right hand side vector representing single dipole sources. Thus, the coefficient matrix \({\varvec{A}}\) is square, symmetrical and sparse, with only 19 non zero entries per row.

Coefficient Matrix Formulation

A stationary solver with SOR is typically used in FDMs (Hallez et al. 2005). With SOR, the information about the position of the 19 non-zero coefficients in the matrix \({\varvec{A}}\) is not used, because the coefficients in each row are summed. However, the matrix \({\varvec{A}}\) must be properly defined to use more efficient (non-stationary) solvers for the linear system. To address this problem, it has been suggested to define a FD as a full cubic or cuboidal space, in which the voxels around the head have very low conductivity (Turovets et al. 2008). The presence of these additional voxels increases the computational complexity and may also reduce the reliability of the estimated leadfield matrix due to propagation errors in the linear equation system. In this study, we propose an approach for removing the voxels around the head from the linear equation system, and for building a coefficient matrix that only contains non-zero potentials (Fig. 2). To this end, an 18-node-three data structure is built, mapping the three-dimensional node positions in the coefficient matrix.

Fig. 2
figure 2

Original-domain (non-zero) versus fictitious-domain. In the original domain, the voxels outside the head (white dots) are constrained to have zero potential and are not included in the FDM solution. The potentials for the FD are regularly distributed in a domain spanning the whole MR image

The volume conductor \(\Omega\) is discretized in regular \(({s_x},{s_y},{s_z}) \in {\mathbb{Z}}\) partitions in \(x\), \(y\) and \(z\), directions, with resolution \({h_x}\), \({h_y}\) and \({h_z}\) respectively. In the FD, the coefficients \({c_{l,m}} \in {\mathbb{R}}\) in Eq. (6) are regularly ordered in a rectangular box, so that it is possible to write \({c_{l,m}}= - \sum\nolimits_{{i \in {S_j}}} {\alpha _{m}^{l}}\), \(\forall l=m\); \({c_{l,m}}=\alpha _{m}^{l}\), \(\forall (l \ne m) \in {S_l}\) and \({c_{l,m}}=0\), \(\forall l,m \notin {S_l}\) where, \(l,m=0,1,2, \cdots ,N - 1 \in {\mathbb{Z}}\). In the original domain (OD), we define the non-zero coefficients \({c_{{l_N},{m_N}}}\), \(\forall {l_r}(x_{i}^{r},y_{i}^{r},z_{i}^{r}) \ne 0\) as follows:

$${c_{{l_r},{m_r}}}=\left\{ {\begin{array}{*{20}{l}} { - \sum\limits_{{{m_r} \in {S_r}}}^{{18}} {\alpha _{{{m_r}}}^{{{l_r}}},} }&{\forall {l_r}={m_r}} \\ {\alpha _{{{m_r}}}^{{{l_r}}},}&{\forall ({l_r} \ne {m_r}) \in {S_r}} \\ 0&{\forall lr=0} \end{array}} \right.$$
(8)

with \({l_r},{m_r}=0,1,2, \ldots ,{N_Z} - 1\), where NZ is the number on non-zero valued elements.

In both cases under consideration, every row corresponds to a neighbour \({S_j}\), and each column is \(m\)-th position of the linear expansion over the spatial positions \((x_{i}^{j},y_{i}^{j},z_{i}^{j})\) for the coefficient matrix \({\varvec{A}}\).

Numerical Solver and Preconditioning

Several iterative methods have been developed for solving linear equation systems. Yet, the choice of the solver depends mainly on two considerations: the convergence speed to achieve a given relative minimum residual and the computational complexity of each iteration. Notably, the numerical properties of the coefficient matrix highly influence the convergence rate of any solver. Indeed, the more ill-conditioned the system matrix, the slower the convergence of the gradient descent method. The condition number of \({\varvec{A}}\), defined as \(C=\left\| {\varvec{A}} \right\|\left\| {{{\varvec{A}}^{ - 1}}} \right\|\), generally measures the sensitivity of a linear equation system solution to variations in the input data. As such, it can be used to estimate the convergence of an iterative solver: the larger the conditional number, the slower the solver is expected to reach a desired minimal residual. In this regard, we used preconditioning to reduce the conditional number \(C \in {\mathbb{R}}\), selecting an adequate non-singular matrix \({\varvec{M}}\) such that the condition number of the product \({{\varvec{M}}^{ - 1}}{\varvec{A}}\) remains low. Therefore, Eq. (7) can be rewritten as:

$${{\varvec{M}}^{- 1}}{\varvec{A}}\varvec{\phi}={{\varvec{M}}^{- 1}}{\varvec{\iota}_f}$$
(9)

where \({\varvec{M}} \in {{\mathbb{R}}^{N \times N}}\) is the so-called preconditioner for the system matrix \({\varvec{A}} \in {{\mathbb{R}}^{N \times N}}\), \(\varvec{\phi} \in {{\mathbb{R}}^N}\) is the vector of potentials, and \({\varvec{\iota}_f} \in {{\mathbb{R}}^N}\) is the righthand side of the linear equation system (excitation). To properly balance convergence speed and estimation residuals in our proposed FDM approach, we combined a BiCG-stabilized solver with an incomplete LU (iLU) preconditioner (Cuartas et al. 2015).

Reciprocity for the AFDM Method

The solution of the forward problem, if the same volumetric space defined by MRI data is used, may even have millions of unknowns. However, distributed source localization using EEG is usually performed at lower spatial resolution, such that the source space is modelled using a few thousand dipoles (Grech et al. 2008). Theoretically speaking, the forward problem should be solved for each of these dipoles. Importantly, it is possible to perform calculations for all pairs of electrodes over the scalp rather than for all dipole positions by using the reciprocity theorem (Vanrumste et al. 2001). This theorem states that:

$${U_{AB}}{I_{AB}}={V_{rx}}{I_{rx}}$$
(10)

where \({U_{AB}}\) is the so-called leadpair potential between two scalp electrodes (\({E_A}\) and \({E_B}\)) produced for a single dipole \({I_{rx}}\) in the brain. In turn, \({I_{AB}}\) is the current flowing between the same pair of scalp electrodes, produced for the potential \({V_{rx}}\) in the brain. The reciprocity theorem is widely used in the EEG forward methods, and also in our FDM. This permits indeed to reduce the number of forward calculations to \(N - 1\), where \(N\) is the number of electrodes. Since our FDM also incorporates anisotropy information, we will refer to it as anisotropic finite difference reciprocity method-non zero (AFDRM-NZ).

Method Validation

Spherical Model

For the numerical validation of AFDRM-NZ, we generated a spherical head model with six concentric layers with the following radii (measured in [mm]): skin = 0.092, skull = 0.084, CSF = 0.076, brain gray matter (GM) = 0.068, brain white matter (WM) = 0.050, and thalamic inner sphere (TL) = 0.020 (Fig. 3). We fixed the conductivity values [S/m] based on the study by (Vorwerk et al. 2014): skin (scalp) = 0.43, skull = 0.0105, CSF = 1.79, GM = 0.33, WM = 0.14, and TL = 0.33. The WM was modelled as either isotropic or anisotropic. In the latter case, conductivity of WM voxels was set to have 9:1 radial/tangential ratio respectively (Hallez et al. 2005). We positioned 112 electrodes in 6 geodesic rings evenly distributed over the scalp surface (Turovets et al. 2014). For the source space, we randomly selected 300 sources within the GM (superficial) and the TL (deep) regions, with radial direction and variable distance from the electrodes (Stenroos and Sarvas 2012).

Fig. 3
figure 3

Spherical head model. We built a 6-layer spherical head model, to be used as a volume conductor for both numerical and analytical solutions. This model includes anisotropy in the WM and also an inner thalamic area to represent deep sources surrounded by anisotropic WM tissue

We tested the performance of OD–BiCG–iLU, the BiCG–iLU solver for the OD integrated into AFDRM-NZ, against that of other FDM solvers previously investigated by (Cuartas et al. 2015). These solvers are: OD–SOR, FD–SOR, OD–BiCG–NP, FD–BiCG–NP, OD–BiCG–LU, FD–BiCG–iLU, FD BiCG Fourier–Jacobi. Calculations were stopped either after 1000 iterations or when the relative residual was below 10−13. The computation time was measured using a computer with Windows operating system, a 2.7 GHz Intel Xeon processor, and 32 GB RAM. We also compared the conditional number obtained with the BiCG–iLU solver for the original and the FD, respectively.

To quantify the precision of the leadfield matrix produced by AFDRM-NZ, we compared it with the one obtained using an analytical solution (DeMunck 1988) using two different measures: the logarithmic magnitude (lnMAG) (Güllmar et al. 2010) and the relative difference measure (RDM) (Meijs et al. 1989). These were defined as follows:

$$lnMAG({L_1},{L_2})=\ln \left( {\frac{{\left\| {{L_1}} \right\|}}{{\left\| {{L_2}} \right\|}}} \right)$$
(11)
$$RDM({L_1},{L_2})=\left\| {\frac{{{L_2}}}{{\left\| {{L_2}} \right\|}} - \frac{{{L_1}}}{{\left\| {{L_1}} \right\|}}} \right\|$$
(12)

where \(L\) denotes a leadfield matrix, the norm is the \({l^2}\) norm and subscripts 1 and 2 correspond to the reference and test head models, respectively. To better assess the performance of AFDRM-NZ, we also created a leadfield matrix using a 9-layer isotropic FEM with hexahedral meshing (Vorwerk 2018) and 3-layer BEM with scalp, skull and brain compartments (Oostenveld et al. 2011). Both FEM and BEM are integrated in the FieldTrip toolbox (http://www.fieldtriptoolbox.org). We calculated MAG, RDM and computation time for FEM and BEM, as previously done for AFDRM-NZ.

Realistic Head Model

We also used AFDRM-NZ to model the head of a real experimental subject. To this end, we acquired structural MR images using a General Electric Sigma HDxt 3.0 T MR scanner with a body coil for proton excitation and an 8-channel head coil for signal detection. We used a 3DT1w Spoiled Gradient Recalled (SPGR) sequence with TR = 8.7 ms, TE = 3.2 ms, TI = 400 ms, NEX = 1, FOV = 260 mm, matrix = 320 × 160, resolution 1 × 1 × 1 mm, flip angle = 12°; a diffusion weighted imaging (DWI) sequence with TR = 9200 ms, TE = 83.8 ms, TI = 0 ms, NEX = 1, acquisition FOV = 240 mm, matrix = 100 × 100, flip angle = 90°, directions = 45, thickness = 2 mm; an iterative decomposition of water and fat with echo asymmetry and least-squares estimation (IDEAL) T2 sequence with TR = 3000 ms, TE = 81.9 ms, NEX = 6, FOV = 260 mm, matrix 320 × 160, flip angle 90°; a time of flight (TOF) sequence consisting of 8 volumes with 6 slices overlap with TR = 20 ms, TE = 2.1 ms, NEX = 1, FOV = 224 mm, matrix 224 × 224, flip angle 15°.

DWI, IDEAL, and TOF data were initially aligned to the T1-w image with a similarity-based affine registration procedure to correct for image orientation differences and geometrical distortions. DWI data were processed to calculate diffusion tensors that were resampled to have the same resolution as the T1-w data. Afterward, a segmentation of the T1w image in 9 compartments was performed with Freesurfer (https://surfer.nmr.mgh.harvard.edu), integrating information also from IDEAL and TOF images. Conductivity values [S/m] were set as follows: skin = 0.43, muscle = 0.355, fat = 0.0573, eyeballs = 1.55, vessels = 0.28, skull = 0.0105, CSF = 1.79, GM = 0.33, WM = 0.14 (with 9:1 radial/tangential anisotropic ratio). A 5-layer segmentation was derived from the 9-layer segmentation, by incorporating muscle, fat, eyeballs, vessels within the skin compartment. Finally, a 128-channel EEG montage was spatially aligned to the skin surface (see Fig. 4).

Fig. 4
figure 4

Realistic head model. The segmented MR images used for the AFDRM-NZ validation are shown, along with a legend indicating the identified compartments. A 128-channel EEG montage is aligned over the outer compartment (skin), for the calculation of a lead-field solution using AFDRM-NZ

As a final test, we analyzed the dipole estimation errors due to not include multiple tissue compartments with varying conductivities in the realistic forward modeling. Within this framework, pairwise dipole parameters \(\left( {r,d} \right)\) for a given source configuration were estimated by calculating the electrode potentials \({v_{test}} \in {\mathbb{R}}\) that minimize the following equation (Hallez et al. 2009):

$$(r,d)=\mathop {\hbox{min} }\limits_{{r,d}} \left\{ {\frac{{{{\left\| {{v_{ref}}\left( {\bar {r},\bar {d}} \right) - {v_{test}}(r,d)} \right\|}^2}}}{{{{\left\| {{v_{ref}}\left( {\bar {r},\bar {d}} \right)} \right\|}^2}}}+c(r)} \right\}$$
(13)

where \({v_{ref}}\left( {\overline {r} ,\;\overline {d} } \right)\) are the electrode potentials of the reference model and \({v_{test}}(r,d)\) are the those estimated in the test model. The term \(c(r)\) is a penalization parameter that is set to be very large for dipole positions outside the GM. The notation \(\left\| \cdot \right\|\) stands for the Euclidean norm.

The dipole localization error (DLE) for a reference \(\left( {\overline {r} ,\;\overline {d} } \right)\) and a test \((r,d)\) source configuration was computed as the Euclidean norm of their difference:

$$DLE=\left\| {r - \overline {r} } \right\|$$
(14)

We used the DLE to examine the importance of correctly modelling the conductivity of the different tissues for the calculation of an accurate leadfield matrix. To this end, we used the parametric inverse solution with the anisotropic 9-layer model as the reference model, and compared it with the solution obtained by using the anisotropic 5-layer model.

Results

Computational Performance of FDM Solvers

We tested the computational performance of several linear solvers for the OD and the FD. Our results showed that the stationary solver SOR had the worse convergence rate and a final relative error larger than 10−8 even after 1000 iterations. Generally speaking, the use of a suitable preconditioning substantially increased the convergence rate of the BiCG solvers and led to lower residual errors, both for the original and the FD. The most efficient solver in terms of convergence rate was the BiCG OD–LU, which reached a target residual value of 10−13 just after two iterations. Additionally, the version with Fourier–Jacobi preconditioning (FD–FJ) had a high convergence rate. However, this solver initially had a high residual error value (around 101), and the minimum residual error reached was around 10−10. Only the OD–LU and OD–iLU reached the target residual error of 10−13 (Fig. 5).

Fig. 5
figure 5

Comparison of different solvers with respect to convergence rate and minimal residual. The dashed red line stands indicate the target minimal residual, equal to 10−13. OD original domain, FD fictitious domain, SOR successive over-relaxation method, BiCG biconjugate gradient stabilized method, NP no preconditioning, LU factorization preconditioning, iLU incomplete LU preconditioning, FJ Fourier Jacobi preconditioning

We also examined the computational time for the different solver implementations under consideration (Table 1). As expected, the LU preconditioning required considerably more computational time than the other preconditioners (Fourier–Jacobi and iLU). Overall, the original-domain BiCG–iLU yielded the lowest total computation time. The FD with Fourier–Jacobi preconditioning was also computationally efficient, but relatively slower than OD–iLU.

Table 1 Accuracy and computational time (in seconds) for different FDM solver implementations

Validation of AFDRM-NZ Using an Analytical Solution

We assessed the numerical solution obtained using AFDRM-NZ for the 6-layer spherical head model against the analytical solution (DeMunck 1988). We observed a very close correspondence between the leadfield matrices, in both isotropic and anisotropic conditions.

We calculated MAG and RDM measures to quantify this correspondence. The results of this analysis confirmed the reliability of the solution obtained with AFDRM-NZ for all dipole positions and orientations in GM and TL regions. In contrast, BEM and FEM had an altered distribution of electric potentials across recording channels (Figs. 6, 7). Overall, we found the AFDRM-NZ to have lower computation time and more efficient memory use than FEM, but not BEM (Table 2).

Fig. 6
figure 6

Correspondence between electrode potentials for AFDRM-NZ, BEM, FEM and analytical (DeMunck) solutions, employing a single dipole in the GM with normal orientation with respect to the spherical surface. Potentials were normalized to facilitate visual comparisons between methods

Fig. 7
figure 7

Quantitative comparison between numerical and analytical solutions. For AFDRM-NZ and FEM, the distribution of lnMAG and RDM values is shown using box plots. We compared the isotropic analytical solution against isotropic ANFDRM-NZ and FEM. Then, we compared the anisotropic analytical solution against the isotropic FEM and the anisotropic AFDRM-NZ

Table 2 Analysis of computational performance for AFDRM-NZ, FEM, and BEM, assessed on the creation of a leadfield matrix for the spherical head model

Realistic Head Modelling with AFDRM-NZ

As a last validation step, we used AFDRM-NZ to create anisotropic realistic head models. First of all, we measured the computational time required for the calculation of a single lead-pair, which was 279.31 s for a fully isotropic model and 347.55 s when anisotropy information was included.

To qualitatively appreciate the impact of modelling WM anisotropy, we then examined the equipotential lines (forward potentials) for a single dipole source laying in the GM, with normal orientation with respect to the cortical surface. When anisotropy information was not used, equipotential lines were smooth and crossed the boundaries between head tissues with minor distortion effects (Fig. 8). In the anisotropic case, instead, the lines tended to locally align with the major white matter tracts.

Fig. 8
figure 8

Equipotential lines for a single dipole with isotropic and anisotropic WM conductivity, respectively. The current distribution, which was calculated for a 5-layer realistic head model, is shown in sagittal and coronal sections

Finally, we examined the DLE when using the 5-layer head model against the more precise 9-layer model. The results of this analysis revealed that localization errors associated with a less precise definition of head tissues could lead to large localization errors, being up to 2 cm in deeper brain regions (Fig. 9).

Fig. 9
figure 9

Spatial distribution of dipole localization errors for a simplified 5-layer head model, as compared to a 9-layer head model

Discussion

In this study, we have introduced a novel finite-difference method (AFDRM-NZ) for solving the forward problem in EEG source analysis. The electromagnetic field solver integrated in AFDRM-NZ has superior computational performance and reliability compared with alternative finite-difference solvers. Most importantly, AFDRM-NZ is designed to flexibly incorporate whole-brain conductivity information without head compartment tessellations, and can therefore optimally integrate information from structural MR imaging. Furthermore, our FDM method is intrinsically built to consider conductivity anisotropy, which is important to ensure correct modelling of current flow in the head. In the next section, we will more extensively discuss the aspects highlighted here above.

Computational Performance

AFDRM-NZ is based on the use of an iLU preconditioner and BiCG-stabilized solver, in combination with the Saleheen coefficients for FDM computations in the original-domain (non-zero). These technological solutions were specifically conceived to achieve very high computational performance, for a standard level of reconstruction error. First of all, our results show a sharp reduction of computational times of the BiCG-stabilized solver with iLU preconditioning against the commonly used SOR solver (Hallez et al. 2005) (Fig. 5). The use of the Saleheen coefficients in the coefficient matrix \({\varvec{A}}\), in combination with the iLU preconditioner, strongly increased the convergence rate and the numerical smoothness of the BiCG solver, such that very small residual errors could be reached (Table 1). Importantly, the original-domain (non-zero) solution permitted a reduction in the computational complexity of the preconditioning by about three times with respect to the FD solution (Turovets et al. 2014). This is because the voxels surrounding the head, which are assumed to have zero potential, are not included in the linear equation system for FDM.

It is not straightforward to compare AFDRM-NZ with a non-FDM solution, since the use of different software implementations and different input parameters may strongly drive the results. When we examined the computational efficiency of AFDRM-NZ with respect to FEM and BEM solutions incorporated into FieldTrip, we found that our method requires less allocated memory to be allocated than FEM, and also has shorter computation times. On the other hand, by using BEM, we generated a leadfield matrix in shorter times and using less memory (Table 2). It should be noted that these comparisons in terms of memory and computation times were conducted without considering differences in reconstruction errors across methods.

Reliability of the Leadfield Matrix Solution

The validation conducted using a spherical head model revealed a high correspondence between the potentials calculated using AFDRM-NZ and the analytic approach (Fig. 6). This finding was corroborated by the fact that lnMAG and RDM metrics had a median value close to zero at a very low dispersion (Fig. 7). In the realistic head model, we observed the equipotential lines to show a smooth transition at the interface between different conductivity tissues in the brain (Fig. 8), following the general Neumann boundary condition. When the WM was modelled as an anisotropic medium, the equipotential lines were qualitatively different with respect when conductivity in the WM was considered to be isotropic. In particular, the equipotential lines tended to locally align to WM tracts (Wolters et al. 2006; Turovets et al. 2014; Hallez et al. 2009).

Impact on Electrical Source Imaging

Besides the computational efficiency of AFDRM-NZ, its usability and potential impact for ESI should also be considered. The AFDRM-NZ solution was indeed developed to perfectly integrate with structural imaging data available from MRI, which is defined in a homogeneous volumetric space. First of all, anisotropy information can be extracted from diffusion MR imaging data and directly provided in the form of a diffusion tensor to AFDRM-NZ. A classical approach for the incorporation of conductivity information, which is used in FDMs but also BEMs and FEMs, relies on the segmentation of T1-weighted MR images in multiple head compartments. A conductivity value for each compartment is either extracted from the literature or non-invasively estimated using electrical impedance tomography. It has been suggested that simultaneous EEG/MEG measurements can be used to calibrate the conductivity values, aiming at maximizing the correspondence between source localizations from EEG and MEG data, respectively (Aydin et al. 2014). Another emerging approach that is attracting increasing interest in the brain imaging community is the use of MR imaging for low-frequency conductivity mapping (Michel et al. 2016). This may permit to obtain volumetric images of head conductivity, which is particularly important in the case of patient populations. AFDRM-NZ is the first head modelling method that can take advantage of this new development in the field of MR imaging. Accordingly, the use of AFDRM-NZ in combination with MR conductivity and diffusion images may yield superior source localization precision for EEG data collected not only in healthy volunteers but also neurological and psychiatric patients.

Limitations and Future Directions

AFDRM-NZ has been developed to ensure maximum flexibility of use, as well as high computational speed. However, even though AFDRM-NZ is relatively faster than several other FDM implementations, it overall requires relatively large computation time. From this standpoint, future efforts may be dedicated to an implementation of AFDRM-NZ that has parallel processing capabilities. If at least as many processing cores are available as the number of EEG electrodes, full parallelization can in principle be achieved, bringing a full AFDRM-NZ calculation in less than 5 min.

Conclusion

We have introduced AFDRM-NZ, a computationally-efficient FDM that can flexibly integrate across-voxel conductivity and anisotropy information to solve the EEG forward problem. Our results clearly show that AFDRM-NZ can contribute to more precise head modelling, which is essential for using EEG as a brain imaging tool (Michel and Murray 2012). In future studies, AFDRM-NZ could also be employed for studying the effects of conductivity uncertainty on source localization accuracy (Irimia et al. 2013a, b), and for the modelling of currents injected in the brain by means of transcranial current stimulation (Truong et al. 2013).