-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunHCPPipeline.sh
executable file
·153 lines (120 loc) · 3.5 KB
/
runHCPPipeline.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/bash
SCRIPT_NAME=$(basename ${0})
usage()
{
cat << EOF
Run HCP minimal processing pipeline for the Depression Connectome Project.
Usage: ${SCRIPT_NAME} --subj=<subject folder name> --odir=<output directory>
PARAMETERs ( [] = optional ):
[--help] Displays usage and parameter options
--subj=<subject-folder-name> REQUIRED. Subject folder name (assumes that the
parent directory is located /ifs/faculty/narr/schizo/CONNECTOME.
If this is not the case, please use --pathtodir)
--odir=<output-dir> REQUIRED. Output directory (full path is recommended).
**TO BE DEPRECATED AFTER SERVER SETUP**
[--pathtodir=<path-to-dir>] Path to subject folder (do not include subject
folder in the path)
[--stages=<stages>] Stages/Processes to be run.
Separated by commas (no space!).
Options: PreFreeSurfer, FreeSurfer,
PostFreeSurfer, fMRIVolume, fMRISurface,
DiffusionPreprocessing, TaskfMRIAnalysis.
Default: ALL
EOF
}
get_options()
{
local arguments=($@)
local index=0
local numArgs=${#arguments[@]}
local argument
while [ ${index} -lt ${numArgs} ] ; do
argument=${arguments[index]}
case ${argument} in
--help)
usage
exit 1
;;
--subj=*)
subjfolder=${argument#*=}
index=$(( index + 1))
;;
--pathtodir=*)
pathtodir=${argument#*=}
index=$(( index + 1))
;;
--odir=*)
outputdir=${argument#*=}
index=$(( index + 1))
;;
--stages=*)
stages=${argument#*=}
index=$(( index + 1))
;;
*)
usage
echo "ERROR: ${argument} is unrecognizable"
exit 1
;;
esac
done
local error_msgs=""
# STAGES=`echo $stages | tr ',' ' '`
# echo $STAGES
declare -a arr=("PreFreeSurfer" "FreeSurfer" "PostFreeSurfer" "fMRIVolume" "fMRISurface" "DiffusionPreprocessing" "TaskfMRIAnalysis")
if [ -z ${subjfolder} ]; then
error_msgs+="\nERROR: <subject-folder-name> not specified"
fi
if [ -z ${outputdir} ]; then
error_msgs+="\nERROR: <output-dir> not specified"
fi
if ! [ -z ${stages} ]; then
STAGES=`echo $stages | tr ',' ' '`
for i in $(echo ${stages} | sed "s/,/ /g"); do
if ! [[ " ${arr[*]} " == *"$i"* ]]; then
error_msgs+="\nERROR: Stage does not belong in list"
fi
done
fi
if [ -z ${stages} ]; then
STAGES='PreFreeSurfer FreeSurfer PostFreeSurfer fMRIVolume fMRISurface DiffusionPreprocessing TaskfMRIAnalysis'
fi
#if ! [ -d ${outputdir} ]; then
# echo "Directory ${outputdir} not found"
# exit 1
#fi
if [ ! -z "${error_msgs}" ] ; then
usage
echo -e ${error_msgs}
echo ""
exit 1
fi
echo ""
echo " Subject folder name: ${subjfolder}"
echo " Path to subject folder: ${pathtodir}/"
echo " Running: ${STAGES}"
echo ""
}
if [ -z ${pathtodir} ]; then
pathtodir=/ifs/faculty/narr/schizo/CONNECTOME/
fi
main()
{
get_options $@
#get actual study folder
DIR="${pathtodir}/${subjfolder}/"
[[ -z `find $DIR -type d -name "*KNARR*" ` ]]
StudyFolder=`find $DIR -type d -name "*KNARR*" `
echo " Study folder with DICOM files: ${StudyFolder}"
LICENSE="CindOjuhSN1s"
SUBJ=`echo "${subjfolder}" | tr _ T`
echo " BIDS-compliant subject ID: $SUBJ"
if [[ -d ${outputdir} ]]; then
echo "${outputdir} directory already exists. Please choose another directory name or delete previous folder."
exit 1;
fi
mkdir $outputdir
# run docker
docker run -ti --rm -v ${StudyFolder}:/dataset -v ${outputdir}:/output yeunkim/hcppipelines_v1.1 /dataset /output -subjID ${SUBJ} -dataset DEPRESSION --license_key ${LICENSE} --n_cpus 4 --stages ${STAGES}
}
main $@