Skip to content

Commit a12524d

Browse files
committed
first, complete multi-shell-harmonization test
1 parent 6db532f commit a12524d

1 file changed

Lines changed: 161 additions & 0 deletions

File tree

lib/tests/pipeline_test.sh

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
#!/usr/bin/env bash
2+
3+
# ===============================================================================
4+
# dMRIharmonization (2018) pipeline is written by-
5+
#
6+
# TASHRIF BILLAH
7+
# Brigham and Women's Hospital/Harvard Medical School
8+
# tbillah@bwh.harvard.edu, tashrifbillah@gmail.com
9+
#
10+
# ===============================================================================
11+
# See details at https://github.com/pnlbwh/dMRIharmonization
12+
# Submit issues at https://github.com/pnlbwh/dMRIharmonization/issues
13+
# View LICENSE at https://github.com/pnlbwh/dMRIharmonization/blob/master/LICENSE
14+
# ===============================================================================
15+
16+
17+
EXIT()
18+
{
19+
echo ''
20+
echo $1
21+
exit 1
22+
}
23+
24+
25+
write_list()
26+
{
27+
CASELIST=$1
28+
TMPFILE=/tmp/harm_caselist.txt
29+
while IFS=, read -r img mask; do echo $CURRDIR/$img,$CURRDIR/$mask; done < $1 > $TMPFILE
30+
31+
mv $TMPFILE $CASELIST
32+
}
33+
34+
# get version info
35+
IFS=" = ", read -r _ v < ../../_version.py
36+
__version__=`echo $v | xargs`
37+
38+
# download test data
39+
test_data=connectom_prisma # change this value if test data name is changed
40+
if [ ! -f ${test_data}.zip ]
41+
then
42+
# we have been providing the same test data for the last couple of releases
43+
# so no need to spend time uploading test data with each release for the forseeable future
44+
# rather download from v2.0
45+
__version__=2.0
46+
wget https://github.com/pnlbwh/dMRIharmonization/releases/download/v${__version__}/${test_data}.zip
47+
fi
48+
49+
tar -xzvf ${test_data}.zip
50+
51+
cd ${test_data}
52+
CURRDIR=`pwd`
53+
54+
# append path to image list and write back
55+
write_list connectom.txt
56+
write_list prisma.txt
57+
58+
### Run pipeline and obtain statistics when same number of matched reference and target images are used in
59+
### tempalate creation and harmonization
60+
# run test
61+
../../multi-shell-harmonization.py \
62+
--template ./template-multi/ \
63+
--ref_list connectom.txt \
64+
--tar_list prisma.txt \
65+
--ref_name CONNECTOM \
66+
--tar_name PRISMA \
67+
--nproc -1 \
68+
--create --process --debug || EXIT 'multi-shell-harmonization.py with --create --process --debug failed'
69+
70+
../../harmonization.py \
71+
--bvalMap 1000 \
72+
--resample 1.5x1.5x1.5 \
73+
--template ./template/ \
74+
--ref_list connectom.txt \
75+
--tar_list prisma.txt \
76+
--ref_name CONNECTOM \
77+
--tar_name PRISMA \
78+
--nproc -1 \
79+
--create --process --debug || EXIT 'harmonization.py with --create --process --debug failed'
80+
# ===============================================================================================================
81+
82+
### Run pipeline and obtain statistics when small set of matched reference and target images are used in template creation
83+
### and a larger set (does not have to be mutually exclusive from the former) of target images are used in harmonization
84+
85+
# test the following advanced parameter
86+
export TEMPLATE_CONSTRUCT_CORES=6
87+
88+
# --create and --debug block
89+
../../harmonization.py \
90+
--bvalMap 1000 \
91+
--resample 1.5x1.5x1.5 \
92+
--template ./template/ \
93+
--ref_list connectom.txt \
94+
--tar_list prisma.txt \
95+
--ref_name CONNECTOM \
96+
--tar_name PRISMA \
97+
--travelHeads \
98+
--nproc -1 \
99+
--create --debug --force || EXIT 'harmonization.py with --create --debug --force failed'
100+
101+
../../harmonization.py \
102+
--bvalMap 1000 \
103+
--resample 1.5x1.5x1.5 \
104+
--template ./template/ \
105+
--ref_list connectom.txt \
106+
--tar_list prisma.txt \
107+
--ref_name CONNECTOM \
108+
--tar_name PRISMA \
109+
--travelHeads \
110+
--nproc -1 \
111+
--create --debug || EXIT 'harmonization.py with --create --debug failed'
112+
113+
# --process and --debug block
114+
../../harmonization.py \
115+
--bvalMap 1000 \
116+
--resample 1.5x1.5x1.5 \
117+
--template ./template/ \
118+
--tar_list prisma.txt \
119+
--tar_name PRISMA \
120+
--ref_list connectom.txt \
121+
--nproc -1 \
122+
--process --debug --force || EXIT 'harmonization.py with --process --debug --force failed'
123+
124+
../../harmonization.py \
125+
--bvalMap 1000 \
126+
--resample 1.5x1.5x1.5 \
127+
--template ./template/ \
128+
--tar_list prisma.txt \
129+
--tar_name PRISMA \
130+
--ref_list connectom.txt \
131+
--nproc -1 \
132+
--process --debug || EXIT 'harmonization.py with --process --debug failed'
133+
134+
# ===============================================================================================================
135+
136+
# same bvalue, resolution block
137+
cp connectom.txt.modified connectom_same.txt
138+
cp prisma.txt.modified prisma_same.txt
139+
../../harmonization.py \
140+
--template ./template/ \
141+
--ref_list connectom_same.txt \
142+
--tar_list prisma_same.txt \
143+
--ref_name CONNECTOM \
144+
--tar_name PRISMA \
145+
--nproc -1 \
146+
--create --process || EXIT 'harmonization.py for same bvalue, resolution with --create --process failed'
147+
148+
# ===============================================================================================================
149+
# compute statistics
150+
../fa_skeleton_test.py -i connectom.txt.modified \
151+
-s CONNECTOM -t template/ || EXIT 'fa_skeleton_test.py failed for modified reference'
152+
153+
../fa_skeleton_test.py -i prisma.txt \
154+
-s PRISMA -t template/ || EXIT 'fa_skeleton_test.py failed for given target'
155+
156+
../fa_skeleton_test.py -i prisma.txt.modified.harmonized \
157+
-s PRISMA -t template/ || EXIT 'fa_skeleton_test.py failed for harmonized target'
158+
159+
# ===============================================================================================================
160+
161+

0 commit comments

Comments
 (0)