-
Notifications
You must be signed in to change notification settings - Fork 14
/
pipeline_test.sh
executable file
·179 lines (144 loc) · 5.29 KB
/
pipeline_test.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/usr/bin/env bash
# ===============================================================================
# dMRIharmonization (2018) pipeline is written by-
#
# TASHRIF BILLAH
# Brigham and Women's Hospital/Harvard Medical School
# tbillah@bwh.harvard.edu, tashrifbillah@gmail.com
#
# ===============================================================================
# See details at https://github.com/pnlbwh/dMRIharmonization
# Submit issues at https://github.com/pnlbwh/dMRIharmonization/issues
# View LICENSE at https://github.com/pnlbwh/dMRIharmonization/blob/master/LICENSE
# ===============================================================================
EXIT()
{
echo ''
echo $1
exit 1
}
write_list()
{
CASELIST=$1
TMPFILE=/tmp/harm_caselist.txt
while IFS=, read -r img mask; do echo $CURRDIR/$img,$CURRDIR/$mask; done < $1 > $TMPFILE
mv $TMPFILE $CASELIST
}
# get version info
IFS=" = ", read -r _ v < ../../_version.py
__version__=`echo $v | xargs`
# download test data
test_data=connectom_prisma # change this value if test data name is changed
if [ ! -f ${test_data}.zip ]
then
# we have been providing the same test data for the last couple of releases
# so no need to spend time uploading test data with each release for the forseeable future
# rather download from v2.0
__version__=2.0
wget https://github.com/pnlbwh/dMRIharmonization/releases/download/v${__version__}/${test_data}.zip
fi
tar -xzvf ${test_data}.zip
cd ${test_data}
CURRDIR=`pwd`
# append path to image list and write back
write_list connectom.txt
write_list prisma.txt
### Run pipeline and obtain statistics when same number of matched reference and target images are used in
### tempalate creation and harmonization
# run test
../../harmonization.py \
--bvalMap 1000 \
--resample 1.5x1.5x1.5 \
--template ./template/ \
--ref_list connectom.txt \
--tar_list prisma.txt \
--ref_name CONNECTOM \
--tar_name PRISMA \
--nproc -1 \
--create --process --debug || EXIT 'harmonization.py with --create --process --debug failed'
# recompute statistics
../../harmonization.py \
--template ./template/ \
--ref_list connectom.txt.modified \
--tar_list prisma.txt \
--harm_list prisma.txt.modified.harmonized \
--ref_name CONNECTOM \
--tar_name PRISMA \
--stats || EXIT 'harmonization.py with --stats failed'
# ===============================================================================================================
### Run pipeline and obtain statistics when small set of matched reference and target images are used in template creation
### and a larger set (does not have to be mutually exclusive from the former) of target images are used in harmonization
# test the following advanced parameter
export TEMPLATE_CONSTRUCT_CORES=6
# --create and --debug block
../../harmonization.py \
--bvalMap 1000 \
--resample 1.5x1.5x1.5 \
--template ./template/ \
--ref_list connectom.txt \
--tar_list prisma.txt \
--ref_name CONNECTOM \
--tar_name PRISMA \
--travelHeads \
--nproc -1 \
--create --debug --force || EXIT 'harmonization.py with --create --debug --force failed'
../../harmonization.py \
--bvalMap 1000 \
--resample 1.5x1.5x1.5 \
--template ./template/ \
--ref_list connectom.txt \
--tar_list prisma.txt \
--ref_name CONNECTOM \
--tar_name PRISMA \
--travelHeads \
--nproc -1 \
--create --debug || EXIT 'harmonization.py with --create --debug failed'
# --process and --debug block
../../harmonization.py \
--bvalMap 1000 \
--resample 1.5x1.5x1.5 \
--template ./template/ \
--tar_list prisma.txt \
--tar_name PRISMA \
--ref_list connectom.txt \
--nproc -1 \
--process --debug --force || EXIT 'harmonization.py with --process --debug --force failed'
../../harmonization.py \
--bvalMap 1000 \
--resample 1.5x1.5x1.5 \
--template ./template/ \
--tar_list prisma.txt \
--tar_name PRISMA \
--ref_list connectom.txt \
--nproc -1 \
--process --debug || EXIT 'harmonization.py with --process --debug failed'
# ===============================================================================================================
# same bvalue, resolution block
cp connectom.txt.modified connectom_same.txt
cp prisma.txt.modified prisma_same.txt
../../harmonization.py \
--template ./template/ \
--ref_list connectom_same.txt \
--tar_list prisma_same.txt \
--ref_name CONNECTOM \
--tar_name PRISMA \
--nproc -1 \
--create --process || EXIT 'harmonization.py for same bvalue, resolution with --create --process failed'
# ===============================================================================================================
# compute statistics
../fa_skeleton_test.py -i connectom.txt.modified \
-s CONNECTOM -t template/ || EXIT 'fa_skeleton_test.py failed for modified reference'
../fa_skeleton_test.py -i prisma.txt \
-s PRISMA -t template/ || EXIT 'fa_skeleton_test.py failed for given target'
../fa_skeleton_test.py -i prisma.txt.modified.harmonized \
-s PRISMA -t template/ || EXIT 'fa_skeleton_test.py failed for harmonized target'
# now that all files are created, recompute statistics
../../harmonization.py \
--template ./template/ \
--ref_list connectom.txt.modified \
--tar_list prisma.txt \
--harm_list prisma.txt.modified.harmonized \
--ref_name CONNECTOM \
--tar_name PRISMA \
--stats || EXIT 'harmonization.py with --stats failed'
# ===============================================================================================================