- SimNIBS and any additional dependencies (depending on version): https://simnibs.github.io/simnibs/build/html/installation/simnibs_installer.html
- The SimNIBS example dataset is found at https://simnibs.github.io/simnibs/build/html/dataset.html
- FreeSurfer: https://surfer.nmr.mgh.harvard.edu/fswiki/DownloadAndInstall
- For Windows users, it is possible to download and use FreeSurfer through the Linux subsystem by following the instructions here: https://surfer.nmr.mgh.harvard.edu/fswiki/FS7_wsl
- In the Linux subsystem / Terminal, navigate to the folder where the NifTI files are located in the SimNIBS example dataset
- In the Linux subsystem / Terminal, run
recon-all -subjid ernie -all -i org/ernie_T1.nii.gz -T2 org/ernie_T2.nii.gz- This should generate a
fs_erniefolder in theSUBJECTS_DIRyou specified during the FreeSurfer Installation - If you get a permission denied error, add
export SUBJECTS_DIR=<path to acceessable folder>to the same file you addedsource $FREESURFER_HOME/SetUpFreeSurfer.shwhile setting up freesurfer
- This should generate a
- In the Linux subsystem / Terminal, run
charm ernie org/ernie_T1.nii.gz org/ernie_T2.nii.gz --fs-dir <path to fs_ernie folder>
- In MATLAB, Open “run_subj.m”
- In MATLAB, change the filepaths between
%%%%% CHANGE TAP PARAMETER HERE: Begin %%%%%and%%%%% CHANGE TAP PARAMETER HERE: End %%%%%as needed- Set
Scale_Efield_to_Valueto the desired E-field value in V/m (can use 100 to test) - If not running on a Linux cluster, comment out the line starting with
setenv
- Set
- Change
subjects/Ernie_charmor the subjects subfolder corresponding to the appropriate pipeline tosubjects/ernieand copy theerniefolder from the example dataset tosubjects/ernie - Copy
M1_mask_TMS_target.nii.gzfromTAP/subjects/Ernie_headrecointo “subjects/ernie” - In MATLAB, run
run_subj('ernie', 'subjects', 'M1', 'M1_mask_TMS_target.nii.gz', 1)- This should generate a
ernie_M1folder, aernie_M1_scirunfolder, and at least oneM1_HTX.Xfolder
- This should generate a
- For the SimNIBS head mesh, see https://simnibs.github.io/simnibs/build/html/tutorial/advanced/fix_affine_registration.html for quality control
- Open
subjects/ernie/M1_HT0.0/ernie_TMS_optimize_MagVenture_Cool-B65.msh- Check that the target is at the expected location
- Check that the coil is oriented such that the primary E-field induced by the coil points into the target gyrus
- Many coils have arrows on them indicating the current direction
- For monophasic pulses, the primary E-field points in the opposite direction as the current
- For biphasic pulses, the primary E-field points in the same direction as the current
Custom MATLAB code to determine an optimal scalp placement of a TMS coil on the computational model of the subject's head. (1) Optimal coil placement is chosen based on maximizing the TMS-induced electric field in a brain region of interest which is derived from individual fMRI peak activity and computed prospectively for neuronavigation-supported TMS experiments. (2) The code's functionality allows also for accuracy assessment of the coil placement recorded during and analyzed after a TMS session.
Dependencies:
- SimNIBS 3.2.X
- 'Tools for NIfTI and ANALYZE image' for loading structural MRI data sets (nii files) version 1.27.0.0 (from MATHWORKS MATLAB Central)
For SimNIBS version < 3.2.5 users, the option to control the smoothness of the scalp surface (scalp_normals_smoothing_steps) to allow changing the scalp tangential plane from MATLAB is not available. However, there is a simple patch you can do yourself and described here: simnibs/simnibs#42 and change smooth=1 to smooth=20 for example.