-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmove2xnat
More file actions
executable file
·101 lines (77 loc) · 1.89 KB
/
Copy pathmove2xnat
File metadata and controls
executable file
·101 lines (77 loc) · 1.89 KB
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
#!/bin/bash
function helpme()
{
echo "USAGE: move2xnat -datadir=<path_to_subjects> -studyname=<your_study_name>"
echo
echo "This will move your dicoms and recon-all output to"
echo "xnat and replace the data current directories with "
echo "symlinks to the data :)"
echo
echo "Please ensure that <path_to_subjects> contains a"
echo "directory called dicoms as well as the recon-all"
echo "generated output directories"
echo
echo "Written by John Salvatore -- jsalva@mit.edu"
exit 0
}
function main()
{
xnatsurfdir="/mindhive/xnat/surfaces/${studyname}"
xnatdicomdir="/mindhive/xnat/dicom_storage/${studyname}"
for d in $(find ${datadir} -maxdepth 1 -type d |sed "s|${datadir}\/||g"); do
echo $d
if [ ! -d "${xnatdicomdir}/$d" ];then
cmd="mkdir -p ${xnatdicomdir}/$d"
echo ${cmd}
eval ${cmd}
fi
if [ ! -d "${xnatsurfdir}/$d" ];then
cmd="mkdir -p ${xnatsurfdir}/$d"
echo ${cmd}
eval ${cmd}
fi
#echo "rsync -rLptgD /mindhive/gablab/CARD/data/$d/dicoms ${xnatdir}/$d" | qsub -V -q bigmem
dicomdir="${datadir}/$d/dicoms"
echo ${dicomdir}
if [ ! -L ${dicomdir} ]; then
mv ${dicomdir} ${xnatdicomdir}/$d
ln -s "${xnatdicomdir}/$d/dicoms" "${dicomdir}"
fi
for dir in surf mri label bem src "touch" scripts stats tmp trash; do
fsdir=${datadir}/$d/${dir}
echo ${fsdir}
if [ ! -L ${fsdir} ]; then
mv ${fsdir} ${xnatsurfdir}/$d
ln -s ${xnatsurfdir}/$d/${dir} ${fsdir}
fi
done
done
exit 1
}
if [ $# != 0 ]; then
for arg in "$@"
do
case "${arg}" in
-h|-help|help)
helpme
;;
-datadir=*|-data=*)
darg=`echo ${arg} | sed 's/[-a-zA-Z0-9]*=//'`
echo "darg = "$darg
datadir=${darg}
;;
-studyname=*|-study=*)
sarg=`echo ${arg} | sed 's/[-a-zA-Z0-9]*=//'`
studyname=${sarg}
echo "sarg = "$sarg
;;
*)
echo "Error: Nonsense input, aborting"
exit 0
;;
esac
done
main
fi
echo "Error: No arguments. Try again with -help"
exit 0