-
Notifications
You must be signed in to change notification settings - Fork 2
/
run-maper-example-generate.sh
executable file
·121 lines (84 loc) · 3.28 KB
/
run-maper-example-generate.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
#!/usr/bin/env bash
ppath=$(realpath "$BASH_SOURCE")
pdir=$(dirname "$ppath")
pname=$(basename "$ppath")
set -e
cat <<EOF
This program generates a test script (run-maper-example.sh) in the
present working directory. Please edit the file and modify the
settings according to your local requirements. Then run it with
'bash run-maper-example.sh' or (more verbose) 'bash -vx
run-maper-example.sh'
The script will download a minimal atlas database (19 MByte) to the
present working directory and run MAPER single-threaded in quicktest
mode, writing to \$PWD/test/. It should finish in 45 minutes or
less.
For more extensive testing, consider setting \$quicktest to false and
\$threads to the number of available cores. The runtime will then be
approximately 120 minutes divided either by seven or by \$threads,
whichever is smaller.
Continue? Please enter 'y'
EOF
read reply
if [[ $reply != "y" ]] ; then echo "Not continuing" ; exit ; fi
echo
cat >run-maper-example.sh <<EOF
set -e
### Set paths here
##nix-path-goes-here##
# export PATH=/opt/mirtk/bin:\$PATH
# export PATH=/opt/niftyseg/seg-apps:\$PATH
### Set number of parallel threads (or set MAPERTEST_XARGS environment variable instead)
threads=1
### Set \$quicktest to false to run a full test
quicktest=TRUE
########
### For basic testing, nothing needs modifying below this line
########
ppath=\$(realpath "\$BASH_SOURCE")
pdir=\$(dirname "\$ppath")
pname=\$(basename "\$ppath")
[[ \$quicktest == "FALSE" ]] || quicktestarg="-quicktest"
[[ -z \$MAPERTEST_XARGS ]] && MAPERTEST_XARGS="xargs -L 1 -P \$threads"
msg () {
for msgline
do echo -e "\$pname: \$msgline" >&2
done
}
fatal () { msg "\$@" ; exit 1 ; }
usage() { echo \$usage ; fatal "\$@" ; }
tempdir () {
: \${TMPDIR:="/tmp"}
tdbase=\$TMPDIR/\$USER
test -e \$tdbase || mkdir -p \$tdbase
td=\$(mktemp -d \$tdbase/\$(basename \$0).XXXXXX) || fatal "Could not create temp dir in \$tdbase"
echo \$td
}
finish () {
[[ \$savewd -eq 1 ]] || rm -rf "\$td"
exit
}
### Check for MAPER and dependencies
type maper >/dev/null 2>&1 || fatal "MAPER not found. Please ensure maper is on executable path"
type mirtk >/dev/null 2>&1 || fatal "MIRTK not found. Please ensure mirtk binary is on executable path"
type seg_maths >/dev/null 2>&1 || fatal "NiftySeg not found. Please ensure seg_maths is on executable path"
### Download mini atlas
atlas=mini-atlas-n7r95
if [[ ! -e \$atlas.tar ]] ; then
dlcommand="wget -O -"
url=https://github.com/soundray/maper/releases/download/0.9.0-rc/\$atlas.tar
# url=https://soundray.org/maper/\$atlas.tar
type wget >/dev/null 2>&1 || dlcommand="curl -fL --output -"
\$dlcommand \$url >\$atlas.tar || fatal "Download failed. wget or curl must be installed"
fi
[[ ! -e \$atlas.tar ]] && fatal "No tarfile found -- something went wrong"
tar xf \$atlas.tar || fatal "Atlas unpacking failed"
set -v
launchlist-gen \\
\$quicktestarg -output-dir \$PWD/test -threads 1 \\
-src-base \$atlas -src-description \$atlas/source-description.csv \\
-tgt-base \$atlas -tgt-description \$atlas/test-target.csv \\
-launchlist launchlist.sh || fatal "Launchlist not generated"
time cat launchlist.sh | cut -d ' ' -f 2- | \${MAPERTEST_XARGS:-xargs -L 1 -P 1} maper | tee maper.log
EOF
echo "Script 'run-maper-example.sh' written."