High-Performance Computing at the NIH
GitHub YouTube @nih_hpc RSS Feed
SimNIBS on Biowulf & Helix

Quick Links
Description

SimNIBS is used to simulate non-invasive brain stimulation. Calculations of the electric field induced by transcranial magnetic stimulation (TMS) and transcranial direct current stimulation (tDCS) are supported. It includes

The basic workflow of a SimNIBS analysis:

simnibs workflow

There may be multiple versions of SimNIBS available. An easy way of selecting the version is to use modules. To see the modules available, type

module avail SimNIBS 

To select a module use

module load simnibs/[version]

where [version] is the version of choice.

Environment variables set

Dependencies

Dependencies are loaded automatically by the SimNIBS module and set up their respective environments.

$SIMNIBS_GMSH_OPTIONS points to a file that can be copied to ~/.gmsh-options to change the default options for Gmsh to SimNIBS standard.

References

Documentation

Quickstart

Set up the environment and copy the example data set

biowulf$ module load simnibs
Bash users should now type: 
 source $FREESURFER_HOME//SetUpFreeSurfer.sh
Csh/tcsh users should now type:
source $FREESURFER_HOME/SetUpFreeSurfer.csh 
[+] Loading simnibs 2.0.0

biowulf$ source $FREESURFER_HOME//SetUpFreeSurfer.sh
-------- freesurfer-Linux-centos6_x86_64-stable-pub-v5.3.0 --------
Setting up environment for FreeSurfer/FS-FAST (and FSL)
FREESURFER_HOME   /usr/local/apps/freesurfer/5.3.0
FSFAST_HOME       /usr/local/apps/freesurfer/5.3.0/fsfast
FSF_OUTPUT_FORMAT nii.gz
SUBJECTS_DIR      /usr/local/apps/freesurfer/5.3.0/subjects
MNI_DIR           /usr/local/apps/freesurfer/5.3.0/mni
FSL_DIR           /usr/local/apps/fsl/5.0.9/fsl

biowulf$ cp -r $SIMNIBS_TESTDATA .
biowulf$ cd simnibs2.0_example
biowulf$ cp $SIMNIBS_GMSH_OPTIONS ~/.gmsh-options

The first step would usually be the construction of a 3D mesh from MRI images. Since this step is time consuming, it should be run as a batch job. Create a batch script simiar to the following

#! /bin/bash
#SBATCH --time=18:00:00
#SBATCH --mem=10G

# this file is make_mesh.sh

module load simnibs || exit 1
source $FREESURFER_HOME//SetUpFreeSurfer.sh

cd /data/$USER/test_data/simnibs/simnibs2.0_example
mkdir new_mesh
cd new_mesh
mri2mesh --all almi5 ../org/almi5_T1fs.nii.gz ../org/almi5_T2.nii.gz

and submit it as a batch job with

biowulf$ sbatch make_mesh.sh

A more elaborate reconstruction script is included in the example directory (run_headreco).

Since the example directory already contains a mesh reconstruction of the example data, we can proceed with the tutorial without waiting for the batch job to finish. This next part uses the SimNIBS GUI and we will run it on an interactive node. Since this is a GUI program, using NX to connect to biowulf is likely to give better resonsiveness.

biowulf$ sinteractive --x11 --mem=10g --constraint=gpuk20x --gres=gpu:k20x:1
node$ module load simnibs
node$ source $FREESURFER_HOME//SetUpFreeSurfer.sh
node$ Simnibs

This will start the following GUI:

GUI 1

Click 'Browse' and load the almi5.msh mesh. The model will appear in the righ box. Note that loading the head model can be slow.

GUI 2

To set up a TMS simulation click 'Add TMS Poslist', then click on 'Browse' to select a coil file for the instrument used. Then double click the position column to open the position window. Next double click the head to select the position where the coil center will be simulated. Double click again to select the direction of the coil handle.

GUI 2

Then select 'Run' and wait for the simulation to run. The result can be visualized with gmsh. For opimal gmsh settings, copy the SimNIBS provided .gmsh_options file first

node$ cp $SIMNIBS_GMSH_OPTIONS ~/.gmsh-options
node$ gmsh simnibs_sim/almi5_001-0001_Magstim-70mm-Fig8-measured_scalar_160411-154729_elm_merge.msh

With some custom settings an image such as the following can be rendered by gmsh. Note however that gmsh performance on a remote server is relatively poor.

GUI 2