forked from dfsp-spirit/freesurfer_parallel_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_stats_tables.bash
executable file
·63 lines (47 loc) · 1.81 KB
/
get_stats_tables.bash
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
#!/bin/bash
### Settings ###
python2_bin=$(which python2)
#python2_bin=/usr/local/bin/python2
###
aparcstats2table_bin=$(which aparcstats2table)
asegstats2table_bin=$(which asegstats2table)
### Command line args ###
subjects_dir=$1
subjects_file=$2
#### sanity checks
if [ -z "$subjects_file" ]; then
echo "USAGE: $0 <subjects_dir> <subjects_file>"
exit 1
fi
if [ ! -d $subjects_dir ]; then
echo "ERROR: Subjects dir '$subjects_dir' does not exist."
exit 1
fi
if [ ! -f $subjects_file ]; then
echo "ERROR: Subjects file '$subjects_file' does not exist."
exit 1
fi
if [ -z "$python2_bin" ]; then
echo "ERROR: Could not autodetect path to python2 binary, please adapt setting 'python2_bin' in this script."
exit 1
fi
if [ ! -x "$python2_bin" ]; then
echo "ERROR: Cannot execute python2 binary at '$python2_bin'"
exit 1
fi
export SUBJECTS_DIR="${subjects_dir}"
#### run commands
subjects=$(cat $subjects_file | tr '\n' ' ')
num_subjects=$(echo "${subjects}" | wc -w | tr -d '[:space:]')
echo "Getting stats for $num_subjects subjects."
for hemi in lh rh; do
for measure in thickness area volume; do # Feel free to add more measures here, see the help of aparcstats2table for options.
aparc_output_table="${hemi}.aparc_table_${measure}.tsv"
# You many want to add more command line options to the call in the next line. E.g., '--skip' or '--common-parcs' may come in handy.
$python2_bin $aparcstats2table_bin --subjectsfile $subjects_file --meas $measure --hemi $hemi -t $aparc_output_table && echo " * output file '$aparc_output_table' written."
done
aseg_output_table="aseg_table.tsv"
$python2_bin $asegstats2table_bin --subjectsfile $subjects_file -t $aseg_output_table && echo " * output file '$aseg_output_table' written."
done
echo "All done, exiting."
exit 0