-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract_dosing.sh
executable file
·71 lines (64 loc) · 3.42 KB
/
extract_dosing.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
#!/bin/bash
# usage:
# extract_dosing.sh S206 22249 cope3
subid=$1
subjectID=$1
serverID=$2
interaction=$3
skinloc=/Users/BSEL/Desktop/WMT+TMS_Subjects/WMTMS_Anat/${1}/m2m_${1}
mtsimloc=/Users/BSEL/Desktop/WMT+TMS_Subjects/WMTMS_Anat/${1}/MTsim/
dosingsimloc=/Users/BSEL/Desktop/WMT+TMS_Subjects/WMTMS_Anat/${subid}/DosingSim/
dosingdataloc=/Users/BSEL/Desktop/WMT+TMS_Subjects/WMTMS_Anat/${1}/DosingSim/DosingData/
parietalfmriloc=/Volumes/Cabeza/WMTMS.01/Analysis/CAC_ParametricSlopes/DelayParModels/separate_models/*${serverID}/*Level2.gfeat/${interaction}.feat/stats/
parietalmaskloc=/Volumes/Cabeza/WMTMS.01/Analysis/CAC_ParametricSlopes/
matlab=/Applications/MATLAB_R2016a.app/bin/matlab
transmat=${subid}"_MNI_to_SIMNIBS.mat"
transmatloc=/Users/BSEL/Desktop/WMT+TMS_Subjects/WMTMS_Anat/${1}/DosingSim/DosingData/${transmat}
## Making Directories
if [ ! -d /Users/BSEL/Desktop/WMT+TMS_Subjects/WMTMS_Anat/${1}/DosingSim/DosingData ]; then
echo Making Dosing Output Directory.......
mkdir /Users/BSEL/Desktop/WMT+TMS_Subjects/WMTMS_Anat/${1}/DosingSim/DosingData
echo Complete
fi
## Moving Files into calculation Directory
echo Moving brain scan
# Brain and aparcaseg
cd /Users/BSEL/Desktop/WMT+TMS_Subjects/WMTMS_Anat/${1}/fs_${1}/mri/
mri_convert brain.mgz brain.nii
mri_convert aparc+aseg.mgz aparcaseg.nii
cp brain.nii ../../DosingSim/DosingData/
cp aparcaseg.nii ../../DosingSim/DosingData/
## Creating masks for simulation extraction
cd ${skinloc}
${matlab} -nodisplay -nodesktop -r "process_mask('${subjectID}'),quit"
cp ${parietalmaskloc}/constrained_parietal_mask_FINAL.nii.gz ${dosingdataloc}/parietalmask_MNI.nii.gz
cp ${parietalmaskloc}/parietal_wes.nii.gz ${dosingdataloc}/parietalmask_wes_MNI.nii.gz
# fMRI activation
echo Moving zstat and transforming to individual space
cd ${dosingdataloc}
cp /usr/local/fsl/data/standard/MNI152_T1_2mm_brain.nii.gz /Users/BSEL/Desktop/WMT+TMS_Subjects/WMTMS_Anat/${1}/DosingSim/DosingData/MNI.nii.gz
cp /usr/local/fsl/data/standard/MNI152_T1_2mm_brain.nii.gz /Users/BSEL/Desktop/WMT+TMS_Subjects/WMTMS_Anat/${1}/DosingSim/DosingData/MNI_orig.nii.gz
cd ${parietalfmriloc}
cp zstat1.nii* ${dosingdataloc}/zstat_MNI.nii.gz
if [ ! -f /Users/BSEL/Desktop/WMT+TMS_Subjects/WMTMS_Anat/${1}/DosingSim/DosingData/zstat_${subid}.nii.gz ]; then
cd ${dosingdataloc}
flirt -in MNI.nii.gz -ref brain.nii -out MNI_to_${subid} -omat ${transmatloc} -bins 256 -cost corratio -searchrx -90 90 -searchry -90 90 -searchrz -90 90 -dof 12 -interp trilinear
flirt -in zstat_MNI.nii.gz -ref brain.nii -out zstat_${subid}.nii.gz -applyxfm -init ${transmat} -interp trilinear
fi
#if [ ! -f /Users/BSEL/Desktop/WMT+TMS_Subjects/WMTMS_Anat/${1}/DosingSim/DosingData/parietalmask_${subid}.nii.gz ]; then
cd ${dosingdataloc}
flirt -in parietalmask_MNI.nii.gz -ref brain.nii -out parietalmask_${subid}.nii.gz -applyxfm -init ${transmat} -interp trilinear
#fi
if [ ! -f /Users/BSEL/Desktop/WMT+TMS_Subjects/WMTMS_Anat/${1}/DosingSim/DosingData/parietalmask_wes_${subid}.nii.gz ]; then
cd ${dosingdataloc}
flirt -in parietalmask_wes_MNI.nii.gz -ref brain.nii -out parietalmask_wes_${subid}.nii.gz -applyxfm -init ${transmat} -interp trilinear
fi
# extract parietalsim
echo Extracting Parietal Efield
cd ${dosingsimloc}
pwd
for i in $(ls *merge.msh)
do
msh2nii --mesh=$i --mask=mask.nii --hdr=../${subjectID}_T1fs_conform.nii.gz --fields=eE --fn_out='parietal_efield' > /dev/null 2>&1
done
cp parietal_efield_normE.nii.gz DosingData/efield.nii.gz