-
Notifications
You must be signed in to change notification settings - Fork 0
/
OHSU_CMPwrapper.bash
executable file
·107 lines (89 loc) · 4.33 KB
/
OHSU_CMPwrapper.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
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
#!/bin/bash -e
#run this script with the following qsub submission:
#qsub -N CMPLOG_${sub} -sync y -l mf=1.75G,h_vmem=4G,h=fozzie,h_rt=18:00:00 -pe smp 2 xvfb-run -a OHSU_CMPwrapper.bash <subjectFolder> <HCP_group> <scan_date> <motion in DWI (1 or 0)>
#command usage
if [[ $# -ne 5 ]]; then
echo -e "\nUsage: `basename $0` <subjectFolder> <HCP_group> <scan_date> <motion in DWI (1 or 0)> <where_to_process>"
echo -e "\ne.g. `basename $0` 11938-1 ADHD-HumanYouth-OHSU 20130309 0 /scratch/grayson_temp"
echo -e "\nif there is no motion to remove, use 0, otherwise use 1"
exit 1
fi
#assign cmdline args
sub=$1
group=$2
scandate=$3
motion=$4
topdir=$5
#define top-level directories
initdir=`readlink -m /group_shares/FAIR_HCP/HCP/processed/${group}/${sub}`
FSdir=`readlink -m ${initdir}/${scandate}-SIEMENS*Study/HCP*FNL*/T1w/${sub}`
Rawdir=`readlink -m /group_shares/FAIR_HCP/HCP/sorted/${group}/${sub}/${scandate}-SIEMENS_TrioTim-Nagel_K_Study/`
analysesdir=`readlink -m ${initdir}/${scandate}-SIEMENS*Study/HCP*FNL*/analyses_v2`
T1andT2dir=`readlink -m ${initdir}/${scandate}-SIEMENS*Study/HCP*FNL*/T1w`
######## IMPORTANT ISSUE #########
#FSdir, analysesdir, and T1andT2dir will need to vary per subject/scandate depending on what Eric Earl recommends
#will need to decide whether to assign these directories using HCP_prerelease_FNL_0_1, HCP_FNL_NOT2_VER, or HCP_NoT2_NoDFM
######## ######## ######## ########
#check for existence of folders
if [ ! -d "${FSdir}" ]; then
echo -e "\nFATAL ERROR: T1/T2/Freesurfer folder missing. See below\n"
ls ${FSdir}
exit 1
fi
if [ ! -d ${Rawdir}/*Woodward_DTI_72directions_10b0 ]; then
echo -e "\nFATAL ERROR: DWI folder missing, or there's more than one DWI folder. See below\n"
ls ${Rawdir}/*Woodward_DTI_72directions_10b0
exit 1
fi
#if T1 and T2 files are found, define raw data directories/files
if [[ -f "${T1andT2dir}/T1w_acpc_dc_restore.nii.gz" && -f "${T1andT2dir}/T1w_acpc_dc_restore.nii.gz" ]]; then
T1data=`readlink -f ${T1andT2dir}/T1w_acpc_dc_restore.nii.gz`
T2data=`readlink -f ${T1andT2dir}/T2w_acpc_dc_restore.nii.gz`
DTIdata=`readlink -m ${Rawdir}/*Woodward_DTI_72directions_10b0`
#T1data=`readlink -m ${Rawdir}/*T1Anatomical_1_ISO`
#T2data=`readlink -m ${Rawdir}/*t2_spc_1mm_p2`
else
echo -e "\nFATAL ERROR: T1 and T2 files missing. See below\n"
ls ${T1andT2dir}/T1w_acpc_dc_restore.nii.gz ${T1andT2dir}/T2w_acpc_dc_restore.nii.gz
exit 1
fi
#where and how to process
procdir=${topdir}/OHSU_CMP_data_finished
movetrks=${topdir}/OHSU_CMP_tracks_to_archive
config=OHSU_MRtrixCSD_prob
echo "${sub} FOLDER WILL BE IN ${procdir}"
mkdir -p ${procdir} ${movetrks}
orig_wd=$PWD
cd ${procdir}
case setup in
setup)
echo "RUNNING SET-UP SCRIPT ON RAW DATA"
#call qsub with -sync here (so this script doesn't skip ahead before finishing the setup)
#right now this is problematic only if motion is present because OHSU_createSub.bash will ask for user input about frame removal
#qsub -N setupLOG_${sub} -sync y -l h_rt=4:00:00 OHSU_createSub.bash ${sub} ${T1data} ${DTIdata} ${T2data} ${motion}
OHSU_createSub.bash ${sub} ${T1data} ${DTIdata} ${T2data} ${motion}
echo "MAKING FREESURFER FOLDER WITH ALL SYMLINKS TO EXISTING DATA"
pushd $sub
currdir=`readlink -m .`
cp -rs ${FSdir}/ ${currdir}/
mv ${sub} FREESURFER
popd
;&
CMP)
echo "RUNNING CONNECTOMEMAPPER IN ${procdir}"
mkdir -p ${movetrks}
#qsub -N CMPLOG_${sub} -sync y -l mf=1.75G,h_vmem=4G,h=fozzie,h_rt=12:00:00 -pe smp 2 xvfb-run -a run_cmp_v2.1beta_serial.bash ${sub} /group_shares/PSYCH/code/development/utilities/customCMPmatrix/CONFIGS/${config}.ini Gordon True 0 .
run_cmp_v2.1beta_serial.bash ${sub} /group_shares/PSYCH/code/development/utilities/customCMPmatrix/CONFIGS/${config}.ini Gordon True 0 .
;&
Markov)
#qsub -N MarkovLOG_${sub} -sync y -l mf=3.5G,h_vmem=4G,h_rt=4:00:00 run_cmp_v2.1beta_serial.bash ${sub} /group_shares/PSYCH/code/development/utilities/customCMPmatrix/CONFIGS/${config}.ini Markov True ${movetrks} .
run_cmp_v2.1beta_serial.bash ${sub} /group_shares/PSYCH/code/development/utilities/customCMPmatrix/CONFIGS/${config}.ini Markov True ${movetrks} .
mkdir -p ${analysesdir}/DWI
for file in connectomes_${config}/${sub}/connectivity_matrices/connectome*mat;do
parc=`echo $file | sed 's/.*\/connectome_//' | sed 's/Parc_reslice//' | sed 's/\.mat//'`
cp -f ${file} ${analysesdir}/DWI/${sub}_${config}_${parc}_subcortical.pconn.mat
done
;;
esac
cd ${orig_wd}
exit