-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_me_a_roi_2.0.sh
107 lines (74 loc) · 3.31 KB
/
make_me_a_roi_2.0.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
#!/bin/bash
#---------------- HELP ----------------#
help() {
echo "
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # ROI Analysis for Cortical Thickness (Using CIVET and the Human Brainnetome Atlas) # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
____________
< Hey there! >
------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
This set of scripts is intended to be fed with:
a) a region from the Human Brainnetome Atlas (specifically, a region probability map),
b) cortical thickness files (outputted from CIVET) of a subjects group,
c) a cortical 3-D mesh representing the group average, and:
d) a .csv file with the variables associated with the subjects.
What this set of scripts does is:
--> convert BNA NIFTI probability map to MINC format
--> convert it to a binary mask according to the desired treshold
--> use that mask to threshold individual CT measures
--> apply a linear model (and FDR correction) over the dataset according to the specified\
dependent and independent variables.
It takes the following arguments:
[1]: BNA probability map (e.g. 025.nii)
[2]: Directory where cortical thickness files (.txt, outputted from CIVET) are located
[3]: average cortical 3-D mesh (single hemisphere, e.g. lh_average.obj)
[4]: dataframe (.csv file; important: IDs' column must be named: id
[5]: Derired threshold for delimiting the probability map
[6]: Predictor variable(s) (which can take the form accepted by R formulae; e.g. group+age)
[7]: If comparing two groups, here you must input the code of the experimental group
[8]: And control group's code
Notice: You should execute these scripts from the same directory where the required files are located.
- E.D. marcoseliseo.da at gmail dot com
"
}
if [ $# -eq 0 ]
then
echo "No arguments supplied"
help
exit 1
fi
# Warm-up
echo " # # # # # # Starting pipeline # # # # # #"
echo " # # # # # # Current working dir is " $(pwd)
id=`echo $1 | cut -d "." -f 1`
# Step 1: NIFTI 2 MINC
nii2mnc $1 ${id}_roi.mnc
echo " # # Created file: " $(ls *.mnc*)
# Step 2: MINC to Vertex
mkdir vertex_files
volume_object_evaluate ${id}_roi.mnc ${3} vertex_files/${id}_vertex.txt
echo "# # Created file: " $(ls vertex_files)
# Step 3: use R to turn into 0's and 1's
Rscript binarize_2.0.R vertex_files/${id}_vertex.txt ${5} ${id}
mv density_plot binary_mask_${id}_${5}.txt vertex_files
# Step 4: Multiply by thickness data (vertstats_math)
mkdir roi_ct
for file in $2/*.txt; do
vertstats_math -mult vertex_files/binary_mask_${id}_${5}.txt $file -old_style_file $(dirname $file)/$(basename $file .txt)_${id}_${5}.txt
done
mv $2/*_${id}_${5}.txt roi_ct
echo " # # # # # # # # # # created files: " $(ls roi_ct/*_${id}_${5}) " # # # # # # #"
prefix=`echo $2/* | cut -d "_" -f 1 | cut -d "/" -f 2`
echo " # # # # # # Created PREFIX: $prefix # # # # # # # # #"
# Step 5: Analysis (in R)
Rscript analyze_thickness_2.0.R $id $prefix $2 $4 $5 $6 $7 $8
# Step 6: Clean statistical map
sed -i 's/NA/0/g' ${id}_statmap.txt
echo " # # # # # # # # # # # Finished # # # # # # # # # # # # #"
# Me queda la duda: si corro el script desde otro directorio, se trabaja en el directorio desde el que se convoca???