Debian Codegraph @

Scripts/unbiased_pairwise_registration_with_aux_images.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 usage=" $0 -d 3 -f fixed.nii.gz -m moving.nii.gz -t grouptemplate.nii.gz -b templatebrainmask.nii.gz -g f_auximage_tensor -n m_auximage_tensor -o output_prefix -h f_auximage_scalar -k m_auximage_scalar "
3 :<<supercalifragilisticexpialidocious
4
5 here is a first pass at an unbiased registration between an image pair, A ( fixed ) and B.
6
7 the reference frame for the registration uses the header of A.
8
9 however, the image content ---- call it AB ----- is actually half-way between A and B.
10
11 so we have ( in geometry )
12
13 A . . . . AB . . . . B
14
15 or very close to it.
16
17 we then compute :
18
19 AB => A which gives Aff_A
20 AB => B which gives Aff_B
21
22 and , finally A( Aff_A ) <=> B( Aff_ B )
23
24 where <=> is SyN.
25
26 i don't worry about the header bias too much or the fact that my first transform depends on mapping B to A --- the interpolation is still symmetric ( i think ) with this approach.
27
28 would be nice to use the CompositeTransformUtil to convert the output of this to just a fwd/inv tx.
29
30 if this turns out to be biased, i suppose we need header tricks.
31
32 supercalifragilisticexpialidocious
33
34 A=A ; B=B ; prefix=J ; dim=3
35 if [[ $# -eq 0 ]] ; then echoscip-shell system . . echo. $usage ; exit 0 ; fi
36 while getopts ":d:f:m:b:o:t:g:h:n:k:h:" opt; do
37 case $opt in
38 d)
39 echoscip-shell system . . echo. "-d $OPTARG" >&2
40 dim=$OPTARG
41 ;;
42 f)
43 echoscip-shell system . . echo. "-f $OPTARG" >&2
44 A=$OPTARG
45 ;;
46 g)
47 echoscip-shell system . . echo. "-g $OPTARG" >&2
48 G=$OPTARG
49 ;;
50 h)
51 echoscip-shell system . . echo. "-h $OPTARG" >&2
52 H=$OPTARG
53 ;;
54 k)
55 echoscip-shell system . . echo. "-k $OPTARG" >&2
56 K=$OPTARG
57 ;;
58 m)
59 echoscip-shell system . . echo. "-m $OPTARG" >&2
60 B=$OPTARG
61 ;;
62 n)
63 echoscip-shell system . . echo. "-n $OPTARG" >&2
64 N=$OPTARG
65 ;;
66 o)
67 echoscip-shell system . . echo. "-o $OPTARG " >&2
68 prefix=$OPTARG
69 ;;
70 t)
71 echoscip-shell system . . echo. "-t $OPTARG " >&2
72 template=$OPTARG
73 ;;
74 b)
75 echoscip-shell system . . echo. "-b $OPTARG " >&2
76 templatebm=$OPTARG
77 ;;
78 h)
79 echoscip-shell system . . echo. "Usage: $usage " >&2
80 exit 0
81 ;;
82 \?)
83 echoscip-shell system . . echo. "Usage: $usage " >&2
84 exit 0
85 ;;
86 esac
87 done
88 echoscip-shell system . . echo. inputs: $A $B $prefix $dim
89 echoscip-shell system . . echo. THIS SCRIPT MAY OR MAY NOT WORK - IT HAS NOT BEEN TESTED RECENTLY
90 echoscip-shell system . . echo. USE AT OWN RISK BY COMMENTING OUT THE EXIT CALL BELOW
91 exit 0
92 if [[ ${#dim} -lt 1 ]] ; then echoscip-shell system . . echo. must provide input dimension $dim ; echoscip-shell system . . echo. $usage ; exit 0 ; fi
93 if [[ ${#prefix} -lt 3 ]] ; then echoscip-shell system . . echo. must provide output prefix $prefix ; echoscip-shell system . . echo. $usage ; exit 0 ; fi
94 if [[ ! -s $A ]] || [[ ! -s $B ]] ; then echoscip-shell system . . echo. inputs: $A $B $prefix ; echoscip-shell system . . echo. $usage ; exit 1 ; fi
95
96 reg=antsRegistration
97 uval=0
98 affits=999x550x20
99 aff=" -t affine[ 0.2 ] -c [ $affits ,1.e-7,20 ] -s 3x2x0 -f 4x2x1 -u $uval -l 0 "
100 metparams=" 1 , 32, random , 0.25 "
101 synits=100x50 #BA
102 ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=2
103 export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS
104 nmA=${prefix}_A_norm
105 nmB=${prefix}_B_norm
106 nm=${prefix}_Long
107 nminv=${prefix}_ILong
108 inA=${prefix}_A.nii.gz
109 inB=${prefix}_B.nii.gz
110 if [[ ! -s $inA ]] && [[ ! -s $inB ]] ; then
111 cpscip-shell system . . cp. $A $inA
112 cpscip-shell system . . cp. $B $inB
113 A=$inA
114 B=$inB
115 # map the input images to a similar intensity space
116 ImageMath $dim $A Normalize $A
117 ImageMath $dim $B Normalize $B
118 if [[ -s $template ]] ; then
119 ImageMath $dim $A HistogramMatch $A $template
120 ImageMath $dim $B HistogramMatch $B $template
121 fi
122 N3BiasFieldCorrection $dim $A $A 4
123 N3BiasFieldCorrection $dim $B $B 4
124 fi
125 A=$inA
126 B=$inB
127 ################
128 # T1 Mapping #
129 ################
130 initAmat=${prefix}_A_norm0GenericAffine.mat
131 initBmat=${prefix}_B_norm0GenericAffine.mat
132 initA=${prefix}_initA
133 initB=${prefix}_initB
134 #####################
135 if [[ ! -s ${nm}1Warp.nii.gz ]] ; then
136 $reg -d $dim -r [ $A, $B, 1 ] \
137 -m mattes[ $A, $B , $metparams ] $aff -z 1 \
138 -o [ ${initA}]
139 $reg -d $dim -r [ $B, $A, 1 ] \
140 -m mattes[ $B, $A , $metparams ] $aff -z 1 \
141 -o [ ${initB}]
142 # get the identity map
143 ComposeMultiTransform $dim ${initA}_id.mat -R ${initA}0GenericAffine.mat ${initA}0GenericAffine.mat -i ${initA}0GenericAffine.mat
144 # invert the 2nd affine registration map
145 ComposeMultiTransform $dim ${initB}_inv.mat -R ${initA}0GenericAffine.mat -i ${initB}0GenericAffine.mat
146 # get the average affine map
147 AverageAffineTransform $dim ${prefix}_avg.mat ${initB}_inv.mat ${initA}0GenericAffine.mat
148 # get the midpoint affine map
149 AverageAffineTransform $dim ${prefix}_mid.mat ${initA}_id.mat ${prefix}_avg.mat
150 #.........#
151 # this applies, to B, a map from B to midpoint(B,A)
152 ImageMath $dim ${prefix}_mid.nii.gz PadImage $A 10
153 antsApplyTransforms -d $dim -i $B -o ${prefix}_mid.nii.gz -t ${prefix}_mid.mat -r $A
154 # compute the map from A to midpoint(B,A) --- "fair" interpolation
155 $reg -d $dim \
156 -m mattes[ ${prefix}_mid.nii.gz, $A, $metparams ] $aff \
157 -o [ ${nmA},${nmA}_aff.nii.gz]
158 # compute the map from B to midpoint(B,A) --- "fair" interpolation
159 $reg -d $dim \
160 -m mattes[ ${nmA}_aff.nii.gz, $B, $metparams ] $aff \
161 -o [ ${nmB},${nmB}_aff.nii.gz]
162
163 # now we can do a symmetric deformable mapping
164 N3BiasFieldCorrection $dim $A ${nm}_n3_a.nii.gz 4
165 N3BiasFieldCorrection $dim ${nm}_n3_a.nii.gz ${nm}_n3_a.nii.gz 2
166 N3BiasFieldCorrection $dim $B ${nm}_n3_b.nii.gz 4
167 N3BiasFieldCorrection $dim ${nm}_n3_b.nii.gz ${nm}_n3_b.nii.gz 2
168 echoscip-shell system . . echo. now do deformable expecting $initB and $initA to exist
169 if [[ -s $initAmat ]] && [[ -s $initBmat ]] ; then
170 $reg -d $dim --initial-fixed-transform $initAmat --initial-moving-transform $initBmat \
171 -m mattes[ ${nm}_n3_a.nii.gz, ${nm}_n3_b.nii.gz , 1 , 32 ] \
172 -t syn[ 0.25, 3, 0.5 ] \
173 -c [ ${synits},1.e-8,10 ] \
174 -s 1x0 \
175 -f 2x1 \
176 -u $uval -b 0 -z 1 \
177 -o [ ${nm},${nm}_diff_symm.nii.gz]
178 # $reg -d $dim --initial-fixed-transform $initBmat --initial-moving-transform $initAmat \
179 # -m mattes[ ${nm}_n3_a.nii.gz, ${nm}_n3_b.nii.gz , 1 , 32 ] \
180 # -t syn[ 0.25, 3, 0.5 ] \
181 # -c [ ${synits},1.e-8,10 ] \
182 # -s 1x0 \
183 # -f 2x1 \
184 # -u $uval -b 0 -z 1 \
185 # -o [ ${nminv},${nminv}_diff_symm.nii.gz]
186 else
187 echoscip-shell system . . echo. $initBmat and $initAmat DO NOT exist
188 exit
189 fi
190 fi
191 AverageImages $dim ${nm}_avg.nii.gz 0 ${nmA}_aff.nii.gz ${nm}_diff_symm.nii.gz
192 MultiplyImages $dim ${nm}1InverseWarp.nii.gz 0.5 ${nm}tempWarp.nii.gz
193 antsApplyTransforms -d $dim -i ${nm}_avg.nii.gz -o ${nm}_avg.nii.gz -t ${nm}tempWarp.nii.gz -r ${nm}_avg.nii.gz
194 rmscip-shell system . . rm. ${nm}tempWarp.nii.gz
195
196 # recompute the mappings
197 if [[ -s $initAmat ]] && [[ -s $initBmat ]] ; then
198 $reg -d $dim --initial-moving-transform $initBmat \
199 -m mattes[ ${nm}_avg.nii.gz, ${nm}_n3_b.nii.gz , 1 , 32 ] \
200 -t syn[ 0.25, 3, 0.5 ] \
201 -c [ ${synits},1.e-8,10 ] \
202 -s 1x0 \
203 -f 2x1 \
204 -u $uval -b 0 -z 1 \
205 -o [ ${nm}_B,${nm}_B_symm.nii.gz]
206 $reg -d $dim --initial-moving-transform $initAmat \
207 -m mattes[ ${nm}_avg.nii.gz, ${nm}_n3_a.nii.gz , 1 , 32 ] \
208 -t syn[ 0.25, 3, 0.5 ] \
209 -c [ ${synits},1.e-8,10 ] \
210 -s 1x0 \
211 -f 2x1 \
212 -u $uval -b 0 -z 1 \
213 -o [ ${nm}_A,${nm}_A_symm.nii.gz]
214 else
215 echoscip-shell system . . echo. $initBmat and $initAmat DO NOT exist
216 exit
217 fi
218
219 initafffn=${nm}_init_aff.mat
220 if [[ -s $template ]] && [[ ! -s ${nm}_gt_0GenericAffine.mat ]] ; then
221 imgsmall=${nm}_diffsmall.nii.gz
222 temsmall=${nm}_temsmall.nii.gz
223 ResampleImageBySpacing $dim ${nm}_avg.nii.gz $imgsmall 4 4 4
224 ResampleImageBySpacing $dim $template $temsmall 4 4 4
225 antsAffineInitializer $dim $temsmall $imgsmall $initafffn 15 0.1 0 10
226 gf=$template
227 gm=${nm}_avg.nii.gz
228 imgs=" $gf, $gm "
229 $reg -d $dim -r $initafffn \
230 -m mattes[ $imgs , 1 , 32, regular, 0.25 ] \
231 -t affine[ 0.1 ] \
232 -c [ $affits ,1.e-7,20 ] \
233 -s 4x2x1vox \
234 -f 4x2x1 -l 1 \
235 -m cc[ $imgs , 1 , 4 ] \
236 -t syn[ .2, 3, 0.0 ] \
237 -c [ 100x50x20,1.e-8,20 ] \
238 -s 2x1x0vox \
239 -f 4x2x1 -l 1 -u 0 -z 1 \
240 -o [ ${nm}_gt_,${nm}_gt.nii.gz]
241
242 # map brain mask to subject space T1
243 trans=" -t [ $initAmat, 1 ] -t ${nm}_A1InverseWarp.nii.gz -t [ ${nm}_gt_0GenericAffine.mat, 1 ] -t ${nm}_gt_1InverseWarp.nii.gz "
244 antsApplyTransforms -d $dim -i $templatebm -o ${nm}_bm_A.nii.gz -n NearestNeighbor -r $A $trans
245 trans=" -t [ $initBmat, 1 ] -t ${nm}_B1InverseWarp.nii.gz -t [ ${nm}_gt_0GenericAffine.mat, 1 ] -t ${nm}_gt_1InverseWarp.nii.gz "
246 antsApplyTransforms -d $dim -i $templatebm -o ${nm}_bm_B.nii.gz -n NearestNeighbor -r $B $trans
247 MultiplyImages $dim ${nm}_bm_A.nii.gz $A ${nm}_A_brain.nii.gz
248 MultiplyImages $dim ${nm}_bm_B.nii.gz $B ${nm}_B_brain.nii.gz
249 fi
250 echoscip-shell system . . echo. done with brain extraction
251
252 if [[ -s $G ]] && [[ -s $N ]] && [[ ! -s ${nm}_fadiff.nii.gz ]] ; then
253 # map brain mask to subject space T1
254 trans=" -t [ $initAmat, 1 ] -t [ ${nm}_gt_0GenericAffine.mat, 1 ] -t ${nm}_gt_1InverseWarp.nii.gz "
255 antsApplyTransforms -d $dim -i $templatebm -o ${nm}_bm_A.nii.gz -n NearestNeighbor -r $A $trans
256 trans=" -t [ $initBmat, 1 ] -t ${nm}1InverseWarp.nii.gz -t [ ${nm}_gt_0GenericAffine.mat, 1 ] -t ${nm}_gt_1InverseWarp.nii.gz "
257 antsApplyTransforms -d $dim -i $templatebm -o ${nm}_bm_B.nii.gz -n NearestNeighbor -r $B $trans
258 MultiplyImages $dim ${nm}_bm_A.nii.gz $A ${nm}_A_brain.nii.gz
259 MultiplyImages $dim ${nm}_bm_B.nii.gz $B ${nm}_B_brain.nii.gz
260
261
262 ######### now redo bias correction & syn #########
263 N3BiasFieldCorrection $dim ${nm}_A_brain.nii.gz ${nm}_n3_a.nii.gz 4
264 N3BiasFieldCorrection $dim ${nm}_n3_a.nii.gz ${nm}_n3_a.nii.gz 2
265 N3BiasFieldCorrection $dim ${nm}_n3_a.nii.gz ${nm}_n3_a.nii.gz 2
266 N3BiasFieldCorrection $dim ${nm}_B_brain.nii.gz ${nm}_n3_b.nii.gz 4
267 N3BiasFieldCorrection $dim ${nm}_n3_b.nii.gz ${nm}_n3_b.nii.gz 2
268 N3BiasFieldCorrection $dim ${nm}_n3_b.nii.gz ${nm}_n3_b.nii.gz 2
269 echoscip-shell system . . echo. now do deformable expecting $initB and $initA to exist
270 if [[ -s $initAmat ]] && [[ -s $initBmat ]] ; then
271 $reg -d $dim --initial-fixed-transform $initAmat --initial-moving-transform $initBmat \
272 -m mattes[ ${nm}_n3_a.nii.gz, ${nm}_n3_b.nii.gz , 1 , 32 ] \
273 -t syn[ 0.25, 3, 0.5 ] \
274 -c [ ${synits},1.e-8,10 ] \
275 -s 1x0 \
276 -f 2x1 \
277 -u $uval -b 0 -z 1 \
278 -o [ ${nm},${nm}_diff_symm.nii.gz]
279 else
280 echoscip-shell system . . echo. $initBmat and $initAmat DO NOT exist
281 exit
282 fi
283 antsApplyTransforms -d $dim -i $B -o ${nm}_diff.nii.gz -t [ $initAmat, 1 ] -t ${nm}1Warp.nii.gz -t $initBmat -r $A
284 ANTSJacobian $dim ${nm}1Warp.nii.gz ${nm} 1 no 0
285 fi
286 if [[ -s $G ]] && [[ -s $N ]] && [[ ! -s ${nm}_fadiff.nii.gz ]] ; then
287 echoscip-shell system . . echo. deal with auxiliary images ... here DTI
288 ffa=${nm}_ffa.nii.gz
289 mfa=${nm}_mfa.nii.gz
290 ImageMath 3 $ffa TensorFA $G
291 ImageMath 3 $mfa TensorFA $N
292 synits=15x25x3
293 imgs=" ${nm}_A_brain.nii.gz, $ffa "
294 $reg -d $dim \
295 -m mattes[ $imgs , 1 , 32, regular, 0.2 ] \
296 -t rigid[ 0.1 ] \
297 -c [ 1000x1000x5,1.e-7,20 ] \
298 -s 4x2x1mm -x [ ${nm}_bm_A.nii.gz ] \
299 -f 4x2x1 -l 1 -u 1 -z 1 \
300 -m mattes[ $imgs , 1 , 32, regular, 0.2 ] \
301 -t affine[ 0.1 ] \
302 -c [ 1000x25,1.e-7,20 ] \
303 -s 2x1mm -x [ ${nm}_bm_A.nii.gz ] \
304 -f 2x1 -l 1 -u 1 -z 1 \
305 -m mattes[ $imgs , 1 , 32 ] \
306 -m cc[ $imgs , 1 , 2 ] \
307 -t SyN[ 0.2, 3, 0.5 ] \
308 -c [ $synits,1.e-7,20 ] \
309 -s 4x2x1mm -x [ ${nm}_bm_A.nii.gz ] \
310 -f 4x2x1 -l 1 -u 1 -z 1 \
311 -o [ ${nm}_ffa,${nm}_ffa_distcorr.nii.gz]
312 imgs=" ${nm}_B_brain.nii.gz, $mfa "
313 $reg -d $dim \
314 -m mattes[ $imgs , 1 , 32, regular, 0.2 ] \
315 -t rigid[ 0.1 ] \
316 -c [ 1000x1000x5,1.e-7,20 ] \
317 -s 4x2x1mm -x [ ${nm}_bm_A.nii.gz ] \
318 -f 4x2x1 -l 1 -u 1 -z 1 \
319 -m mattes[ $imgs , 1 , 32, regular, 0.2 ] \
320 -t affine[ 0.1 ] \
321 -c [ 1000x25,1.e-7,20 ] \
322 -s 2x1mm -x [ ${nm}_bm_B.nii.gz ] \
323 -f 2x1 -l 1 -u 1 -z 1 \
324 -m mattes[ $imgs , 1 , 32 ] \
325 -m cc[ $imgs , 1 , 2 ] \
326 -t SyN[ 0.2, 3, 0.5 ] \
327 -c [ $synits,1.e-7,20 ] \
328 -s 4x2x1mm -x [ ${nm}_bm_B.nii.gz ] \
329 -f 4x2x1 -l 1 -u 1 -z 1 \
330 -o [ ${nm}_mfa,${nm}_mfa_distcorr.nii.gz]
331 #
332 trans=" -t ${nm}_gt_1Warp.nii.gz -t ${nm}_gt_0GenericAffine.mat -t ${nm}_A1Warp.nii.gz -t $initAmat -t ${nm}_ffa1Warp.nii.gz -t ${nm}_ffa0GenericAffine.mat "
333 antsApplyTransforms -d $dim -i $ffa -o ${nm}_ffanorm.nii.gz -r $template $trans
334 #
335 trans=" -t ${nm}_gt_1Warp.nii.gz -t ${nm}_gt_0GenericAffine.mat -t ${nm}_B1Warp.nii.gz -t $initBmat -t ${nm}_mfa1Warp.nii.gz -t ${nm}_mfa0GenericAffine.mat "
336 antsApplyTransforms -d $dim -i $mfa -o ${nm}_mfanorm.nii.gz -r $template $trans
337 ImageMath $dim ${nm}_fadiff.nii.gz - ${nm}_ffanorm.nii.gz ${nm}_mfanorm.nii.gz
338 fi
339 echoscip-shell system . . echo. done with aux images --- now get final jacobians
340
341
342
343 if [[ -s $H ]] && [[ -s $K ]] && [[ ! -s ${nm}_cbfdiff.nii.gz ]] ; then
344 echoscip-shell system . . echo. deal with auxiliary images ... here a scalar image pair
345 # if [[ -s $H ]] && [[ -s $K ]] && [[ ! -s ${nm}_cbfdiff.nii.gz ]] ; then
346 # echo deal with auxiliary images ... here DTI
347 fcbf=${nm}_fcbf.nii.gz
348 mcbf=${nm}_mcbf.nii.gz
349 ImageMath $dim $fcbf Normalize $H
350 ImageMath $dim $mcbf Normalize $K
351 synits=15x25x3
352 imgs=" ${nm}_A_brain.nii.gz, $fcbf "
353 $reg -d $dim \
354 -m mattes[ $imgs , 1 , 32, regular, 0.2 ] \
355 -t rigid[ 0.1 ] \
356 -c [ 1000x1000x5,1.e-7,20 ] \
357 -s 4x2x1mm -x [ ${nm}_bm_A.nii.gz ] \
358 -f 4x2x1 -l 1 -u 1 -z 1 \
359 -m mattes[ $imgs , 1 , 32, regular, 0.2 ] \
360 -t affine[ 0.1 ] \
361 -c [ 1000x25,1.e-7,20 ] \
362 -s 2x1mm -x [ ${nm}_bm_A.nii.gz ] \
363 -f 2x1 -l 1 -u 1 -z 1 \
364 -m mattes[ $imgs , 1 , 32 ] \
365 -m cc[ $imgs , 1 , 2 ] \
366 -t SyN[ 0.2, 3, 0.5 ] \
367 -c [ $synits,1.e-7,20 ] \
368 -s 4x2x1mm -x [ ${nm}_bm_A.nii.gz ] \
369 -f 4x2x1 -l 1 -u 1 -z 1 \
370 -o [ ${nm}_fcbf,${nm}_fcbf_distcorr.nii.gz]
371 imgs=" ${nm}_B_brain.nii.gz, $mcbf "
372 $reg -d $dim \
373 -m mattes[ $imgs , 1 , 32, regular, 0.2 ] \
374 -t rigid[ 0.1 ] \
375 -c [ 1000x1000x5,1.e-7,20 ] \
376 -s 4x2x1mm -x [ ${nm}_bm_A.nii.gz ] \
377 -f 4x2x1 -l 1 -u 1 -z 1 \
378 -m mattes[ $imgs , 1 , 32, regular, 0.2 ] \
379 -t affine[ 0.1 ] \
380 -c [ 1000x25,1.e-7,20 ] \
381 -s 2x1mm -x [ ${nm}_bm_B.nii.gz ] \
382 -f 2x1 -l 1 -u 1 -z 1 \
383 -m mattes[ $imgs , 1 , 32 ] \
384 -m cc[ $imgs , 1 , 2 ] \
385 -t SyN[ 0.2, 3, 0.5 ] \
386 -c [ $synits,1.e-7,20 ] \
387 -s 4x2x1mm -x [ ${nm}_bm_B.nii.gz ] \
388 -f 4x2x1 -l 1 -u 1 -z 1 \
389 -o [ ${nm}_mcbf,${nm}_mcbf_distcorr.nii.gz]
390 #
391 trans=" -t ${nm}_gt_1Warp.nii.gz -t ${nm}_gt_0GenericAffine.mat -t ${nm}_A1Warp.nii.gz -t $initAmat -t ${nm}_fcbf1Warp.nii.gz -t ${nm}_fcbf0GenericAffine.mat "
392 exe1="antsApplyTransforms -d $dim -i $fcbf -o ${nm}_fcbfnorm.nii.gz -r $template $trans"
393 $exe1
394 #####
395 trans=" -t ${nm}_gt_1Warp.nii.gz -t ${nm}_gt_0GenericAffine.mat -t ${nm}_B1Warp.nii.gz -t $initBmat -t ${nm}_mcbf1Warp.nii.gz -t ${nm}_mcbf0GenericAffine.mat "
396 exe2="antsApplyTransforms -d $dim -i $mcbf -o ${nm}_mcbfnorm.nii.gz -r $template $trans"
397 $exe2
398 echoscip-shell system . . echo. $exe1 > ${nm}_cbf_map.txt
399 echoscip-shell system . . echo. $exe2 >> ${nm}_cbf_map.txt
400 #####
401 ImageMath $dim ${nm}_cbfdiff.nii.gz - ${nm}_fcbfnorm.nii.gz ${nm}_mcbfnorm.nii.gz
402 fi
403 echoscip-shell system . . echo. done with 2nd aux images --- now get final jacobians
404
405 # get final jacobian values
406 # trans=" -t ${nm}_gt_1Warp.nii.gz -t ${nm}_gt_0GenericAffine.mat -t ${nm}_A1Warp.nii.gz -t $initAmat"
407 trans=" -t ${nm}_gt_1Warp.nii.gz -t ${nm}_gt_0GenericAffine.mat -t $initAmat"
408 antsApplyTransforms -d $dim -i ${nm}_A_brain.nii.gz -o [ ${nm}_A_fullWarp.nii.gz, 1 ] -r $template $trans
409 ANTSJacobian $dim ${nm}_A_fullWarp.nii.gz ${nm}_A_full 1 no 0
410 #
411 trans=" -t ${nm}_gt_1Warp.nii.gz -t ${nm}_gt_0GenericAffine.mat -t ${nm}_B1Warp.nii.gz -t $initBmat"
412 antsApplyTransforms -d $dim -i ${nm}_B_brain.nii.gz -o [ ${nm}_B_fullWarp.nii.gz, 1 ] -r $template $trans
413 ANTSJacobian $dim ${nm}_B_fullWarp.nii.gz ${nm}_B_full 1 no 0