-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path7b_randomise_con.sh
executable file
·81 lines (71 loc) · 2.38 KB
/
7b_randomise_con.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
#!/bin/bash
# A.L.R.R. Nov 12, 2020
# Script to convert individual images to MNI space, create 4D files (all...
# ...subject MNI converted control ROI-WB FC), and run randomise on those...
# ...files to obtain group-specific (1stt) maps.
## Define paths
source var_names.sh
## Define the (control) ROIs and an array including them
roi1=09-LINS
roi2=12-RINS
ROIS=($roi1 $roi2)
## Define number of time points (according to longitudinal data)
TP=3
## Create the output folder if it doesn't exist
mkdir -p $OUTPUTFOLDER
## Loop through the participants' folder to warp the native whole-brain...
## ...images to MNI space to prepare them for randomise
for participant in $INPUTFOLDER*
do
foldername=`basename $participant`
echo "Process for $foldername"
cd $participant
for mask in ${participant}/*
do
maskname=`basename $mask`
if [[ ${maskname} == SCA* ]]
then
maskname=`basename $mask | sed 's/SCA_DR_//'`
cd $mask
if [ ! -f ${maskname}_MNI.nii.gz ]
then
echo "flirt for $maskname..."
flirt -usesqform -in $mask/dr_stage2_ic0000.nii.gz -ref $STD_TEMPLATE -applyxfm -init $DATAFOLDER/${foldername}/${REGFOLDER}/example_func2standard.mat -out $mask/${maskname}_MNI
echo "...done"
fi
fi
done
done
## Merge all participant's images per ROI and time point (within the ROI)...
## ...for randomization, looping through ROIs in the OUTPUTFOLDER and...
## ...time points
echo "Now continuing with fslmerge..."
for roi in ${ROIS[@]}
do
mkdir -p $OUTPUTFOLDER/$roi
echo "...Merging $roi across participants and time points..."
for timepoint in $(seq 1 $TP)
do
echo "...Merging timepoint 0$timepoint..."
fslmerge -t $OUTPUTFOLDER/${roi}/${roi}_0$timepoint $INPUTFOLDER/wsu-???-00??-0${timepoint}/SCA_DR_${roi}/${roi}_MNI.nii.gz
echo "...done"
done
done
echo "Merging of all ROIs, done"
## Loop for randomise through participant folder and time point while...
## ...using the MNI brain mask as mask
echo "Now starting randomise: (warning: it takes a while)"
for map in $OUTPUTFOLDER*
do
foldername=`basename $map`
cd $map
for timepoint in ${map}/*
do
tpname=`basename $timepoint | sed 's/.nii.gz//'`
echo "Randomising across $tpname..."
randomise -i $timepoint -o ${tpname}_1stt -1 -T -m $MASKFOLDER/MNI152_T1_2mm_brain_mask.nii.gz
echo "...done"
done
done
## End message
echo "* FINISHED $0 ON $(date) *"