47. TMS E‐field modeling with interactive TMS coil placement - fahsuanlin/labmanual GitHub Wiki

We use the Matlab toolbox provided by Drs. Sergey N Makarov and Aapo Nummenmaa to calculate the induced electric field in TMS.

0. Prepare TMS coil model

We will model the electric field generated by the MRi-B91 coil (MagVenture). Therefore, we need to define the coil geometry.

We created coil.mat and coilCAD.mat by running coil03_MagVenture_MRiB91.m (provided by TMS toolbox inside the Coil folder).

https://github.com/fahsuanlin/labmanual/blob/master/images/MRi-B91_coil.png

1. Prepare an anatomical model.

1.1 Geometries preparation

[This script file] prepares the geometries needed for BEM models. The surfaces include:

  • outer skin (outer_skin.surf)
  • outer skull (outer_skull.surf)
  • inner skull (inner_skull.surf)
  • left hemisphere pial surface (surf/lh.orig)
  • right hemisphere pial surface (surf/rh.orig)

The first three files were created at the bem folder of the subject's FreeSurfer recon. See EEG/SEEG modeling pages for details creating these files.

The last two files were created at the surf folder of the subjects' FreeSurfer recon. automatically.

https://github.com/fahsuanlin/labmanual/blob/master/images/s001_bem.png

[This script file] shows the head/brain geometries.

1.2 Tissue parameter setup

The file about tissue conductivity must be provided with matched definition. For example, the tissue_index.txt file was for subject 's002', who had a few mat files defining the head/brain geometries. These mat files were created from the procedure above. Associated with these boundaries, conductivity must be specified. We define a few boundaries 'Freespace', 'Skin', 'Skull', 'GM_LH', and 'GM_RH' here.

>Skin : s001_skin.mat : 0.4650 : FreeSpace
>Skull : s001_skull.mat : 0.010 : Skin
>GM_LH : s001_gm_lh.mat : 0.2750 : Skull
>GM_RH : s001_gm_rh.mat : 0.2750 : Skull

2. Run the following scripts sequentially

2.1 Load model

bem0_load_model.m loads the model.

2.2 Setup TMS coil

bem1_setup_coil_prep_fhlin.m prepares the brain surfaces and a TMS coil model to allow for interactive TMS coil placement and orientation.

  • 2.2.1. click 'x' to select the variable 'coil_patch' to create the coil object
  • 2.2.2. rotate/move the TMS coil object in the Move 3D object window

https://github.com/fahsuanlin/labmanual/blob/master/images/s001_tms_coil_placement.png

  • 2.2.3. export the 12-parameter rigid body transformation matrix 'object_xfm' to the workspace by click the 'export' button.

bem1_setup_coil_fhlin.m prepares the TMS coil and brain geometries for calculation.

Remember to check the following line to define the tissue to be rendered. This string is defined in the tissue_index.txt file (see above).

tissue_to_plot = 'GM_LH';

https://github.com/fahsuanlin/labmanual/blob/master/images/s001_brain_coil.png

2.3 Charge engine

bem2_charge_engine.m charges the computation engine.

2.4 Calculate fields

The total electric field is shown here.

https://github.com/fahsuanlin/labmanual/blob/master/images/s001_brain_coil_e.png

This script shows the total electric field on the cortical surface using our toolbox.

https://github.com/fahsuanlin/labmanual/blob/master/images/s001_brain_coil_e_fhlin.png