ROAST: A fully automated, Realistic, vOlumetric Approach to Simulate Transcranial electric stimulation. This is an open-source tool that runs on Matlab and calls open-source software packages such as iso2mesh and getDP. Starting from an MRI structural image, it segments the full head, places virtual electrodes, generates an FEM mesh and solves for voltage and electric field distribution -- at 1 mm resolution. All this in about 10-30 minutes and fully automated.

This work was made possible by NIH through a number of grants (see below), but especially NIMH R01-MH111896 and NINDS R44-NS092144. Also Soterix Medical Inc provided significant support.

Getting started

Download ROAST (v 3.0, codenamed Hell's Kitchen)* | Go to the github repo for well-fomatted documentations

Unzip this file, launch Matlab** and change to the roast directory, then enter:


This will demo a modeling process on the MNI152 head. Specifically, it will use the T1 image of the 6th gen MNI-152 head to build a TES model with anode on Fp1 (1 mA) and cathode on P4 (-1 mA).

See video demonstration | A short talk at IEEE EMBC 2018 | A 1-hour tutorial at NYC Neuromodulation Online 2020; Tutorial slides


One can specify an individual*** head (in NIfTI format) and any combination of electrodes and currents as follows:


This will build a model for subject1.nii in subdirectory ./example with anodes F1 (0.3 mA) and P2 (0.7 mA), and cathodes C5 (0.6 mA), O2 (0.4 mA).

If you don't have an individual MRI, then you should use a high-quality standard, such as The NY Head. ROAST will skip the segmentation step as this standard head was already segmented with great care at 0.5 mm resolution (though simulations will be slower due to the more detailed spatial resolutions). To run this standard head with calibrated conductivity values use the following:


These values were calibrated to best match intracranial voltage recordings from 10 human subjects (Huang, Liu, et al 2017, specifically for the Fpz--Oz configuration).

Since version V2.0 the following features are supported: customized electrodes; addition of T2 images to improve segmentation; customize mesh options; user-defined tissue conductivities; resampling MRI into 1 mm resolution; add empty slices (zero-padding) to MRI to allow specific electrode placement; save all the results into NIfTI format; easier to manage simulation data. See README file for more details and examples. Here is an 'awesomeSimulation' demonstrating many of these features:

        'elecsize',{[],[7 9 3],[40 20 4],[],[]},...

To review the simulation results that are computed in this example, you can just enter the subject name and the simulation tag as follows:


Since version V3.0 the targeting feature was added. The first step to do targeting is to run ROAST with the 'leadField' keyword as the 'recipe':


This will generate the lead field automatically for use in the targeting program roast_target():

roast_target('example/MNI152_T1_1mm.nii','mni152LF',[-48 -8 50],'optType','wls-l1','targetingTag','mni152LeftMotorMaxFoc')

This will perform the targeting on the MNI152 head trying to maximize the focality of the electric field at the left primary motor cortex (MNI coordinates [-48 -8 50]) using the weighted least squares algorithm. This targeting run is tagged as 'mni152LeftMotorMaxFoc'. See README file for more details and examples.

To review the targeting results that are computed in this example, you can just use the targeting tag (See README file for more details and examples):


Processing pipeline

Modeling includes the following steps:

  1. Segment the MRI into skin, bone, CSF, white matter, gray matter and air cavities (using SPM8 in Matlab as explained here).
  2. Touch-up the segmentation to be sure there are no "holes" (using a touch-up script in Matlab).
  3. Place virtual electrodes of 6 mm radius at locations Fp1 and P4 (using this script in Matlab).
  4. Generate a Finite Element Model (FEM) mesh (using iso2mesh).
  5. Solve the FEM for voltage and electric field distributions (using getDP).
  6. Resample the result into the original 3D volume and make some interactive displays (using Matlab).

You may want to review the result of the automated segmentation on your individual heads, and if necessary, touch it up "by hand" using volume editing software, e.g. ITK-SNAP.

How to ask questions

Subscribe to the ROAST users group to post and answer any questions, and share experiences.

Google Groups
Subscribe to roast-users


Comparisions of ROAST with other modeling tools are here (please use these as references):

If you also use New York head in the simulation, please also cite:

If you also use the targeting feature (roast_target), please cite these:

This work was supported by NIH through grants R01MH111896, R01MH111439, R01NS095123, R44NS092144, R41NS076123, and by Soterix Medical Inc.

Notes and Disclaimers

* Version 3.0 is incompatible with simulation data generated by Version 2.7.1 and earlier versions.
** A Docker version
*** ROAST was not designed to build models for pathological heads, but there are plans to add this capability in future versions.

Latest update, April 22, 2020, Yu (Andy) Huang and Lucas C Parra