-
Notifications
You must be signed in to change notification settings - Fork 7
/
main
executable file
·179 lines (153 loc) · 5 KB
/
main
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
#!/bin/bash
#PBS -l nodes=1:ppn=6
#PBS -l vmem=16gb
#PBS -l walltime=10:00:00
set -e
set -x
cmd=`jq -r .command config.json`
case "$cmd" in
dipy_median_otsu)
#bypass bvals / bvecs for masked output
cp $(jq -r .bvals config.json) dwi.bvals
cp $(jq -r .bvecs config.json) dwi.bvecs
# Todo: Add these options after dipy release 0.14.0
ext_arg=""
autocrop=$(jq -r .autocrop config.json)
if [ $autocrop == "true" ]; then
ext_arg="--autocrop"
fi
cat > script.sh <<EOF
#!/bin/bash
$cmd $ext_arg --force \
--out_dir $(pwd) \
--save_masked \
--numpass $(jq -r .numpass config.json) \
--median_radius $(jq -r .median_radius config.json) \
--out_mask mask.nii.gz \
--out_masked dwi.nii.gz \
$(jq -r .dwi config.json)
EOF
;;
dipy_fit_dti)
cat > script.sh <<EOF
#!/bin/bash
$cmd --force \
--out_dir $(pwd) \
--b0_threshold $(jq -r .b0_threshold config.json) \
--bvecs_tol $(jq -r .bvecs_tol config.json) \
--out_strat what \
$(jq -r .dwi config.json) $(jq -r .bvals config.json) $(jq -r .bvecs config.json) $(jq -r .mask config.json)
EOF
;;
dipy_fit_dki)
cat > script.sh <<EOF
$cmd --force \
--out_dir $(pwd) \
--b0_threshold $(jq -r .b0_threshold config.json) \
--out_strat what \
$(jq -r .dwi config.json) $(jq -r .bvals config.json) $(jq -r .bvecs config.json) $(jq -r .mask config.json)
EOF
;;
dipy_fit_csa)
cat > script.sh <<EOF
#!/bin/bash
$cmd --force \
--out_dir $(pwd) \
--b0_threshold $(jq -r .b0_threshold config.json) \
--out_strat what \
$(jq -r .dwi config.json) $(jq -r .bvals config.json) $(jq -r .bvecs config.json) $(jq -r .mask config.json)
;;
dipy_fit_csd)
cat > script.sh <<EOF
#!/bin/bash
$cmd --force \
--out_dir $(pwd) \
--b0_threshold $(jq -r .b0_threshold config.json) \
--out_strat what \
$(jq -r .dwi config.json) $(jq -r .bvals config.json) $(jq -r .bvecs config.json) $(jq -r .mask config.json)
;;
dipy_fit_mapmri)
cat > script.sh <<EOF
#!/bin/bash
$cmd --force \
--out_dir $(pwd) \
--b0_threshold $(jq -r .b0_threshold config.json) \
--out_strat what \
$(jq -r .dwi config.json) $(jq -r .bvals config.json) $(jq -r .bvecs config.json) $(jq -r .small_delta config.json)
$(jq -r .big_delta config.json)
;;
dipy_nlmeans)
cat > script.sh <<EOF
#!/bin/bash
$cmd --force \
--out_dir $PWD \
--sigma $(jq -r .sigma config.json) \
--out_denoised dwi.nii.gz \
$(jq -r .dwi config.json)
;;
dipy_mask:dwi)
cat > script.sh <<EOF
#!/bin/bash
dipy_mask --force \
--out_dir $PWD \
--out_mask mask.nii.gz \
$(jq -r .dwi config.json) $(jq -r .lb config.json)
;;
dipy_mask:tensor)
cat > script.sh <<EOF
#!/bin/bash
dipy_mask --force \
--out_dir $PWD \
--out_mask mask.nii.gz \
$(jq -r .fa config.json) $(jq -r .lb config.json)
;;
dipy_reslice)
# pass through bvecs/bvals
cp $(jq -r .bvecs config.json) dwi.bvecs
cp $(jq -r .bvals config.json) dwi.bvals
cat > script.sh <<EOF
#!/bin/bash
$cmd --force \
--out_dir $PWD \
--out_resliced dwi.nii.gz \
$(jq -r .dwi config.json) $(jq -r .new_vox_size config.json)
EOF
;;
dipy_recobundles)
#TODO - maybe we could do this in the Dockerfile? Ping Josh as he is doing something similar I believe
mkdir -p "atlas"
if [ ! -f "atlas/Atlas_in_MNI_Space_16_bundles.zip" ]; then
wget -O "atlas/Atlas_in_MNI_Space_16_bundles.zip" https://ndownloader.figshare.com/files/11921522
unzip -d "atlas" "atlas/Atlas_in_MNI_Space_16_bundles.zip"
fi
cat > script.sh <<EOF
#!/bin/bash
set -e
set -x
#no ~/.dipy inside dipy container..
#dipy_slr ~/.dipy/bundle_atlas_hcp842/Atlas_in_MNI_Space_16_bundles/whole_brain/whole_brain_MNI.trk csa_track.trk --mix_names
#dipy_recobundles --force --out_dir $PWD --mix_names --refine $(jq -r .tracks_target config.json) \
# "\$(python -c "from dipy.data import get_bundle_atlas_hcp842; print(get_bundle_atlas_hcp842()[1])")" #double-double quotes ok?
#dipy_labelsbundles $(jq -r .tracks_target config.json) *.npy --mix_names --out_dir original_space
dipy_recobundles --force --out_dir $PWD --mix_names --refine $(jq -r .tracks_target config.json) "atlas/Atlas_in_MNI_Space_16_bundles/bundles/*.trk"
EOF
;;
dipy_info)
cat > script.sh << EOF
#!/bin/bash
$cmd --force $(jq -r .dwi config.json) $(jq -r .bvals config.json) $(jq -r .bvecs config.json)
EOF
;;
dipy_track_det)
cat > script.sh << EOF
#!/bin/bash
$cmd --force --out_dir $PWD $(jq -r .peaks config.json) $(jq -r .stop config.json) $(jq -r .seed config.json)
EOF
;;
*)
echo "invalid command: $cmd"
exit 1
esac
chmod +x script.sh
SINGULARITYENV_PYTHONNOUSERSITE=true singularity exec -e docker://brainlife/dipy:0.16.0 ./script.sh
echo "done"