-
Notifications
You must be signed in to change notification settings - Fork 6
/
tree_for_tractometry.sh
executable file
·89 lines (78 loc) · 2.89 KB
/
tree_for_tractometry.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
#!/usr/bin/env bash
usage() { echo "$(basename $0) [-r RBX] [-t tractoflow/results] [-n noddi/results] [-f freewater_flow/results] [-m mrds_flow/results] [-o output]" 1>&2; exit 1; }
while getopts "r:t:n:f:m:o:" args; do
case "${args}" in
r) r=${OPTARG};;
t) t=${OPTARG};;
n) n=${OPTARG};;
f) f=${OPTARG};;
m) m=${OPTARG};;
o) o=${OPTARG};;
*) usage;;
esac
done
shift $((OPTIND-1))
if [ -z "${r}" ] || [ -z "${t}" ] || [ -z "${o}" ]; then
usage
fi
echo "rbx_flow results folder: ${r}"
echo "tractoflow results folder: ${t}"
echo "noddi_flow results folder: ${n}"
echo "freewater_flow results folder: ${f}"
echo "mrds_flow results folder: ${m}"
echo "Output folder: ${o}"
echo "Building tree for the following folders:"
cd ${r}
for i in *;
do
echo $i
mkdir -p $o/$i/bundles
mkdir -p $o/$i/metrics
mkdir -p $o/$i/fixel_metrics
# if centroids are there, create dir
if [ -d "$r/$i/Transform_Centroids/" ]
then
mkdir -p $o/$i/centroids
ln -s $r/$i/Transform_Centroids/*.trk $o/$i/centroids/
fi
# RBX results
for file in $r/$i/Clean_Bundles/*cleaned.trk;
do
name=${file/*Clean_Bundles\//}
ln -s $file $o/$i/bundles/${name/_m_cleaned.trk/.trk}
done
# tractoflow metrics
ln -s $t/$i/DTI_Metrics/*fa.nii.gz $o/$i/metrics/fa.nii.gz
ln -s $t/$i/DTI_Metrics/*ad.nii.gz $o/$i/metrics/ad.nii.gz
ln -s $t/$i/DTI_Metrics/*md.nii.gz $o/$i/metrics/md.nii.gz
ln -s $t/$i/DTI_Metrics/*rd.nii.gz $o/$i/metrics/rd.nii.gz
ln -s $t/$i/FODF_Metrics/*afd_total.nii.gz $o/$i/metrics/afd_total.nii.gz
ln -s $t/$i/FODF_Metrics/*nufo.nii.gz $o/$i/metrics/nufo.nii.gz
# noddi_flow metrics
if [[ ! -z "${n}" ]];
then
ln -s $n/$i/Compute_NODDI/*OD.nii.gz $o/$i/metrics/noddi_od.nii.gz
ln -s $n/$i/Compute_NODDI/*ISOVF.nii.gz $o/$i/metrics/noddi_isovf.nii.gz
ln -s $n/$i/Compute_NODDI/*ICVF.nii.gz $o/$i/metrics/noddi_icvf.nii.gz
fi
# freewater_flow metrics
if [[ ! -z "${f}" ]];
then
ln -s $f/$i/Compute_FreeWater/*FW.nii.gz $o/$i/metrics/freewater.nii.gz
ln -s $f/$i/FW_Corrected_Metrics/*fa.nii.gz $o/$i/metrics/FAt.nii.gz
ln -s $f/$i/FW_Corrected_Metrics/*ad.nii.gz $o/$i/metrics/ADt.nii.gz
ln -s $f/$i/FW_Corrected_Metrics/*rd.nii.gz $o/$i/metrics/RDt.nii.gz
fi
# mrds_flow metrics
if [[ ! -z "${m}" ]];
then
ln -s $m/$i/Modsel_TODI/*PDDs_CARTESIAN.nii.gz $o/$i/pdds.nii.gz
ln -s $m/$i/Modsel_TODI/*NUM_COMP.nii.gz $o/$i/metrics/todi_nufo.nii.gz
ln -s $m/$i/MRDS_Metrics/*FA.nii.gz $o/$i/fixel_metrics/fixel_fa.nii.gz
ln -s $m/$i/MRDS_Metrics/*RD.nii.gz $o/$i/fixel_metrics/fixel_rd.nii.gz
ln -s $m/$i/MRDS_Metrics/*AD.nii.gz $o/$i/fixel_metrics/fixel_ad.nii.gz
ln -s $m/$i/MRDS_Metrics/*MD.nii.gz $o/$i/fixel_metrics/fixel_md.nii.gz
fi
done
echo "Done"
rm -rf ${o}/Average_Bundles