forked from HBClab/RestingState
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakeROI.sh
More file actions
executable file
·74 lines (59 loc) · 2.19 KB
/
makeROI.sh
File metadata and controls
executable file
·74 lines (59 loc) · 2.19 KB
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
68
69
70
71
72
73
#!/bin/bash
#to check how big the ROI is that you made, use fslstats with -V option, this gives you number of voxels in anatomical space
#using a 14mm diameter with this script will give you ~125 voxel ROI, which generally works well
Usage() {
echo "Usage: makeROI <x y z> <mm or vox> <diameter of ROI (6, 10, 14, 18, 22mm)> <sphere or box> <output name>"
exit
}
[ "$1" = "" ] && Usage
[ "$2" = "" ] && Usage
[ "$3" = "" ] && Usage
[ "$4" = "" ] && Usage
[ "$5" = "" ] && Usage
[ "$6" = "" ] && Usage
[ "$7" = "" ] && Usage
echo $1 $2 $3 $4 $5 $6 $7
#Assumes you are running this from the RestingState Scripts folder
myscriptdir=`perl -e 'use Cwd "abs_path";print abs_path(shift)'`
myROIdir=${myscriptdir}/ROIs
fslstdimage='MNI152_T1_2mm_brain'
if [ $4 = "vox" ]
then
fslmaths ${FSLDIR}/data/standard/${fslstdimage} -roi ${1} 1 ${2} 1 ${3} 1 0 1 ${myROIdir}/${7}
if [ $6 = "box" ]
then
fslmaths ${myROIdir}/${7} -kernel ${6} ${5} -fmean ${myROIdir}/${7}
fslmaths ${myROIdir}/${7} -bin ${myROIdir}/${7}
fi
if [ $6 = "sphere" ]
then
n1=`expr ${5} - 2`
n2=`expr ${n1} / 2`
fslmaths ${myROIdir}/${7} -kernel ${6} ${n2} -fmean ${myROIdir}/${7}
fslmaths ${myROIdir}/${7} -bin ${myROIdir}/${7}
fi
elif [ $4 = "mm" ]
then
echo ${1} ${2} ${3} > ${myROIdir}/tmp.txt
newvox=`std2imgcoord -img ${FSLDIR}/data/standard/${fslstdimage} -std ${FSLDIR}/data/standard/${fslstdimage} ${myROIdir}/tmp.txt -vox | head -1`
echo $newvox > ${myROIdir}/tmp.txt
newx=`cat ${myROIdir}/tmp.txt | cut -f1 -d " "`
newy=`cat ${myROIdir}/tmp.txt | cut -f2 -d " "`
newz=`cat ${myROIdir}/tmp.txt | cut -f3 -d " "`
echo "The voxel coordinates are: $newx $newy $newz"
fslmaths ${FSLDIR}/data/standard/${fslstdimage} -roi ${newx} 1 ${newy} 1 ${newz} 1 0 1 ${myROIdir}/${7}
if [ $6 = "box" ]
then
fslmaths ${myROIdir}/${7} -kernel ${6} ${5} -fmean ${myROIdir}/${7}
fslmaths ${myROIdir}/${7} -bin ${myROIdir}/${7}
fi
if [ $6 = "sphere" ]
then
n1=`expr ${5} - 2`
n2=`expr ${n1} / 2`
fslmaths ${myROIdir}/${7} -kernel ${6} ${n2} -fmean ${myROIdir}/${7}
fslmaths ${myROIdir}/${7} -bin ${myROIdir}/${7}
fi
rm -r ${myROIdir}/tmp.txt
fi
echo "Finished!"