forked from FeiX-OvO/NPH_Segmentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
skull_strip.sh
39 lines (36 loc) · 1.45 KB
/
skull_strip.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
img=$1
echo ${img}
intensity=0.01
outfile=$2
echo ${outfile}
tmpfile=`mktemp`
# Thresholding Image to 0-100
fslmaths "${img}" -thr -10.000000 -uthr 150.000000 "${outfile}"
# Creating 0 - 100 mask to remask after filling
fslmaths "${outfile}" -bin "${tmpfile}";
fslmaths "${tmpfile}.nii.gz" -bin -fillh "${tmpfile}"
# Presmoothing image
fslmaths "${outfile}" -s 1 "${outfile}";
# Remasking Smoothed Image
fslmaths "${outfile}" -mas "${tmpfile}" "${outfile}"
# Running bet2
bet2 "${outfile}" "${outfile}" -f ${intensity} -v
# Using fslfill to fill in any holes in mask
fslmaths "${outfile}" -bin -fillh "${outfile}_Mask"
fslmaths "${outfile}_Mask" -bin -fillh "${outfile}_Mask"
# Using the filled mask to mask original image
fslmaths "${img}" -mas "${outfile}_Mask" "${outfile}"
######################
## If no pre-smoothing
######################
# outfile_nosmooth="Head_Image_1_SS_0.01_nopresmooth"
# fslmaths "$img" -thr 0.000000 -uthr 100.000000 "${outfile_nosmooth}"
# # Creating 0 - 100 mask to remask after filling
# fslmaths "${outfile_nosmooth}" -bin "${tmpfile}";
# fslmaths "${tmpfile}" -bin -fillh "${tmpfile}"
# # Running bet2
# bet2 "${outfile_nosmooth}" "${outfile_nosmooth}" -f ${intensity} -v
# # Using fslfill to fill in any holes in mask
# fslmaths "${outfile_nosmooth}" -bin -fillh "${outfile_nosmooth}_Mask"
# # Using the filled mask to mask original image
# fslmaths "$img" -mas "${outfile_nosmooth}_Mask" "${outfile_nosmooth}"