-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake_segmentation_SD.sh
executable file
·141 lines (105 loc) · 4.23 KB
/
make_segmentation_SD.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
#!/bin/bash
# make_segmentation_SD.sh ${segmentation}
#
# Default atlases include:
# Desikan-Killiany (individual segmentation, from FreeSurfer): cluster based segmentation, thalamus only
# Yeo7: hard segmentation, thalamus & pallidum
# Kmeans: cortex mask only
#
# Can also run with custom atlas individually
#
# Michael Hart, St George's University of London, January 2022 (c)
#######
#Set up
#######
#define
codedir=${HOME}/Dropbox/Github/tractography
basedir="$(pwd -P)"
FSLOUTPUTTYPE=NIFTI_GZ #occassionally not set as standard
############################################
#6. Dystonia Network (Corp et al Brain 2019)
# (only in SD - as an extra)
############################################
segmentation=${codedir}/templates/r_neg_all_overlap_3.nii.gz
if [ $(imtest ${segmentation}) == 1 ] ;
then
echo "${segmentation} dataset for segmentation ok"
echo "Doing stand alone ${segmentation} segmentation analysis"
atlas=${segmentation}
#Mask atlas by hemisphere (faster & avoids conflict with connectome)
#cd segmentation
#cp ${atlas} .
outname=`basename ${atlas} .nii.gz` #for parsing outputs
echo ${atlas} > ${outname}.txt
#fslmaths ${atlas} -mas ${codedir}/templates/right_brain.nii.gz ${outname}_right
#fslmaths ${atlas} -mas ${codedir}/templates/left_brain.nii.gz ${outname}_left
#Split atlas into individual ROI files
#echo "running deparcellator ${outname}"
#deparcellator.sh ${outname}
#deparcellator.sh ${outname}_right
#deparcellator.sh ${outname}_left
#cd ../
#Left thalamus: hard segmentation
probtrackx2 --samples=bpx.bedpostX/merged \
--mask=bpx.bedpostX/nodif_brain_mask \
--xfm=bpx.bedpostX/xfms/standard2diff \
--invxfm=bpx.bedpostX/xfms/diff2standard \
--seedref=${FSLDIR}/data/standard/MNI152_T1_2mm_brain.nii.gz \
--seed=segmentation/thalamus_left_MNI.nii.gz \
--targetmasks=segmentation=${outname}.txt \
--dir=thalamus2cortex_left_${outname} \
--loopcheck \
--onewaycondition \
--forcedir \
--opd \
--os2t \
--nsamples=5000
#left thalamus
#find_the_biggest thalamus2cortex_left_${outname}/seeds_to_* thalamus2cortex_left/biggest_segmentation
cluster --in=thalamus2cortex_left_${outname}/seeds_to_${outname}.nii.gz --thresh=100 --othresh=thalamus2cortex_left_${outname}/cluster_${outname}
else
echo "No specified segmentation template identified. Continuing with default DK (clustering), Yeo7, & kmeans segmentation."
default=1
fi
segmentation=${codedir}/templates/r_pos_all_overlap_4.nii.gz
if [ $(imtest ${segmentation}) == 1 ] ;
then
echo "${segmentation} dataset for segmentation ok"
echo "Doing stand alone ${segmentation} segmentation analysis"
atlas=${segmentation}
#Mask atlas by hemisphere (faster & avoids conflict with connectome)
#cd segmentation
#cp ${atlas} .
outname=`basename ${atlas} .nii.gz` #for parsing outputs
echo ${atlas} > ${outname}.txt
#fslmaths ${atlas} -mas ${codedir}/templates/right_brain.nii.gz ${outname}_right
#fslmaths ${atlas} -mas ${codedir}/templates/left_brain.nii.gz ${outname}_left
#Split atlas into individual ROI files
#echo "running deparcellator ${outname}"
#deparcellator.sh ${outname}
#deparcellator.sh ${outname}_right
#deparcellator.sh ${outname}_left
#cd ../
#Left thalamus: hard segmentation
probtrackx2 --samples=bpx.bedpostX/merged \
--mask=bpx.bedpostX/nodif_brain_mask \
--xfm=bpx.bedpostX/xfms/standard2diff \
--invxfm=bpx.bedpostX/xfms/diff2standard \
--seedref=${FSLDIR}/data/standard/MNI152_T1_2mm_brain.nii.gz \
--seed=segmentation/thalamus_left_MNI.nii.gz \
--targetmasks=${outname}.txt \
--dir=thalamus2cortex_left_${outname} \
--loopcheck \
--onewaycondition \
--forcedir \
--opd \
--os2t \
--nsamples=5000
#left thalamus
#find_the_biggest thalamus2cortex_left_${outname}/seeds_to_* thalamus2cortex_left/biggest_segmentation
cluster --in=thalamus2cortex_left_${outname}/seeds_to_${outname}.nii.gz --thresh=100 --othresh=thalamus2cortex_left_${outname}/cluster_${outname}
else
echo "No specified segmentation template identified. Continuing with default DK (clustering), Yeo7, & kmeans segmentation."
default=1
fi
#fin