-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathlung_extraction.sh
64 lines (40 loc) · 1.27 KB
/
lung_extraction.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
#!/bin/bash
red='\033[1;31m'
green='\033[1;32m'
reset='\033[0m]' #No Color
input_dir=$1
output_dir=$2
# check if the input directory exists and it is provided
if [ -z "$input_dir" ]; then
echo -e "${red}Error! Input directory not set${reset}"
exit 1
elif [ ! -d "$input_dir" ]; then
echo -e "${red}Error! Input directory not found${reset}"
exit 1
fi
# check if the output directory exists and it is provided
if [ -z "$output_dir" ]; then
echo -e "${red}Error! Output directory not set${reset}"
exit 1
# comment the following lines if
# the output directory could not exist
elif [ ! -d "$output_dir" ]; then
echo -e "${red}Error! Output directory not found${reset}"
exit 1
fi
# list all the pickle files into the input directory
input_files=$(ls "$input_dir")
echo "Found ${#input_files[@]} files to process"
# apply the pipeline on the input files
for file in $input_files; do
printf "* Processing $file ... "
f="${file%%.nrrd}"
python3 -m CTLungSeg.lung_extraction --input="$input_dir$file" --output="$output_dir$f.nrrd"
if [ "$?" = 0 ]; then
echo -e "${green}[done]${reset}"
else
echo -e "${red}[failed]${reset}"
exit 1 # you can omit this line if you want to catch
# possible errors into the log without an exit
fi
done