Make spherical ROIs script

Sometimes it’s handy to create a sphere ROI from a given coordinate. This script does exactly that (how convenient!).

Note: the script uses “${FSLDIR}/data/standard/MNI152lin_T1_2mm_brain.nii.gz” as the reference mask. If the image you will apply the ROI to is of a different resolution, you can just edit the mask being used in the script easily.

To use it type (for example): source make_sphere_roi.sh ${FSLDIR}/data/standard/MNI152lin_T1_2mm_brain.nii.gz 48 89 35 10

Here is the header info which explains the script

#! /bin/sh
# note, to run this you have to type the following:
# source make_sphere_roi.sh <input_image.nii.gz> <x y z> <mm>
# <input image> is an image that has the same resolution as the image you want to apply the ROI to.
# NOTE: this image either has to be in the folder you are launching the command from, or has to have a full path.
# <x y z> are the ROI coordinates
# <mm> is the width of the ROI. If you will always want it to be the same (say 10mm), then you can just delete the $5 in the line starting with “echo”, and replace the ‘$5’ in the last line with the number you want (e.g. 10).

You can download the script here.