-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathants_Lesion_to_MNI_affine_only.sh
49 lines (36 loc) · 1.33 KB
/
ants_Lesion_to_MNI_affine_only.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
#!/bin/bash
export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=12 # controls multi-threading
export ANTSPATH=/home/ch186161/bin/ants/bin/ # path to ANTs binaries
export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS
echo This will use ${ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS} threads at a time
echo Using the ANTs version installed at ${ANTSPATH}
temp_dir=./ants_Temp
mkdir -p $temp_dir
template=$1
sub_T1=$2
sub_lesion=$3
sub_prefix=$4
sub_neg_lesion=${temp_dir}/${sub_prefix}_neg_lesion.nii.gz
sub_masked_T1=${temp_dir}/${sub_prefix}_T1_lesioned.nii.gz
# ImageMath 3 $sub_neg_lesion Neg $sub_lesion
# MultiplyImages 3 $sub_T1 $sub_neg_lesion $sub_masked_T1
# In the SyNQuick script, the mask applies to fixed image, so the template is moving to the subject, and
# the inverse warp is what we'll want to apply to the lesion data.
antsRegistrationSyNQuick.sh \
-d 3 \
-m $template \
-f $sub_masked_T1 \
-t a \
-o MNI_to_${sub_prefix}_ \
-x $sub_neg_lesion \
-j 1
# Then we apply the inverse transform to bring the lesion mask to MNI space.
antsApplyTransforms \
-d 3 \
-i ${sub_lesion} \
-r ${template} \
-t [MNI_to_${sub_prefix}_0GenericAffine.mat, 1] \
-n GenericLabel[Linear] \
-o ${sub_prefix}_lesions_in_MNI.nii.gz
# WarpImageMultiTransform 3 $sub_lesion sub_lesion_in_MNI.nii.gz \
# -R $template -i ${nm}0GenericAffine.mat ${nm}1InverseWarp.nii.gz