Set of containerized scripts to extract mesh surfaces from T1/T2-weighted MRI scans. Uses SimNIBS under the hood, plus some smaller scripts. The surfaces are then used in another project: https://github.com/bast/tms-location
You need an installation of Apptainer (e.g. following the quick installation). Alternatively, SingularityCE should also work.
First download the container image (ending with *.sif) from here: https://github.com/bast/MRI-extract-surfaces/releases - then make the container image executable.
Here is an example which uses the container with the T1_ernie.nii.gz
example
data file:
$ ./extract-surfaces.sif ernie /home/user/ernie_data T1_ernie.nii.gz
The above example reads T1_ernie.nii.gz
and creates the directories
m2m_ernie
and /home/user/ernie_data
. On my computer the process takes
30-60 minutes. The folder m2m_ernie
is created in the same directory as the
container image and contains many output files from
SimNIBS.
The input-file does not have to be gzipped, you can also use a plain NIfTI file:
$ ./extract-surfaces.sif ernie /home/user/ernie_data T1_ernie.nii
If you have a T2-weighted MRI scan as well, you can use both T1 and T2 data as input:
$ ./extract-surfaces.sif ernie /home/user/ernie_data T1.nii.gz T2.nii.gz
The generated directory /home/user/ernie_data
contains the following files:
ernie_data/
├── eeg-positions
│ ├── easycap_BC_TMS64_X21.csv
│ ├── easycap_BC_TMS64_X21.geo
│ ├── EEG10-10_Cutini_2011.csv
│ ├── EEG10-10_Cutini_2011.geo
│ ├── EEG10-10_Neuroelectrics.csv
│ ├── EEG10-10_Neuroelectrics.geo
│ ├── EEG10-10_UI_Jurak_2007.csv
│ ├── EEG10-10_UI_Jurak_2007.geo
│ ├── EEG10-20_extended_SPM12.csv
│ ├── EEG10-20_extended_SPM12.geo
│ ├── EEG10-20_Okamoto_2004.csv
│ ├── EEG10-20_Okamoto_2004.geo
│ ├── Fiducials.csv
│ └── Fiducials.geo
├── m2m_data
│ ├── data.msh
│ ├── final_tissues.nii.gz
│ ├── T1.nii.gz
│ └── toMNI
│ ├── Conform2MNI_nonl.nii.gz
│ ├── final_tissues_MNI.nii.gz
│ └── MNI2Conform_nonl.nii.gz
├── meshes
│ ├── 1001.txt
│ ├── 1002.txt
│ ├── 1003.txt
│ ├── 1005.txt
│ ├── 1006.txt
│ ├── 1007.txt
│ ├── 1008.txt
│ ├── 1009.txt
│ ├── 1010.txt
│ └── outside-surface.txt
└── VERSION
You can get the example dataset like this:
$ wget https://github.com/simnibs/example-dataset/releases/latest/download/simnibs4_examples.zip
I am not affiliated with SimNIBS but this container uses SimNIBS under the hood.
When you publish results based on SimNIBS, please cite Thielscher, A., Antunes, A. and Saturnino, G.B. (2015), Field modeling for transcranial magnetic stimulation: a useful tool to understand the physiological effects of TMS? IEEE EMBS 2015, Milano, Italy.
[!WARNING] SimNIBS is a research tool. Clinical usage is not supported or advised. In particular, SimNIBS was not tested to give accurate results in the presence of pathological condition. See also https://simnibs.github.io/simnibs/
To build the image, I have used this wonderful guide as starting point and inspiration.
I find it important that everybody can verify how the container image was built. And you can! You can inspect the definition file and all scripts which are all part of this repository.