Bash script to batch process structural MRI (sMRI) brain scans using FastSurfer's segmentation pipeline
FastSurfer can be installed using several different ways, but the following script was primarily developed, tested, and run using FastSurfer on Docker on WSL 2 on a Windows 10 host machine. However, this script will also work with FastSurfer on Docker on a native Linux installation as well. The script was developed, tested, and run on a machine with the following specifications:
| Operating System (OS) | Processor (CPU) | RAM | Graphics Card (GPU) | Storage |
|---|---|---|---|---|
| Windows 10 | Intel Core i9-8950 HK @ 2.90 GHz | 16.0 GB | NVIDIA GeForce GTX 1070 (8 GB) | 500 GB SSD + 1.82 TB HDD |
Steps to run the run_fastsurfer_custom_sample.sh bash script from an installation from Docker:
-
Install Docker for the respective host Operating System that you are running on by following the instructions on the Docker website.
-
Run the following command in an Ubuntu terminal:
docker pull deepmi/fastsurfer:gpu-latest. Make sure that the Docker engine is first running, otherwise the command may not work. Refer to DockerDocs to help debug any Operating System-specific issues. This command will pull the latest Docker image of FastSurfer with GPU support. If running on CPU, utilize the following command:docker pull deepmi/fastsurfer:latest. -
Download the ADNI dataset and place all of the images inside of a folder called
ExtractedAll. -
List the absolute file paths of all the images that you would like to run through the pipeline within the
images_paths.txtfile with the file path of each image on a separate line. Since this script was run on ADNI T1-weighted sMRI images, this script handles the images best in the folder/file structure that ADNI organized them with all of the DICOM slices for one image in a directory named with the image ID.- Note: This script assumes that the paths in the
images_paths.txtfile are all in the Windows-style path format. The script will convert these Windows-style paths to Unix-style ones as one of the first steps. In order to run this on Unix-style paths, there are two options: either convert all of the paths to Windows-style paths with thewslpath -w <path-to-folder-with-dcm-files>command or change line 24 of the script.
- Note: This script assumes that the paths in the
-
Run the following command to run the script:
./run_fastsurfer_custom_sample.sh -
The output is stored in a folder called
ExtractedAllOutputwhich is created at the same directory level asExtractedAll.