Abstract
Research in the area of transcranial electrical stimulation (TES) often relies on computational models of current flow in the brain. Models are built based on the magnetic resonance images (MRI) of the human head to capture detailed individual anatomy. To simulate current flow on an individual, the subject’s MRI is segmented, virtual electrodes are placed on this anatomical model, the volume is tessellated into a mesh, and a finite element model (FEM) is solved numerically to estimate the current flow. Various software tools are available for each step, as well as processing pipelines that connect these tools for automated or semi-automated processing. The goal of the present tool – ROAST – is to provide an end-to-end pipeline that can automatically process individual heads with realistic volumetric anatomy leveraging open-source software and custom scripts to improve segmentation and execute electrode placement. The electric field estimated with the open-source tools used by ROAST differ little from the results obtained with commercial meshing and FEM solving software. We also do not find large differences between the various automated segmentation methods used by ROAST and SimNIBS, a well-established open-source modeling pipeline. However, we do find large differences when volumetric segmentation are converted into surfaces that are used in SimNIBS to generate volumetric meshes. Evaluation on intracranial recordings from human subjects suggests that ROAST outperforms newer versions of SimNIBS in predicting field distribution and magnitudes, but that an older version of SimNIBS performs similarly. We hope that the detailed comparisons presented here of various choices in this modeling pipeline can provide guidance for future tool development. We release ROAST as an open-source, easy-to-install and fully-automated pipeline for individualized TES modeling at https://www.parralab.org/roast/.
1. Introduction
Models of current flow in the brain are important in research related to transcranial electrical stimulation (TES) as well as electroencephalography (EEG). TES modalities include trancranial direct current and alternating current stimulation (tDCS and tACS), which are generally limited to weak currents of no more than 2 mA. But TES also includes electroconvulsive therapy (ECT), which can go up to 800 mA (Guleyupoglu et al., 2013). In TES currents are applied to the scalp and modeling aims to determine which brain areas are stimulated (Datta et al., 2009; Lee et al., 2012), or where one should place electrodes to “target” a specific brain area (Dmochowski et al., 2011). In the case of EEG, currents generated by the brain are measured as voltage fluctuations on the scalp, and the objective of modeling is to determine the spatial origin of these brain currents. For this “source localization” in EEG (Haufe et al., 2011), one requires the identical current-flow models as for targeting TES (Dmochowski et al., 2017).
A multitude of current-flow models have been developed over the years with increasing level of detail (Rush and Driscoll, 1969; Ferdjallah et al., 1996; Stecker, 2005; Miranda et al., 2006; Datta et al., 2008; Dmochowski et al., 2012; Wagner et al., 2004). Starting in 2009 these models have been built based on individual head anatomy as captured with magnetic resonance imaging (MRI), e.g. with a T1-weighted image (Datta et al., 2009; Sadleir et al., 2010; Parazzini et al., 2011; Datta et al., 2012; Minhas et al., 2012; Datta et al., 2010; Wagner et al., 2007; Datta et al., 2011; Opitz et al., 2015). Today, the major steps for this modeling process include segmenting the MRI into different tissue compartments, assigning conductivity to each compartment, placing virtual electrodes on the model, tessellating this volumetric anatomy into a 3D mesh, and numerically solving the Laplace equation for the voltage distribution on this finite element model (FEM) (Figure 1).
Various software tools are available to execute each of these steps. For example, SPM (Statistical Parametric Mapping, Friston (2007)), FSL (FMRIB Software Library, Smith (2002); Smith et al. (2004)) and FreeSurfer (Dale et al., 1999; Fischl et al., 1999) can all generate segmentations for the brain and head, with each one having different pros and cons (for a review on these segmentation tools, see e.g. Huang and Parra (2015)). A finite element mesh can be generated using open-source tools (e.g. iso2mesh (Fang and Boas, 2009), Gmsh (Geuzaine and Remacle, 2009)) or commercial software (e.g. ScanIP (Simpleware Ltd, Exeter, UK), Mimics (Materialise NV, Leuven, Belgium)). The same is true for FEM solvers (open-source: getFEM++ (Renard and Pommier, 2010), getDP (Dular et al., 1998); commercial: Abaqus (SIMULIA, Providence, RI), COMSOL Multiphysics (COMSOL Inc., Burlington, MA)). SciRun is another open-source tool that can generate meshes and solve the FEM (Weinstein et al., 1998; Fuchs et al., 1998). Given this great variety and complexity, there is a need to automate these tools into a complete and easy-to-use processing pipeline. Existing pipelines are either not fully automated (e.g. NFT (Acar and Makeig, 2010)) or difficult to use (e.g. SciRun (Dannhauer et al., 2012)). Notable in terms of ease of use (if not of installation) is SimNIBS (Windhoff et al., 2011; Thielscher et al., 2015; Saturnino et al., 2015), which integrates FreeSurfer, FSL, Gmsh and getDP to provide a complete end-to-end solution. In the TES modeling literature, volumetric finite element models are preferred over surface-based boundary element methods (BEM) that are more common for EEG modeling (e.g. Fuchs et al., 1998). While a BEM can capture the detailed gyral/sulcal surfaces, it has limited abilities to represent the anatomical morphology. For instance, boundary surfaces between tissues need to be entirely contained within one another, which makes it difficult to implement anatomical details, such as the optic foramen, which is a highly conducting conduit into the skull. Moreover, generating surface segmentations for BEM (Dale et al., 1999) is computationally demanding, compared to volumetric segmentation algorithm based on probability inferences (Ashburner and Friston, 2005). Recently SimNIBS V2.1 was released (Nielsen et al., 2018) which incorporates the volumetric segmentation approach of SPM. This greatly reduces the computation time for segmentation from ~10 hours to 40 minutes. However, during post-processing of SPM-generated segmentation, SimNIBS still converts volumetric segmentation into surfaces, which limits the flexibility of volumetric modeling of anatomic details such as the optic foramen (see Section 3.1 for details).
Here we present a fast automated pipeline that operates entirely with volumes which we released in 2017 under the code name ROAST, a short hand for “Realistic vOlumetric-Approach to Simulate Transcranial Electric Stimulation”. In its current release ROAST uses the segmentation algorithm of SPM version 12 and applies it to the entire head and neck (Huang et al., 2013). We integrate this with our post-processing routine that ensures continuity of the cerebrospinal fluid (CSF) and skull and an additional tool that automatically places virtual electrodes on the volumetric segmentation. This is then followed by meshing with iso2mesh and FEM solving with getDP (Figure 1). Finally, we use volumetric visualization of the resulting electric fields. ROAST is based on Matlab but is otherwise entirely open source. It processes individual MRI volumes in a fully automated fashion to generate 3D renderings of the resulting electric field distributions. The user can specify any number of electrodes within the 10-05 and/or BioSemi-256 system. The end-to-end processing time is typically less than 30 minutes, which is much faster than alternative approaches (e.g. SimNIBS). It is also significantly easier to use and to install as compared to other tools (e.g. SCIRun).
In this report we compare the segmentation results of ROAST and SimNIBS to a hand-labeled segmentation of an individual head which serves as ground truth. We also compare the electric fields obtained with the various segmentation, meshing and solving tools used in ROAST and SimNIBS as well as commercial software (ScanIP and Abaqus) on the MNI-152 standard head (Grabner et al., 2006). To our knowledge this is the first quantitative comparison of these TES modeling tools. This evaluation reveals a substantial difference in the predicted field distribution between ROAST and various versions of SimNIBS. To determine which of these is closer to actual field measures in human heads we compare the predictions to published data (Huang et al., 2016). The prediction performance of ROAST and a previous versions of SimNIBS are similar, but differ for the newer versions of SimNIBS. The latest release of ROAST is freely available and we hope that this can make current-flow models accessible to a broader group of researchers and clinical investigators https://www.parralab.org/roast/.
2. Methods
2.1 Components of ROAST pipeline
ROAST stands for Realistic vOlumetric-Approach to Simulate Transcranial Electric Stimulation. It is composed of the following components:
Segmentation
The “Unified Segmentation” algorithm (Ashburner and Friston, 2005) implemented in SPM12 is used, with an extended tissue probability map covering the entire head (Huang et al., 2013). This allows one to model the head with a field-of-view (FOV) that exends down to the neck. Segmentation from SPM12 is further improved by a Matlab script. This post-processing attempts to smooth the segmentation, fill holes on the cerebrospinal fluid (CSF), and remove the disconnected voxels. The first part of this post-processing has been presented previously (Huang et al., 2013), and it is based on morphological operations. The parameters in these operations are selected conservatively and thus gaps in the thin layers of gray matter, CSF and skull cannot be fully removed. Here, these remaining gaps were filled using simple heuristics (e.g., to fill gaps in CSF, we check if any brain voxel touches bone/skin/air, if so, then we convert the bone/skin/air neighbors to CSF). While this fills in all gaps in gray matter and CSF, we do not apply this process indiscriminately to all of the skull, as we want to preserve skull openings in the optic canal and the foramen magnum which can serve as important conduits of currents into the brain. To preserve these genuine openings in the skull, a special mask was made marking these regions in the tissue probability maps used by the SPM12 segmentation routine and this mask was mapped into the individual MRI space during segmentation. These regions were then treated as exceptions during the patching process.
Electrode placement
This is a Matlab script we developed based on previous work (Huang et al., 2013). In its latest version, users can place virtual electrodes freely among the locations of the 10-20, 10-10, 10-05 or BioSemi-256 EEG system. They can also place the electrode at any arbitrary location on the scalp by providing the coordinates in the MRI voxel space. Furthermore, the shape of each electrode can be selected to be either a disc, pad or ring, with customizable size and orientation (for pad).
Finite element meshing
The Matlab toolbox iso2mesh (Fang and Boas, 2009) is used to generate the volumetric mesh. Specifically, the “cgalv2m” function was used to generate a tetrahedral mesh directly from the segmented MRI. This is made possible by the CGAL package (Rineau et al., 2009), which is capable of generating a volumetric mesh from 3D multi-domain images. Users can customize the mesh options provided by iso2mesh, such as the element size.
FEM solving
The open-source solver getDP (Dular et al., 1998) is used to solve the underlying Laplacian equation (Griffiths, 1999). Users specify how much current goes into each anode and out of each cathode (Neumann boundary condition). The tissue conductivity can be customized, with the default based on previous literature (Crille et al., 1922; Burger and van Milaan, 1943; Freygang Jr and Landau, 1955; Ranck Jr., 1963; Hasted, 1973; Geddes, 1987; De Mercato and Garcia Sanchez, 1992; Gabriel, 1996; Akhtari et al., 2002).
Figure 1 shows the ROAST pipeline (text highlighed in red). ROAST is currently available online at https://www.parralab.org/roast/. A README file there contains more details on the features of this software. As a fully-automated and easy-to-use pipeline, users do not have to install separate packages. They only need to install Matlab, download ROAST, and enter a one-line command that selects the desired MRI (in NIfTI format) and the desired electrode locations with the amount of injected current. A simulation result will then be generated within 20–30 minutes for a typical 1 mm resolution head MRI (tested on a typical dual-core computer with 16 GB memory).
2.2 Comparison of different modeling pipelines
We evaluated the free ROAST pipeline along with variants that use commercial software (Huang et al., 2017), as well as the free SimNIBS pipeline (Windhoff et al., 2011; Nielsen et al., 2018), and various intermediate version (Figure 1). This leads to a comparison across four different segmentation methods (Figure 3) and seven different TES modeling workflows (Figure 4).
2.2.1 Segmentation
A T1-weighted MRI of an adult male subject (S1) published before (Huang et al., 2013) was used to evaluate the performance of different software on segmentation. The reason for using this individual is that it has been manually segmented from scratch (Datta et al., 2009) so there is no bias introduced by initializing the manual segmentation with the results from an automated segmentation software.
The first segmentation candidate was obtained by ROAST (see Section 2.1 for details). ROAST saves the segmentation results in the voxel space of the MRI. The other three candidates for comparison are part of the SimNIBS toolbox (headreco, headrecoE, mri2mesh; here for simplicity we abbreviated them as SimNIBS-hr, SimNIBS-hrE and SimNIBS-mm, respectively). The earlier segmentation routine in SimNIBS is SimNIBS-mm, which combines FreeSurfer (Dale et al., 1999; Fischl et al., 1999) and FSL (Smith, 2002) to segment the brain and non-brain tissues, respectively (Windhoff et al., 2011). Note that this routine cannot segment any head MRI with size bigger than 256 pixels in any direction. As S1 has a size of 280×320×208, we cut it into 246×256×208 by removing the empty slices in the posterior direction and also the slices of the lower part of the head. Also, SimNIBS-mm saves segmentation results in the FreeSurfer standard space, so we registered and resampled that back into the MRI voxel space to be consistent with the other approaches.
Recently a newer version of SimNIBS was released that incorporates SPM12 as its segmentation function (Nielsen et al., 2018), and uses the extended atlas published in Huang et al. (2013) as the prior probability map for segmentation (this map covers the lower part of the head). With this, SimNIBS can now segment heads with sizes bigger than 256 pixels in any dimension, and runs in 1 to 2 hours instead of 10 hours. The entire modeling process was named head-reco, and we name it as SimNIBS-hr. SimNIBS-hr also provides an option to use the CAT12 (Computational Anatomy Toolbox 12, http://www.neuro.uni-jena.de/cat/) to enhance cortical segmentation by capturing sulci in more detail. We denote the segmentation from this as SimNIBS-hrE (E meaning enhanced).
SimNIBS saves the segmentation in two formats under the m2m * folder: surface (.stl) and volumetric (.nii). The surface segmentation is used to generate the current-flow models (see Section 2.2.2). ROAST outputs segmentation in a volumetric format (.nii). To find out how volumetric and surface formats affect the segemntation results, we compared both SimNIBS formats to the segmentation generated from ROAST, as well as the manual segmentation as the ground truth. For the volumetric segmentation from SimNIBS, the following operations were performed so that the same six tissue masks are compared across different approaches (gray matter, white matter, CSF, skull, scalp and air cavities; note air cavities are labeled as skull by SimNIBS-mm): (1) combine eyes with CSF (only for SimNIBS-hr); (2) combine ventricles with CSF; (3) combine cerebellum with gray matter (only for SimNIBS-mm); (4) remove overlap between different tissues (this overlap is generated when SimNIBS saves surfaces into volumes). For the surface format of SimNIBS-genarated segmentation, we converted the surfaces to volumes and upsampled the volumes from 1 mm to 0.2 mm resolution to ensure that surfaces are still fully closed in voxelized grid (ROAST and manual segmentation were also upsampled to 0.2 mm for comparison). This was done in ScanIP and the same operations as described above were performed on the upsampled volumes from SimNIBS. Note that for SimNIBS-mm we registered the converted volumes back into MRI voxel space before the upsampling.
To quantify the difference between these segmentations, the Dice coefficient (Dice, 1945) was calculated between different methods and against the ground truth (i.e., hand-segmented tissue masks). This was done on both the volumetric and surface format of the segmentation (for ROAST and manual segmentation, the surface format is simply the upsampled version of volumetric data). When computing Dice coefficients between SimNIBS-mm and other methods we excluded voxels that are outside the FOV of mri2mesh routine.
2.2.2 Simulation of electric field
Using a well-known standard head (MNI-152, v6, which is a T1 MRI co-registered at 1 mm3 resolution and averaged over 152 individuals (Grabner et al., 2006)), we compared the seven different workflows in Figure 1 in terms of the predictions on electric field distribution. The electrode montage used for all pipelines is Fp1 (anode) and Iz (cathode). Electrodes were all modeled as small discs with radius and height being 6 mm and 2 mm, respectively.
To test how different FEM software perform on the same segmentation data, we run the models using different combinations of either open-source or commercial FEM meshers and solvers, but identical segmentation and automated electrode placement routine (ROAST, ROAST-sg, ROAST-sa, ROAST-gg). For ROAST, iso2mesh and getDP serve as the mesher and solver, respectively (see Section 2.1 for details). In ROAST-sg, adaptive meshing (ScanFE-Free algorithm) was used in ScanIP and the output mesh was converted to .msh format that is compatible with getDP. ROAST-sa essentially follows the same details as described in Huang et al. (2013), which uses commercial software ScanIP and Abaqus. To compare how SimNIBS-generated segmentation affects the modeling results compared to SPM12-generated segmentation, we feed the segmented masks from SPM12 into gmsh and getDP, leading to ROAST-gg. Since gmsh only accepts surface segmentation as its input format (Geuzaine and Remacle, 2009), the volumetric masks from SPM12 were first converted into .stl format using iso2mesh in ROAST-gg before entering gmsh. For these four pipelines, the same conductivity values are used as in Huang et al. (2013), and the boundary condition was set as 1 mA current injection at the anode Fp1 (note this 1 mA is calculated precisely by using the exact anode area calculated from the tetrahedral mesh elements).
The 5th to 7th pipelines in Figure 1 are three different segmentation options in SimNIBS (Version 2.1): headreco (SimNIBS-hr), headreco with CAT12 toolbox (denoted SimNIBS-hrE here) and mri2mesh (SimNIBS-mm) (Windhoff et al., 2011; Nielsen et al., 2018). For these three pipelines, electrode placement was done in SimNIBS graphic user interface (GUI) by selecting the names of the corresponding electrodes. Same tissue conductivity values were entered in the GUI, and the injected current was also set to 1 mA at Fp1 in the GUI. The model was then generated and solved using the built-in tools gmsh and getDP, respectively (Windhoff et al., 2011).
For the ease of comparing the outputs from these pipelines, the solutions on the mesh grid were read into Matlab and resampled onto a regular grid with the same dimensions and resolution as the original MRI. Note that SimNIBS-mm saves the results in the FreeSurfer standard space. These results were thus registered and resliced into the original voxel space of the input MRI. Voxel-to-voxel comparison on the electric field distribution can then be performed across the methods. The metric to quantify the difference between two methods A and B is the deviation of A from B, with B as the reference (i.e., the relative difference):
Here E indicates the electric field. We compare the results of the open-source tools to the commercial FEM software and the results using the SPM12 segmentation to the SimNIBS segmentation. The relative difference was calculated for each tissue separately. Segmentation masks were used to extract the tissue-specific electric field values.
2.3 Validation of modeling pipelines on recording data
When we compare across the seven pipelines in Section 2.2.2, there is no ground truth to evaluate which pipeline provides more accurate prediction on electric field distribution. To this end, we validated the major four automated pipelines against actual intracranial electrical recordings (Huang et al., 2016). We also report the hand-built models of Huang et al. (2017), which is the only one where we have implemented surgical details of these patients’ anatomies. This gives five sets of results (ROAST, SimNIBS-hr, SimNIBS-hrE and SimNIBS-mm, Huang-2017). Computational models were built for 14 subjects (P03, P04, P05, P06, P07, P08, P09, P010, P011, P013, P014, P015, P016, P017) using their pre-surgical MRIs, i.e. the MRI that does not capture the craneotomy or implanted electrodes. As the recorded data in Huang et al. (2016) are calibrated into 1 mA current injection, all the models solved in the four automated pipelines were set to 1 mA current injection as well. Stimulation electrodes were placed on the scalp according to photos of the subjects during the recording. For each subject, the model-predicted values and the recorded values were compared in terms of two criteria: (1) Pearson correlation coefficient r between recorded and predicted values; (2) the slope s of the best linear fit with predicted value as “independent” and measurement as “dependent” variables. The correlation captures how well the model predicts the distribution patterns of the electric fields, regardless of a potential mismatch in overall magnitude. The slope measures how accurate the model estimates the absolute magnitudes. Electric fields are calculated between adjacent recording electrodes, i.e. they represent the projection of the actual field vector in this direction – as the cosine it will be typically smaller than the absolute magnitude. The voxel coordinates of the recording electrodes were used to read out the predicted voltages from the models. See Huang et al. (2017) for details on the methodology. Again note that for SimNIBS-mm, those heads with more than 256 axial slices were cut into 256 axial slices (discard the lower portion of the head). Also, results from SimNIBS-mm were registered and resliced into the original voxel space of the input MRI.
3 Results
3.1 Segmentation performance
Segmentation in ROAST is based on SPM12, followed by custom post-processing to implement morphological constraints that are important for current-flow modeling, such as continuous CSF (see Section 2.1). SimNIBS offers three segmentation options based on SPM12, CAT12 and FSL/FreeSurfer (see Figure 1 and Section 2.2.1), which are followed by custom post-processing. In SimNIBS the post-segmentation processing enforce that one tissue type is fully enclosed by another. The result of these four different approaches are shown in Figure 2 for an individual head along with a segmentation performed entirely by hand (manual). Inspection of the the axial slices (Figure 2A) suggests that the SimNIBS tools (SimNIBS-hr, SimNIBS-hrE, SimNIBS-mm) give smoother segmentations compared to ROAST, especially for the thin surfaces of CSF and skull. In contrast, ROAST gives more detailed segmentation on small structures such as the small bones around the eyes and nose, which is in agreement with the manual segmentation. The CAT12 toolbox appears to enhance the segmentation of the brain by giving more detailed gyri and sulci (comparing SimNIBS-hrE with SimNIBS-hr). SimNIBS-mm does not capture the eyeballs or any realistic skull structures around the eyes and nose, but it segments the brain well with better gyrations compared to SimNIBS-hr and ROAST.
We also show 3D renderings of the segmentation of the CSF and skull in Figure 2. For SimNIBS-hr, we show both the volumetric and the surface format, as indicated by SimNIBS-hr vol and SimNIBS-hr surf, respectively. This is because SimNIBS can save the segmentation in both volumetric and surface format (see Section 2.2.1 for details), but uses the surface segmentation for making the FEM. ROAST only operates in volumetric format. In the volumetric segmentation we often find gaps in thin layers of CSF and skull (Figure 2B–D). SimNIBS closes all these gaps when converting the volumetric segmentation from SPM12 into surfaces, but in the process it loses details of the real anatomy especially for the skull (compare SimNIBS-hr vol and SimNIBS-hr surf in Figure 2B–D). For example, the veridical openings of the skull such as the optic foramen and the foramen magnum (indicated by the red arrows in Figure 2CD) are all closed in the surface format. ROAST, on the other hand, meshes the volumetric segmentation directly. Consistent with the manual segmentation, the automated post-segmentation script in ROAST avoids filling in gaps at known foramen locations (Figure 2CD under ROAST).
To quantify the difference in segmentations we report the Dice coefficients between all methods as a matrix in Figure 3. We compute Dice coefficients before and after the volume-to-surface conversion of SimNIBS (Panel A and B respectively). The Dice coefficients were calculated on the entire head mask excluding skin and air. Note that the Dice coefficients are very large (above 0.9), indicating a very good overall agreement between methods. There is, on this head, almost no difference in results between SimNIBS-hr and SimNIBS-hrE, but these two differ from the segmentations of ROAST and SimNIBS-mm. The SimNIBS post-segmentation routine that converts volumes into surfaces introduces additional discrepancies (compare Panel A and B in Figure 3). In addition, the different methods are compared against the manual segmentation (shown as bar plots for each specific tissue type in Figure 3C). The main observation here is that for all methods the largest discrepancies to manual segmentation are observed for air cavities, bone and CSF (all three compartment are equally dark in T1 images and thus difficult to establish conclusively). Errors are mostly at boundaries, and thus Dice coefficients are large for skin which is comprised of a large bulk volume. GM and WM is reasonably well segmented with the best performance for ROAST. SimNIBS-mm has overall lower performance for all tissues compared to the other three methods. The volume-to-surface conversion causes a small drop in performance for all SimNINBS methods. However, we should note that factors such as continuity of a compartment may be ultimately more important than small changes in segmentation volumes. This may become more apparent when evaluating the resulting field distributions (see Section 3.2).
3.2 Electric fields predicted by different modeling pipelines
When computing the electric field distributions we wanted to evaluate the effect of different meshing and FEM solving toolboxes including free and commercial software. We do this for the segmentation results of ROAST. We also evaluated the results with the same free mesher and solver but for the different segmentation options of SimNIBS. This results in seven different pipeline options (see Figure 1).
Across these different modeling pipelines, the spatial distributions of electric field magnitudes in the brain are visually quite similar (Figure 4), except for results with SimNIBS-hrE (6) and SimNIBS–mm (7), which have more detailed sulcal structures due to the CAT12 toolbox used in SimNIBS-hrE and the surface segmentation in FreeSurfer, respectively. The overall magnitude distribution of fields is also remarkably similar (histograms to the right of each axial slice).
The quantitative differences between these methods for the electric field distributions (Eq. 1) are shown at the lower right corner in Figure 4. We compared eight pairs of pipelines for the electric field in the brain and CSF:
ROAST (1) vs ROAST-sg (2): shows the difference introduced from using open-source mesher iso2mesh instead of the commercial ScanIP;
ROAST-sg (2) vs ROAST-sa (3): gives the difference between the free solver getDP and commercial solver Abaqus;
ROAST (1) vs ROAST-sa (3): captures the difference between iso2mesh/getDP and ScanIP/Abaqus;
ROAST-gg (4) vs ROAST-sg (2): gives the difference between gmsh and ScanIP;
SimNIBS-hrE (6) vs SimNIBS-hr (5): shows the effect of adding the CAT12 toolbox with improved brain segmentation;
SimNIBS-mm (7) vs SimNIBS-hrE (6): is the difference between SimNIBS version 2.0 and version 2.1;
SimNIBS-hr (5) vs ROAST-gg (4): represents the difference from using SimNIBS-hr and ROAST segmentation, which shows the genuine difference between ROAST and SimNIBS (see below);
SimNIBS-mm (7) vs ROAST-gg (4): shows the difference between the segmentation generated by SimNIBS-mm and ROAST.
In terms of the electric field inside the brain it appears that using free vs. commercial mesher/solver does not significantly impact the result (the first four comparisons). However, the results are quite different if one uses SimNIBS instead of ROAST for segmentation.
The big difference (51%) between SimNIBS-mm (7) and ROAST (4) can be explained by the different segmentation approaches used in the two software: ROAST is based on the SPM12 segmentation algorithm that works on voxelized image data (Ashburner and Friston, 2005). SimNIBS-mm, which utilizes FSL (Smith, 2002; Smith et al., 2004) and FreeSurfer (Dale et al., 1999; Fischl et al., 1999), generates a segmentation in the format of a surface mesh.
However, this cannot explain the large difference (52%) between SimNIBS-hr (5) and ROAST-gg (4), as the two utilize exactly the same toolboxes for segmentation, meshing and solving (see Figure 1). The source of this difference lies in the post-processing of the segmentation. When building the mesh, SimNIBS converts the volumetric segmentation from SPM12 into decoupled surfaces (see Section 3.1, Figure 2 and Figure 3 for details). Within SimNIBS the different segmentation functions also give some difference in the predicted fields in the brain: 12% when CAT12 is used in SimNIBS-hr, 21% between SimNIBS version 2.0 (SimNIBS-mm) and version 2.1 (SimNIBS-hrE).
The electric field inside the CSF is another interesting quantity to look at. It does not vary much if open-source mesher is used instead of commercial mesher (25% between iso2mesh and ScanIP; 19% between gmsh and ScanIP), but the difference shoots up to over 100% when getDP is used instead of Abaqus (122% between (2) and (3); 112% between (1) and (3)). This is expected as the CSF is a very thin layer with a high jump of conductivity from its neighboring tissues (CSF: 1.65 S/m; gray matter: 0.276 S/m; skull: 0.01 S/m). Due to this jump in conductivity, computation of electric field from voltages across the tissue boundaries is analytically not defined and it depends on the numerical details of the solvers on how to compute its approximation from the resulting voltages (Engwer et al., 2017). This can be seen in Figure 5 where we take out a line in one example slice of the head and plot the electric field magnitude obtained from getDP and Abaqus. The field magnitudes are exactly the same inside the brain but are different on the boundaries of brain, CSF and skull (indicated by arrows in Panel B) despite nearly identical computed voltages in both solvers. Similarly to the comparison for the brain, when comparing SimNIBS results with ROAST for the CSF, a high difference of 76% is found. The three different functions within SimNIBS also give some difference (9% to 22%).
3.3 Prediction accuracy of different modeling pipelines
The difference in the predicted electric fields begs the questions as to which of these pipelines best match observed electric fields recorded in humans. To address this we compared the predictions to intracranial field measurements recorded in vivo from 14 human subjects using publicly available data (Huang et al., 2016). In total we have 17 configurations (one subject P014 has 4 stimulation montages) and a total of 1456 brain locations to compare against the models. Figure 6 shows the results of five modeling pipelines – one for ROAST, three for SimNIBS, and the manual method of Huang et al. (2017).
Performance is evaluated in terms of the correlation across recording locations between measurement and prediction (Figure 6A) following Huang et al. (2017). This captures the accuracy of the predicted field distribution across the brain. Separate from that, we evaluate the accuracy of the field magnitude, as the scaling factor required for the predictions to best match the measured field magnitudes (Figure 6B; scale of 1 corresponds to accurate estimation of magnitude, all models appear to over-estimate the magnitude).
ROAST predicts the electric field distribution significantly better than SimNIBS-hr (p = 0.0005, t(16) = 4.35) and SimNIBS-hrE (p = 0.0008, t(16) = 4.11), but no different from SimNIBS-mm (p = 0.17). ROAST also predicts the electric field magnitude significantly better than all the three versions of SimNIBS (SimNIBS-hr: p = 0.00006, t(16) = 5.42, SimNIBS-hrE: p = 0.0006, t(16) = 4.25, SimNIBS-mm: p = 0.02, t(16) = 2.57). This means that the estimated slopes are somewhat closer to 1, although clearly all models over-estimate field magnitudes, which can be readily corrected if conductivities are calibrated to match the data (Huang et al., 2017). As expected, the manual approach outperforms the fully automated pipelines, including ROAST in terms of predicting the field distribution (Huang-2017 vs ROAST: p = 0.03, t(16) = 2.32). However, ROAST is no worse than the manually refined model (p = 0.42) in terms of estimating field magnitude.
4 Discussion and Conclusions
This paper reports on a new pipeline for current-flow modeling in the human head, which we have termed ROAST. Full-automation allows users to obtain state-of-the-art models base on individual MRIs without the know-how required to operate various complex software packages. The pipeline is based entirely on free software, except for Matlab, which we have retained in order to leverage existing tools (SPM, post-processing, electrode placement and 3D visualization).
Installation is straightforward as all dependent libraries are included in a single package (for Linux, Windows, and Mac). ROAST allows for realistic modeling of the human head anatomy with relatively short run times (20–30 minutes) by leveraging efficient volumetric segmentation routines of SPM12.
When comparing segmentation results to surface-based segmentation as implemented in FreeSurfer/FSL (SimNIBS-mm), it is clear that cortex is better segmented with surfaces capturing cortical folding into detailed gyri and sulci (Figure 2A), albeit at a substantial additional computational cost. On the other hand, volumetric segmentation implemented in SPM is relatively fast and has more flexibility in representing arbitrary morphology (Figure 2B–D under ROAST and SimNIBS-hr vol). Specifically, surface-based segmentation is limited to tissue volumes defined as the space between two surfaces (e.g., skull volume is between scalp and skull surface). Therefore, embedded structures (e.g., ventricles inside surface CSF), components with intersecting surfaces (e.g., gray matter and cerebellum), and tissues with disconnected regions (e.g., skull and disjoint spine vertebrae) cannot be defined with closed, non-intersecting surfaces, unless each structure is defined as separate surfaces.
When comparing the predicted fields between different toolboxes, one surprising finding is that the same volumetric segmentation approaches provide quite different results: There is a 52% difference between SimNIBS-hr and ROAST-gg (Figure 4, 5-vs-4 in Panel Brain), yet both are based on SPM12 (Figure 1). The explanation for this lies in the different post-processing routines. SimNIBS converts the volumetric segmentation of SMP12 into surfaces prior to meshing, and in that process, many details of the anatomy are lost (Figure 2CD compare ROAST with SimNIBS-hr surf and SimNIBS-mm for the facial structures, optic canals, and the foramen magnum; also Figure 3). ROAST circumvents these problems by working entirely with volumes during segmentation (SPM), meshing (iso2mesh) and FEM computations (getDP). Another large difference is observed between ROAST and SimNIBS-mm (51%, Figure 4), which is expected as they use different segmentation approaches, and furthermore, SimNIBS-mm provides a segmentation with a limited FOV.
An additional question we wanted to address is whether replacing commercial software packages with free software tools affects the simulation results (iso2mesh and getDP instead of ScanIP and Abaqus). With 11% difference in the brain, the relative difference in field estimates are in fact minor (Figure 4, 1-vs-3 in Panel Brain). However, the difference are pronounced in CSF (over 100%, Figure 4, 1-vs-3 in Panel CSF). This however is not unexpected given that these tools differ on how they compute electric fields from the potential distributions at the boundaries (Figure 5), where tissue conductivity values are discontinuous (Engwer et al., 2017). Despite nearly identical potential distributions the two methods give different field estimates at the boundaries. So in total, we conclude that the two methods give identical results, at least in terms of voltage distribution.
To validate predicted fields we compare them to field measured intracranially in human (Huang et al., 2016). For all methods the correspondence is moderate with correlations between measured and predicted fields in the range of 0.4 to 0.9 (Figure 6 A). The exceptions are SimNIBS-hr and SimNIBS-hrE with a number of subjects significantly under-performing. Some of these outliers have all-zero voltages in a certain tissue type, which may be the reason why they have low performance. ROAST, SimNIBS-mm and Huang-2017 are all approximately the same, except for one outlier patient (P016), where the detailed modeling of the surgical alterations may have been important. One surprising result of this analysis is that the performance of SimNIBS-mm is no worse than ROAST despite a severely limited FOV in the segmentation (missing neck and head below the nose). We interpret this finding as support for the notion that careful modeling of cortical gyrations, in particular CSF-filled sulci, is crucial to correctly predict field distribution in the brain. An important caveat to this result is that neither ROAST nor SimNIBS are designed to capture the surgical details necessary to obtain reasonable estimates on these intracranial field measurements. Nevertheless, the results suggest that future work may need to focus on refining volumetric segmentation to capture the details of brain sulci, perhaps at super-resolution level of less than 1 mm, which is possible in principle with surface segmentations.
Future work is needed to validate these modeling software tools using recordings from the entire brain and with a diversity of TES montages. The present results compare modeling with mostly a single TES montage of a frontal and occipital electrode (approximately Fpz and Oz, Huang et al. (2017)), a deliberate choice made in those experiments to avoid the temporal craneotomies. Many of the recording electrodes for these data were placed on cortex (electrocorticogram electrodes) where field predictions are complicated because of the boundary issues discussed above. Future work may benefit from stereotactig EEG during TES which uses only minor burr-holes and allows more flexible placement of TES and EEG alectrodes (Koessler et al., 2017). Additionally, more validation is needed for the FEM meshers and solvers using analytic solutions from a spherical model as the ground truth (Dmochowski et al., 2012), for which we provided a software interface (https://www.parralab.org/spheres/). Lastly, theoretical work on novel modeling approaches is needed to advance this field further. For example, an FEM solver that can directly operate on segmentation data without first building a mesh (Nüßing et al., 2016). Additionally new methods that promise to cope with conductivity discontinuities at boundaries (Engwer et al., 2017) should be tested and potentially incorporated into modeling pipelines. This may be particularly important for fields measured at the cortical surface. Finally, it would be desirable to have a fully open-source solution for ROAST. The primary hurdle for this is the segmentation with SPM12, which we may replace in future versions. Future versions may also implement a graphic user interface so that users can inspect the segmentation easily and perform any touch-up if needed. At present we recommend using free tools such as ITK-SNAP for this purpose (http://itksnap.org).
In closing we want to note the benefits of having multiple modeling toolboxes in development. For instance, SimNIBS has adopted SPM12 as the segmentation tool to allow faster volumetric segmentation. ROAST has in turn borrowed from SimNIBS the use of getDP as a free and fast FEM solver. Simalarly, it has been useful during the development of ROAST to have commercial-grade meshing and FEM solving tools as a reference point for our work (Simple-Ware, Abaqus, COMSOL). We hope that future versions of these tools will continue benefiting from one another to maintain a healthy and productive software development community.
ACKNOWLEDGMENT
The authors would like to thank Chris Thomas at Soterix for insightful discussions, and his work in marking up the special regions in the skull prior map for the patching algorithm in ROAST. We also would like to thank Alexander Opitz for pointing us to the free solver getDP. We also thank Jens Madsen for assistance with Matlab GUI programming, and Zeinab Esmaeilpour for testing ROAST extensively on the Mac OS. This work was supported by the NIH through grants R01MH111896, R44NS092144, R41NS076123, and by Soterix Medical Inc.