-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathants_t1w_transformation.sh
executable file
·62 lines (47 loc) · 1.87 KB
/
ants_t1w_transformation.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
#!/bin/bash
T1W_MOVE=$1
T1W_STAT=$2
T1W_M=space-dwi_T1w.nii.gz
T1W_ANT_PRE=space_MNI_var-t1w_
#------------------------------------------------------------------------------
# ANTS Registration of structural images
#------------------------------------------------------------------------------
# Brain extraction
echo "Brain extraction using BET"
bet $T1W_MOVE $T1W_M
T1W_S=$T1W_STAT #already without skull
# Warp Computation
ANTS 3 -m CC[${T1W_S},${T1W_M},1,5] -t SyN[0.5] \
-r Gauss[2,0] -o $T1W_ANT_PRE -i 30x90x20 --use-Histogram-Matching
#antsRegistrationSyNQuick.sh -d 3 \
# -f $T1W_STAT -m $T1W_MOVE -t s -o $T1W_ANT_PRE
#------------------------------------------------------------------------------
# Renaming files
#------------------------------------------------------------------------------
mv ${T1W_ANT_PRE}Warp.nii.gz ${T1W_ANT_PRE}warp.nii.gz
mv ${T1W_ANT_PRE}InverseWarp.nii.gz ${T1W_ANT_PRE}invwarp.nii.gz
mv ${T1W_ANT_PRE}Affine.txt ${T1W_ANT_PRE}affine.txt
#cp ${T1W_ANT_PRE}warp.nii.gz warps/warp.nii.gz
#cp ${T1W_ANT_PRE}invwarp.nii.gz warps/inverse-warp.nii.gz
#------------------------------------------------------------------------------
# Convert the warp for tck
#------------------------------------------------------------------------------
WARP_PRE=space_MNI_var-ant_warp
WARP_INI=space_MNI_var-ant_warp-i[].nii.gz
WARP_TMP=space_MNI_var-ant_warp-t[].nii.gz
WARP_T1W=space_MNI_var-t1w4tck_warp.nii.gz
T1W_AFF=${T1W_ANT_PRE}affine.txt
T1W_IWARP=${T1W_ANT_PRE}invwarp.nii.gz
T1W_IWARP_FIX=${T1W_ANT_PRE}InverseWarp.nii.gz
warpinit ${T1W_S} ${WARP_INI} -force -quiet
cp $T1W_IWARP $T1W_IWARP_FIX
for i in 0 1 2; do
WarpImageMultiTransform 3 \
${WARP_PRE}-i${i}.nii.gz ${WARP_PRE}-t${i}.nii.gz \
-R $T1W_S -i $T1W_AFF $T1W_IWARP_FIX
done
rm -f $T1W_IWARP_FIX
warpcorrect $WARP_TMP $WARP_T1W -force -quiet
rm ${WARP_PRE}-*
rm $T1W_M
rm $T1W_IWARP