Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

fsl fslmath mask sphere

if [ $# -lt 5 ]
then
    echo "Usage: $0 <input file> <x_pos> <y_pos> <z_pos> <radius_mm>"
    echo "An image of the same size as the input will be created"
    echo "containing a binary spherical mask"
    echo "Example: $0 perfusion 63 63 15 10"
    echo "creates perfusion_sphere_mask_x63_y63_z15_10mm.nii.gz"
    echo "perfusion_sphere_mask_x63_y63_z15 is centered at coordinates" 
    echo "x63, y63, z15 and of radius 10 mm"
    exit 1
fi

img=$1
x_pos=$2
y_pos=$3
z_pos=$4
radius=$5

img_stem=$(basename -s .nii.gz ${img})

# Create an image (temp_one) of the same dimensions as the input, but filled with ones.
fslmaths ${img} -mul 0 -add 1 temp_one

# Create an image (temp_point) containing a single voxel at the specified voxel coordinates
# (Voxel coordinates are whole numbers, and can be viewed in fsleyes)
fslmaths  temp_one -roi ${x_pos} 1 ${y_pos} 1 ${z_pos} 1 0 1 temp_point

# Create a binary sphere mask around the center specified by temp_point
fslmaths temp_point -kernel sphere ${radius} -dilM ${img_stem}_sphere_mask_x${x_pos}_y${y_pos}_z${z_pos}

# Remove intermediate files
rm temp_one.nii.gz temp_point.nii.gz
Comment

PREVIOUS NEXT
Code Example
Shell :: cashier paddle installation 
Shell :: git conflicts in yarn-lock 
Shell :: terrminal generate uudi 
Shell :: git synchronize a branch in a fork 
Shell :: chow install cal inlunix 
Shell :: linux monitor ttyusb0 
Shell :: create json from console 
Shell :: change git to github 
Shell :: nodemon:%20command%20not%20found 
Shell :: left navbar not showing in ubuntu 
Shell :: kubernetes short call 
Shell :: start a new shell to examine the situation 
Shell :: gradle dolast 
Shell :: git remote repo from the cmd prompt 
Shell :: cmd mac pdf reader 
Shell :: xgb feature importance 
Shell :: ubuntu mouse lost focus 
Shell :: Command to install parse-url module 
Shell :: unix symbolic link 
Shell :: sed replace from match 
Shell :: how to change home directory of git bash 
Shell :: git how to learn 
Shell :: ubuntu extract .tar.xz file 
Shell :: pnpm upgrade 
Shell :: git push not working 
Shell :: git hub set up 
Shell :: find mac address from ip powershell 
Shell :: packet tracer 2.7.1 Full Config BC-2 Router 
Shell :: list directory xargs linux 
Shell :: apt mailbox debian 10 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =