#!/bin/bash

#create template_list file

for f in *.nii
do

echo $f >> template_list

done

#run slicesdir to quickly check the data
slicesdir `imglob *`

#create the design matrix and contrasts file
design_ttest2 design 4 4

#run first step of fslvbm with -N option due to neck being included in the images

fslvbm_1_bet -N

#run second step of fslvbm with -n option for non-linear registration

fslvbm_2_template -n

#check the fslvbm_2_template output in fsleyes
fsleyes struc/template_4D_GM.nii.gz

#run third and final step to process images for stats
fslvbm_3_proc

#run statistical inference with randomise
cd stats 

randomise -i GM_mod_merg_s3 -o results -m GM_mask -d design.mat -t design.con -n 5000 -T -V

#visualise results
for f in results_tfce_corrp_tstat*
do

fsleyes $FSLDIR/data/standard/MNI152_T1_2mm_brain.nii.gz $f -cm red-yellow -dr 0.95 1 &

done


