-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreco.sh
executable file
·228 lines (186 loc) · 5.5 KB
/
reco.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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/bin/bash
#
# Copyright 2022. TU Graz. Institute of Biomedical Imaging.
# Copyright 2020-2022. Uecker Lab. University Medical Center Göttingen.
#
# Author: Xiaoqing Wang, 2020-2022
# Wang X et al.
# Free-Breathing Myocardial T1 Mapping using Inversion-Recovery
# Radial FLASH and Motion-Resolved Model-Based Reconstruction.
# Magn Reson Med. (2022), DOI: 10.1002/mrm.29521.
#
set -e
usage="Usage: $0 [-w reg_l1Wav] [-t reg_tv_resp] [-T reg_tv_cardiac] [-a alpha_min] [-u u] [-k] [-o overgrid] [-g] [-R reg_type] <TI> <traj> <ksp> <output> <output_sens>"
if [ $# -lt 4 ] ; then
echo "$usage" >&2
exit 1
fi
k_filter=0
use_gpu=0
reg_type=2
while getopts "hw:t:T:a:u:ko:gR:" opt; do
case $opt in
h)
echo "$usage"
exit 0
;;
w)
reg_l1Wav=${OPTARG}
;;
t)
reg_tv_resp=${OPTARG}
;;
T)
reg_tv_cardiac=${OPTARG}
;;
a)
alpha_min=${OPTARG}
;;
u)
u=${OPTARG}
;;
k)
k_filter=1
;;
o)
overgrid=${OPTARG}
;;
g)
use_gpu=1
;;
R)
reg_type=${OPTARG}
;;
\?)
echo "$usage" >&2
exit 1
;;
esac
done
shift $(($OPTIND -1 ))
TI=$(readlink -f "$1")
traj=$(readlink -f "$2")
ksp=$(readlink -f "$3")
reco=$(readlink -f "$4")
if [ "$#" -lt 5 ] ; then
sens=""
else
sens=$(readlink -f "$5")
fi
if [ ! -e ${TI}.cfl ] ; then
echo "Input file 'TI' does not exist." >&2
echo "$usage" >&2
exit 1
fi
if [ ! -e ${traj}.cfl ] ; then
echo "Input file 'traj' does not exist." >&2
echo "$usage" >&2
exit 1
fi
if [ ! -e ${ksp}.cfl ] ; then
echo "Input file 'ksp' does not exist." >&2
echo "$usage" >&2
exit 1
fi
function calc() { awk "BEGIN { print "$*" }"; }
#WORKDIR=$(mktemp -d)
# Mac: http://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x
WORKDIR=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'`
trap 'rm -rf "$WORKDIR"' EXIT
cd $WORKDIR
# Motion-resolved model-based T1 reconstruction:
START=$(date +%s)
which bart
bart version
opts="-L -d4 -R3 -i10 -C100 -u$u -o$overgrid -j$alpha_min -rS:0.0 -rQ:1.0 "
case "$reg_type" in
0)
opts+="-rW:$(bart bitmask 0 1):$(bart bitmask 6):${reg_l1Wav}"
echo -e "l1-Wavelet spatial regularization with joint thresholding
using the parameter ${reg_l1Wav}"
;;
1)
opts+="-rW:$(bart bitmask 0 1):$(bart bitmask 6):${reg_l1Wav}
-rT:$(bart bitmask 10):0:${reg_tv_cardiac}
-rT:$(bart bitmask 11):0:${reg_tv_resp}"
echo -e "l1-Wavelet spatial regularization with joint thresholding
using the parameter ${reg_l1Wav} +
TV regularizations along the cardiac and respiration dimensions
separately using parameters ${reg_tv_cardiac} and ${reg_tv_resp}"
;;
2)
opts+="-rW:$(bart bitmask 0 1):$(bart bitmask 6):${reg_l1Wav}
-rT:$(bart bitmask 10 11):0:${reg_tv_cardiac}"
echo -e "l1-Wavelet spatial regularization with joint thresholding
using the parameter ${reg_l1Wav} +
TV regularizations along the cardiac and respiration dimensions
jointly using the parameter ${reg_tv_cardiac}"
;;
3)
opts+="-rT:$(bart bitmask 10 11):0:${reg_tv_cardiac}"
echo -e "TV regularizations along the cardiac and respiration dimensions
jointly using the parameter ${reg_tv_cardiac}"
;;
4)
opts+="rT:$(bart bitmask 0 1):$(bart bitmask 6):${reg_tv_cardiac}
-rT:$(bart bitmask 10 11):0:${reg_tv_cardiac}"
echo -e "Spatial TV with joint thresholding using the parameter ${reg_tv_cardiac} +
TV regularizations along the cardiac and respiration dimensions
jointly using the parameter ${reg_tv_cardiac}"
;;
5)
opts+="-rT:$(bart bitmask 0 1 10 11):$(bart bitmask 6):${reg_tv_cardiac}"
echo -e "TV regularizations along the spatial, cardiac and respiration
dimensions jointly with a joint thresholding using the parameter
${reg_tv_cardiac}"
;;
6)
opts+="-rT:$(bart bitmask 0 1 10 11):$(bart bitmask 6):${reg_tv_cardiac}
-rW:$(bart bitmask 0 1):$(bart bitmask 6):${reg_l1Wav}"
echo -e "l1-Wavelet spatial regularization with joint thresholding
using the parameter ${reg_l1Wav} +
TV regularizations along the spatial, cardiac and respiration
dimensions jointly with a joint thresholding using the parameter
${reg_tv_cardiac}"
;;
7)
opts+="-rT:$(bart bitmask 0 1 10 11):0:${reg_tv_cardiac}
-rW:$(bart bitmask 0 1):$(bart bitmask 6):${reg_l1Wav} --other tvscale=0.4:0.4:1.0:0.2"
echo -e "l1-Wavelet spatial regularization with joint thresholding
using the parameter ${reg_l1Wav} +
TV regularizations along the spatial, cardiac and respiration
dimensions jointly
${reg_tv_cardiac}"
;;
8)
opts+="-rT:$(bart bitmask 10):0:${reg_tv_cardiac}
-rW:$(bart bitmask 0 1):$(bart bitmask 6):${reg_l1Wav}"
echo -e "l1-Wavelet spatial regularization with joint thresholding
using the parameter ${reg_l1Wav} +
TV regularizations along the cardiac dimension only ${reg_tv_cardiac}"
;;
9)
opts+="-rT:$(bart bitmask 10):0:${reg_tv_cardiac}
-rT:$(bart bitmask 11):0:${reg_tv_resp}"
echo -e "TV regularizations along the cardiac and respiration dimensions
separately using parameters ${reg_tv_cardiac} and ${reg_tv_resp}"
;;
esac
if [ $k_filter -eq 1 ] ; then
opts+=" -k --kfilter-2 -e1e-2"
fi
if [ $use_gpu -eq 1 ] ; then
opts+=" -g --multi-gpu 1"
fi
readout=$(bart show -d1 $traj)
img_size=`calc $readout/2*$overgrid`
opts+=" --img_dims $img_size:$img_size:1 --normalize_scaling --scale_data 500 --scale_psf 250"
opts+=" --other pinit=1:1:1.5:1"
echo $opts
bart scale 0.5 $traj traj
OMP_NUM_THREADS=40 nice -n15 bart moba $opts -t traj $ksp $TI $reco $sens
END=$(date +%s)
DIFF=$(($END - $START))
echo "It took $DIFF seconds"