-
Notifications
You must be signed in to change notification settings - Fork 0
/
CheckForGdcFiles.sh
executable file
·96 lines (80 loc) · 2.15 KB
/
CheckForGdcFiles.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
#!/bin/bash
#
# Function description
# Show usage information for this script
#
usage() {
local scriptName=$(basename ${0})
echo ""
echo " Usage: ${scriptName} --checkdir=<check-dir>"
echo ""
}
#
# Function description
# Get the command line options for this script
#
# Global output variables
# ${checkdir} - directory to check
#
get_options() {
local scriptName=$(basename ${0})
local arguments=($@)
# initialize global output variables
unset checkdir
# parse arguments
local index=0
local numArgs=${#arguments[@]}
local argument
while [ ${index} -lt ${numArgs} ]; do
argument=${arguments[index]}
case ${argument} in
--help)
usage
exit 1
;;
--checkdir=*)
checkdir=${argument/*=/""}
index=$(( index + 1 ))
;;
*)
usage
echo "ERROR: Unrecognized Option: ${argument}"
exit 1
;;
esac
done
# check required parameters
if [ -z ${checkdir} ]; then
usage
echo "ERROR: <check-dir> not specified"
exit 1
fi
# report
echo "-- ${scriptName}: Specified command-line options - Start --"
echo " checkdir: ${checkdir}"
echo "-- ${scriptName}: Specified command-line options - End --"
}
#
# Main processing
#
main() {
get_options $@
local filesCheckedCount=0
local failuresCount=0
filelist=`find ${checkdir} -name "*.nii.gz" | grep --invert-match "_gdc"`
for image_file in ${filelist} ; do
filesCheckedCount=$(( filesCheckedCount + 1 ))
image_file_base=${image_file%.nii.gz}
gdc_file=${image_file_base}_gdc.nii.gz
if [ ! -f "${gdc_file}" ]; then
echo "FAILURE: ${gdc_file} should exist but does not"
failuresCount=$(( failuresCount + 1 ))
fi
done
echo "-- ${scriptName}: Results - Start --"
echo " filesCheckedCount: ${filesCheckedCount}"
echo " failuresCount: ${failuresCount}"
echo "-- ${scriptName}: Results - End --"
}
# Invoke the main function
main $@