Abstract
Research in the area of transcranial electrical stimulation (TES) often relies on computational models of current flow in the brain. Models are built on magnetic resonance images (MRI) of the human head to capture detailed individual anatomy. To simulate current flow, MRIs have to be segmented, virtual electrodes have to be placed on these anatomical models, the volume is tessellated into a mesh, and the finite element model 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 (SPM8, iso2mesh and getDP) and custom scripts to improve segmentation and execute electrode placement. When we compare the results on a standard head with other major commercial software tools for finite element modeling (ScanIP, Abaqus), ROAST only leads to a small difference of 9% in the estimated electric field in the brain. We obtain a larger difference of 47% when comparing results with SimNIBS, an automated pipeline that is based on surface segmentation of the head. We release ROAST as a fully automated pipeline available online as a open-source tool for TES modeling.
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 same 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 includes segmenting the MRI into different tissue compartments, assigning conductivity to each compartment, plac-ing virtual electrodes on the models, tessellating this volumetric anatomy into a 3D mesh, and numerically solving the Laplace equation for the voltage distribution on this finite element model (FEM) (Datta et al., 2009).
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 complete review on these segmentation software, please see Huang and Parra (2015)). Generation of a finite element mesh can be accomplished by either open-source tools (e.g. iso2mesh (Fang and Boas, 2009), Gmsh (Geuzaine and Remacle, 2009)) or proprietary 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 boundary element methods that are more common for EEG modeling (Fuchs et al., 1998, e.g.). Boundary element models can be significantly faster computationally, but they limit the anatomical morphology that can be represented. 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 low-conductance conduit into the skull. We aimed to generate an automated processing pipeline that operates entirely with volumes and does not have the morphological restrictions imposed by surface-based segmentation.
To this end we use the segmentation algorithm that is part of SPM8 and apply it to the entire head and neck (Huang et al., 2013). We integrate this with our tools to ensure continuity of the cerebrospinal fluid (CSF) and skull and to automatically place electrodes. This is then followed by meshing with iso2mesh and FEM solving with getDP. Finally, we use volumetric visualization of the resulting electric fields (Figure 1). The complete pipeline is a Realistic vOlumetricApproach to Simulate Transcranial Electric Stimulation and has therefore been named ROAST. 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 current distributions. The user can specify any number of electrodes within the 10-10 system. The end-to-end processing time is typically less than 30 minutes, which is one order of magnitude 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).
Results of ROAST on the MNI-152 standard head (Grabner et al., 2006) are compared here to SimNIBS and results obtained with a commercial mesher and solver (ScanIP and Abaqus). To our knowledge this is the first comparative evaluation of these TES modeling tools. Results show that ROAST only deviates 9% in predicting the electric fields in the brain. The difference is higher (47%) when comparing the output of ROAST with that of SimNIBS, mainly because SimNIBS builds the model based on the surface segmentation of the MRI (generated by FreeSurfer), as opposed to the volumetric segmentation generated by SPM8. Further work is needed to validate which pipeline gives more accurate model predictions, along the lines of recent validation efforts with direct measurement of electric fields in vivo in the human brain (Opitz et al., 2016; Huang et al., 2017; Koessler et al., 2017). Nonetheless, we release ROAST now at http://www.parralab.org/roast/ to make current-flow models accessible to a broader group of researchers and clinical investigators.
2. Methods
Starting from 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 tested and compared the results for five different workflows to build a TES model with electrodes at locations Fp2 and Iz. Figure 1 shows these five candidates for comparison. The red and blue outlines highlight ROAST and SimNIBS, respectively, and the circled numbers on the right indicate each pipeline.
For Pipelines 1–4, the MNI-152 MRI was segmented using SPM8 (the New Segment routine, see Ashburner and Friston (2005) and Huang et al. (2013) for details). Automatic touch-up on the segmentation results were performed by morphological operations (Huang et al., 2013). This conservative post-processing attempts to, but does not fully, remove holes on gray matter, cerebrospinal fluid (CSF) and skull. Remaining holes were filled using simple heuristics (e.g., to fill holes on CSF, check if any brain voxel touches bone/skin/air, if so, then convert the bone/skin/air neighbor to CSF). While this patches all holes in gray matter and CSF, we do not want to apply this indiscriminately to all of the skull, e.g., we want to preserve skull openings in the optic canal and the foramen magnum. To preserve these veridical gaps in the skull, a special mask was made marking up these regions in the prior tissue probability maps used by the New Segment routine and this mask was mapped into the individual MRI space during segmentation. These regions were then treated as exceptions during the patching process. Electrodes (Fp2, Iz) were then placed on the scalp surface using Matlab scripts developed in Huang et al. (2013). One can readily select any other location of the 10-10 international electrode placement system and the software can be easily adapted to suit other placement systems. In Pipeline 1, the “cgalv2m” function was used in iso2mesh (Fang and Boas, 2009) to generate a volumetric mesh directly from 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. A customized Matlab function was written to process the generated mesh, set up the boundary conditions corresponding to Fp2-Iz with 1 A/m2 current density applied on the anode Fp2, and call the solver getDP (Dular et al., 1998) to solve the underlying Laplacian equation (Griffiths, 1999). The same conductivity values are used as in Huang et al. (2013). In Pipeline 2, adaptive meshing (ScanFE-Free algorithm) was used in ScanIP and the output mesh was converted to .msh format that is compatible with getDP. Pipeline 3 essentially follows the same details as described in Huang et al. (2013). In Pipeline 5, the MNI-152 head was segmented by the combination of FSL and FreeSurfer (part of SimNIBS, see Windhoff et al. (2011)). Electrode placement was done in SimNIBS graphic user interface (GUI) by entering the exact coordinates on the scalp surface (obtained from Pipeline 1). The model was then generated and solved in SimNIBS by clicking the “Run” button in the GUI. SimNIBS uses gmsh and getDP as its mesher and solver, respectively (Windhoff et al., 2011). To compare how SimNIBS-generated segmentation affects the modeling results compared to SPM8-generated segmentation, we feed the segmented masks from SPM8 into gmsh and getDP, leading to Pipeline 4. Pipeline 5 is then the complete SimNIBS Pipeline. Since gmsh only accepts surface segmentation as its input format (Geuzaine and Remacle, 2009), the volumetric masks from SPM8 were first converted into .stl format using iso2mesh in Pipeline 4 before entering gmsh.
For the ease of comparing the outputs from these pipelines, the solutions on the mesh grid were read into Matlab and interpolated onto a regular grid with the same dimensions and resolution as the original MRI. Voxel-to-voxel comparison on the electric field distribution can then be performed across the methods. Furthermore, model predictions from Pipelines 1–4 were all calibrated to correspond to 1 mA current injection at the anode Fp2, by using the exact anode area calculated from the tetrahedral mesh elements. For Pipeline 5, the injected current was also set to 1 mA at Fp2 in the SimNIBS GUI. 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 SPM8 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. For Pipelines 1–4, SPM8-generated segmentations were used. For Pipeline 5, since SimNIBS generates embedded structures (e.g., ventricles inside surface CSF) and components with intersecting surfaces (e.g., gray matter and cerebellum) separately1, these tissue masks were first manually processed to be consistent with SPM8’s masks, i.e., combining the cerebellum with gray matter, merging ventricles into CSF, etc. The resulting five tissue masks (gray matter, white matter, CSF, skull, and scalp) were used to extract the electric field. Note that air cavities inside the skull are not provided by SimNIBS, instead, these are labeled as skull.
For Pipeline 1, we put all needed open-source tools and customized scripts into one single package and made it available online at http://www.parralab.org/roast/. It is named ROAST, standing for Realistic vOlumetric-Approach-based Simulator for Transcranial electrical stimulation. 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 (in 10-10 system nomenclature) with the amount of injected current. A simulation result will then be generated within 15–30 minutes (tested on a typical dual-core computer with 8 GB memory).
3. Results
Figure 2 shows an axial brain slice of the electric field distribution from the five modeling methods in Figure 1, with the corresponding histograms of the field magnitude in the brain. It is evident that the relative distributions of electric fields in the brain are visually quite similar across different modeling pipelines, except for results from SimNIBS, which has more detailed sulcal structures due to the surface approach for segmentation in FreeSurfer (see Section 4 for details). The overall magnitude distribution of fields is also remarkably similar (histograms on the right column). The quantitative differences for the electric field distributions as calculated from Eq. 1 between these methods are shown in Figure 3, where we essentially compared five pairs of pipelines, as indicated by the five columns. The title at each column indicates which two pipelines were compared. Comparing Pipeline 1 vs. 2 shows the difference introduced from using open-source mesher iso2mesh instead of the commercial ScanIP (Figure 3A); Pipeline 2 vs. 3 gives the difference between the free solver getDP (Figure 3B) and commercial solver Abaqus; Pipeline 1 vs. 3 captures the difference between iso2mesh/getDP and ScanIP/Abaqus (Figure 3C); Pipeline 4 vs. 2 gives the difference between gmsh and ScanIP (Figure 3D); Pipeline 5 vs. 4 shows the difference between the segmentation generated by SimNIBS vs. ROAST (Figure 3E).
Relative differences in electric fields from using open source versus commercial meshers and solvers are an average of 20% (Figure 3A–D), with differences in the CSF shooting up over 100% when getDP is used instead of Abaqus (Figure 3B). 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). Different solvers handle this discontinuity differently when computing the electric field from the solved voltages (Engwer et al., 2017). SimNIBS-generated segmentation gives higher deviations (average 67%, Figure 3E) in electric field compared to those from SPM8-generated segmentation.
4. Discussion and Conclusions
This paper proposes a new pipeline for TES modeling, which we have termed ROAST. It is a fully automated simulator based on free software (but does leverage Matlab to reuse several existing tools). Using the volumetric segmentation from SPM, it allows for a more realistic modeling of the anatomy and runs faster (15–30 minutes) compared to SimNIBS (10 hours). Also, as the dependent libraries are included in a single package (for Linux, Windows, and Mac), it is easy and straightforward to use, without the need to install software (other than Matlab). It only gives a 9% difference in predicted electric field distribution when compared to commercial FEM software. Future work may consider using the open-source alternative of Matlab (e.g., GNU Octave or Python) so that the entire package is freely available. Also a graphic user interface is needed in the future so that users can inspect the segmentation easily and perform any touchup if needed. At present we recommend using free tools such as ITK-SNAP for this purpose (http://itksnap.org).
The high deviation of SimNIBS-generated electric field compared to SPM8-generated result (average 67%, Figure 3E) indicates the genuine difference in these two categories of modeling methods (i.e., Pipeline 1–4 vs. Pipeline 5). The source of this difference comes mainly from the two different segmentation approaches. While SPM8 segmentation algorithm works on voxelized image data (Ashburner and Friston, 2005), SimNIBS, which utilizes FSL (Smith, 2002; Smith et al., 2004) and FreeSurfer (Dale et al., 1999; Fischl et al., 1999), generates the segmentation in the format of a surface mesh. This can give great details of the gyri and sulci on the cortex, even when tested on the MNI-152 head which is an averaged anatomy (Figure 4B). On the other hand, SPM-generated brain segmentation does not include these details (Figure 4A). One limitation of the surface-based segmentation is that each tissue volume is 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 with floating structures of spine) cannot be defined from a single, self-closed, non-intersecting surface, unless each structure is defined separately. Figure 4C–F shows the skull segmentation, from SPM8 and SimNIBS. Obviously, the volumetric approach in SPM8, which is integrated into ROAST, allows more realistic modeling of the anatomy (e.g., facial structures, optic canals, and the foramen magnum). SimNIBS, on the other hand, is very restricted in capturing the fine details of these structures. Future work may consider combining the brain segmentation from FreeSurfer with the skull/scalp segmentation from SPM for building improved TES models. Finally, an important difference between SimNIBS and ROAST is the longer computation time required by FreeSurfer as compared to SMP8 (hours instead of minutes). Similarly, commercial software (ScanIP, Abaqus, COMSOL) are considerably slower than their open-source equivalents (iso2mesh and getDP) which mesh and solve the FEM in 5-10 minutes instead of 30-60 minutes. More importantly, however, the tools we provide here operate entirely automatically, without the need for any user interaction and expert know-how when combining commercial modeling tools.
Finally, we want to emphasize that all the differences reported in this paper are not indicative of better or worse performance relative to the true current flows in the brain. Future work is needed to validate which modeling method gives more accurate predictions. On a very basic level we intend to validate meshing and solving by comparing to analytic solutions of a spherical model (Dmochowski et al., 2012) for which we provided a software interface (http://www.parralab.org/spheres/). To validate the performance of anatomical segmentation for the purpose of current-flow modeling, one may be able to use in vivo intracranial recordings in humans (Huang et al., 2017), which we have already made publicly available (http://www.parralab.org/tesValidate/).
ACKNOWLEDGMENT
The authors would like to thank Chris Thomas at Soterix for insightful discussions. 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. This work was supported by the NIH through grants R01MH111896, R44NS092144, R41NS076123, and by Soterix Medical Inc.
Footnotes
1 These are generated as separated structures because SimNIBS defines a connected volume as inside a closed, nonintersecting surface. See Section 4 for details.