-
Notifications
You must be signed in to change notification settings - Fork 2
49. TMS E‐field modeling with Matlab GUI
We use the Matlab toolbox provided by Drs. Sergey N Makarov and Aapo Nummenmaa to calculate the induced electric field in TMS.
Refer to the page do TMS e-field modeling in scripting without GUI.
To model electric fields (e-fields) using realistic brain models and TMS coil models, the following steps will be involved:
-
Prepare "head models", which are realistic 3D models of head/skull/brain geometries and tissue properties, such as conductivity.
-
Prepare a "TMS coil model", which is a realistic 3D model of TMS coil shape with directed current flows.
-
Prepare the relative position between head models and TMS coil model. This process will be adjusted interactively, potentially including guidance from fMRI.
-
Calculate the e-fields.
-
Render calculated electric field strengths, such as the total strength (regardless of x-, y-, z-directional components) or directional component strength (such as component that is oriented tangentially or perpendicular to the cortical surface).
We will model the electric field generated by the MRi-B91 coil (MagVenture).
We will model the electric field generated over a subject coded s002
, whose FreeSurfer reconstruction is at /space_lin2/fhlin/eegmri_memory/subjects/s002 at Sunnybrook.
E-field estimation can only be achieved by accurate specification of head models, which describes the geometry and conductivities of scalp, skull, and brain. This is done by two steps.
- Define head model shapes Click the S button at upper left to start defining head model shapes.
Click + button to add each head model shape from FreeSurfer surface files, such as scalp surface, (inner/outer) skull surfaces, and pial surfaces (lh.pial and rh.pial).
Modify the "category" of each surface to define it as skin (scalp), skull, CSF, gray matter (GM), or white matter (WM). Here the category refers to the "tissue below the surface file". So, a scalp surface is the boundary of the free space (above the surface) and scalp (below the surface).
Close this window after specifying shape its geometry and category. Now you can toggle the visibility of each surface by clicking the check box at the surface drop-down menu.
- Define head model properties, including the conductivity and the enclosing tissue.
Click the Define head model button to start specifying parameters for each head/brain surface.
Start specifying each surface by define its name at "Tissue" edit box, setting geometry (clicking Choose surface for a surface defined in the previous "Define head model shapes" step, setting its conductivity (in S/m; suggested values are shown at the lower left corner), and choosing the "enclosing tissue" from a list box. Note the enclosing tissue list will grow automatically from recently added surface. So we recommend working from the out-most surface toward the brain inside.
Once finishing theese specifications, press + button to add one surface to the table.
Repeat the process until parameters for all surfaces are defined.
Remember to press Create, which will prompt a file name to save all these parameters. This step must be done before proceeding to head model preparation.
First, if head models are defined with a file name associated with geometry and parameter definitions, the light next to Prepare head model will turn yellow after pressing it.
Upon completing head model preparation, this light will turn green.
If head model has been prepared and saved previously, prepared head models can be loaded by clicking Load prepared model button.
Defining a TMS coil model in this GUI involves three parts. First is creating geometry definitions for each TMS coil. Two files will be created for one TMS coil. Then, one file for TMS coil visualization is loaded. Finally, one file for TMS coil e-field estimation ("strcoil") is loaded. In practice, we do the following.
- create TMS coil files
Choose among the drop-down list to create two files (coil.mat and coilCAD.mat) by clicking Create button.
- load TMS coil object for visualization
Click Load coil to load the coil for visualization using "coilCAD.mat".
Here we rotate the view to allow for better visualization of the loaded TMS coil object.
The light next to the button will turn green if loaded successfully. The loaded TMS coil object is in yellow color. There are also two lines indicating the "axis" and "up" direction of a coil in pink and green, respectively. Three checkboxes can set the visibility of the coil, axis, and up direction.
- load strcoil object for e-field calculation
Click Load strcoil to load the coil for e-field estimation using "coil.mat".
The light next to the button will turn green if loaded successfully. The loaded strcoil object is in green color. It should tightly fit to the TMS coil object just loaded because two objects should align in good agreement.
Defining a TMS target can be done in different ways:
- You can click the brain to define the ideal TMS target location. The clicked location will be shown/updated.
Click Go button move the coil such that its center (axis) going through the clicked brain surface location.
The image can look weird, as shown above. This is because the scalp surface was not set correctly. Change the scalp surface by selecting the right entry in the drop-down menu at the upper left corner (Head/brain boundaries). Then click Go again.
Now the TMS coil look reasonably targeting at the dorsolateral prefrontal cortex. Note that the default orientation of a TMS is that its "up" direction points to the head vertex.
You can input coordinates in MNI or other coordinate systems, such as scanner coordinate system or FreeSurfer surface coordinate system, to define a target. Specifying the coordinate at the edit box in the GUI and then click Go to move the TMS coil.
As briefly stated above, there are actually two TMS coil objects in this GUI representing the one for visualization and the other one for e-field calculation. These two coils can be moved together if the "AT" checkbox is checked.
If such auto-tracking function is not enabled, you will move only the TMS coil for visualization. The figure below illustrates that only the coil object for visualization (in yellow) is moved while the "strcoil" object, the object for e-field modeling, remains at the old position and orientation.
To update the "strcoil" object, the TMS coil for e-field calculation, you can click the U to update its position. With auto-tracking, strcoil object is always updated.
Once a target is define, click Go button to move the TMS coil object for visualization. NOTE this "move" only changes the TMS coil for visualization. The actual TMS coil definition for e-field calculation, strcoil, is not changed.
Then, you update the strcoil such that it aligns with the TMS coil object for visualization.
The process of first changing 'TMS coil object' and then updating 'strcoil' can be combined together by toggling the automatic tracking AT option in the GUI.
With a specified location, TMS target can be further tuned by allowing vertical rotation, horizontal rotation, moving closer/farther from the surface, and rotation around an axis. This is done by using the tuning options in the GUI.
Specifically, this is done by using either a slider or the edit box at the GUI. Four options are available:
- Rotation: this is rotating the TMS coil around the TMS coil axis. The values are in degree.
- Offset: this is increasing or decreasing the distance between the TMS coil and the scalp along the TMS coil axis. The values are in millimeter.
-
Tilt vertically: this is a tilting the TMS coil vertically (toward the head vertex) along a circle with the radius equal to the distance between the current position and origin. The values are in degree.
-
Tilt horizontally: this is a tilting the TMS coil horizontally (perpendicular to the direction of moving toward the head vertex) along a circle with the radius equal to the distance between the current position and origin. The values are in degree.
Once TMS target is defined and tuned, the position and orientation can be added to a table by clicking + button
No target in the table.
One target is added.
Two targets are added.
NOTE: Targets defined here can be sent to Brainsight via a text file. Also, targets defined in Brainsight can be imported via a text file. Remember to put all targets in the scanner coordinate system.
Now calculate the E-fields, including the total strength, tangential and normal components of the e-field. Results will be displayed automatically as an overlay with values. We first need to confirm if all necessary components are prepared for e-field calculation. For example, the figure below shows that head models are not prepared (a red light next to it), so no e-field can be calculated.
After preparing the head model by clicking Prepare head model button, we are ready to calculate the e-field. NOTE the TMS target will be the one selected in the table!
This calculation can take minutes to complete. As it is calculating, the light next to it will turn yellow.
Once e-field is calculated, the light will turn green.
Now e-field can be visualized. Note that we chose the total e-field, which is the root-mean-squares of the directional components. Clicking the check box next to the e-field Calc. button shows the e-field distribution.
Coil objects may obscure the view. So un-check coil objects to better illustrate the e-field distribution.
You can switch the component for visualization. For example, checking the tangential component strength distribution.