Skip to content

Commit 4ccf11f

Browse files
authored
Create script_fMRIPrep_Analysis.sh
1 parent 927849f commit 4ccf11f

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

script_fMRIPrep_Analysis.sh

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
#This script assumes you have already run the file make_Timings.sh, as explained in this chapter: https://andysbrainbook.readthedocs.io/en/latest/OpenScience/OS/fMRIPrep_Demo_5_1stLevelAnalysis.html
4+
#This is combined code from the OpenScience module of Andy's Brain Book: https://andysbrainbook.readthedocs.io/en/latest/OpenScience/OS/fMRIPrep_Demo.html
5+
6+
7+
for i in `cat subjList.txt`; do
8+
cd code;
9+
bash fmriprep_Scripted.sh $i;
10+
cd ../derivatives/fmriprep/${i}/func
11+
for run in 1 2; do
12+
3dmerge -1blur_fwhm 4.0 -doall -prefix r${run}_blur.nii \
13+
${i}_task-flanker_run-${run}_space-MNI152NLin2009cAsym_res-2_desc-preproc_bold.nii.gz;
14+
done
15+
for run in 1 2; do
16+
3dTstat -prefix rm.mean_r${run}.nii r${run}_blur.nii;
17+
3dcalc -a r${run}_blur.nii -b rm.mean_r${run}.nii \
18+
-c ${i}_task-flanker_run-${run}_space-MNI152NLin2009cAsym_res-2_desc-brain_mask.nii.gz \
19+
-expr 'c * min(200, a/b*100)*step(a)*step(b)' \
20+
-prefix r${run}_scale.nii;
21+
done
22+
rm rm*;
23+
3dmask_tool -inputs *mask.nii.gz -union -prefix full_mask.nii
24+
mkdir stimuli;
25+
cp ../../../../${i}/func/*.1D stimuli;
26+
cp ../../../../doDecon.sh .;
27+
for reg in trans_x trans_y trans_z rot_x rot_y rot_z; do
28+
for run in 1 2; do
29+
awk -v col=$reg 'NR==1{for(i=1;i<=NF;i++){if($i==col){c=i;break}} print $c} NR>1{print $c}' ${i}_task-flanker_run-${run}_desc-confounds_regressors.tsv > ${reg}_run${run}_all_tmp.txt;
30+
sed '1d' ${reg}_run${run}_all_tmp.txt > ${reg}_run${run}_noHead_tmp.txt
31+
sed '1!d' ${reg}_run${run}_all_tmp.txt > ${reg}_run${run}_Head_tmp.txt
32+
done
33+
done
34+
NT=`3dinfo -nt r1_scale.nii`
35+
if [ -f zeros_tmp.txt ]; then rm zeros_tmp.txt; fi
36+
for ((j=0; j<$NT; j++)); do echo 0 >> zeros_tmp.txt; done
37+
for reg in trans_x trans_y trans_z rot_x rot_y rot_z; do
38+
for run in 1 2; do
39+
if [ $run -eq 1 ]; then
40+
cat ${reg}_run${run}_noHead_tmp.txt > ${reg}_run${run}.txt
41+
else
42+
cat zeros_tmp.txt ${reg}_run${run}_noHead_tmp.txt > ${reg}_run${run}.txt
43+
fi
44+
done
45+
done
46+
rm *tmp*
47+
tcsh doDecon.sh $i
48+
cd ../../../..
49+
done

0 commit comments

Comments
 (0)