-
Notifications
You must be signed in to change notification settings - Fork 0
/
seglungc.sh
executable file
·68 lines (45 loc) · 1.71 KB
/
seglungc.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
#$ -S /bin/bash
#
#
#
INPUTIMAGE=$1
RESDIR=$2
FINALMASK=$3
LUNGNAME=$4
OUTPUTPREFIX=$2/$4
MYDO(){
# echo "-------------------------------------------------"
# echo $*
# echo "-------------------------------------------------"
$*
echo ">>>>>>>>> DONE <<<<<<<<<<<<<<<<"
}
echo Segment lung ...
C3D=/home/songgang/pkg/bin/c3d
UTILITIESDIR=/home/songgang/project/tustison/Utilities/gccrel
# UTILITIESDIR=/home/songgang/project/tustison/Utilities/bin64_to_be_removed
TMPIMAGE=${OUTPUTPREFIX}_halfsize.nii.gz
LUNGMASK=${OUTPUTPREFIX}_halfsize_lungs.nii.gz
AIRWAYMASK=${OUTPUTPREFIX}_halfsize_airways.nii.gz
SEPARATEMASK=${OUTPUTPREFIX}_halfsize_separate.nii.gz
SMOOTHMASK=${OUTPUTPREFIX}_halfsize_smooth.nii.gz
MYDO $C3D $INPUTIMAGE -interpolation Linear -resample 50% -o $TMPIMAGE
echo 1
MYDO ${UTILITIESDIR}/ExtractLungs $TMPIMAGE $LUNGMASK
echo 2
MYDO ${UTILITIESDIR}/SegmentAirways $TMPIMAGE $LUNGMASK $AIRWAYMASK
echo 3
MYDO ${UTILITIESDIR}/SeparateLungs $TMPIMAGE $AIRWAYMASK $SEPARATEMASK
echo 4
MYDO ${UTILITIESDIR}/SmoothLungs $SEPARATEMASK $SMOOTHMASK 15
echo 5
atmp=`$C3D $INPUTIMAGE -info`
btmp=`echo $atmp | awk '{sub(/\[/, ""); sub(/\]/,""); sub(/\,/,""); sub(/\,/, ""); sub(/\;/,""); print $5"x"$6"x"$7}'`
MYDO $C3D $SMOOTHMASK -interpolation NearestNeighbor -resample $btmp -o $FINALMASK
MYDO ${UTILITIESDIR}/ChangeImageInformation 3 $FINALMASK $FINALMASK 4 $INPUTIMAGE
# remove the vessels from the
echo Removing vessels ...
VesselLowerThres=-50 # need to confirm this with Eduardo!
MYDO $C3D $INPUTIMAGE -threshold $VesselLowerThres Inf 1 0 $FINALMASK -as M -multiply -threshold 2 3 1 0 -as V -scale 5 -push V -scale -1 -shift 1 -push M -times -add -o $FINALMASK
MYDO ln -fs $INPUTIMAGE $2/$4.nii.gz