Alexsavio scripts
De Grupo de Inteligencia Computacional (GIC)
FSL Tools
create_mean_template.sh
#!/bin/bash
#This script reads all images from the $subjs_root directory and creates a new smoothed image with the mean intensity value of all the images.
subjs_root=../Female/original
target_dir=$PWD
cd $subjs_root
cont=0
subj_num=`ls *t88_gfc*hdr | wc -l`
template=template.nii.gz
temp=temp.nii.gz
if [ -f $template ]
then
rm -f $template
fi
if [ -f $temp ]
then
rm -f $temp
fi
ls *hdr | while read vol;
do
cont=$(($cont + 1))
echo $cont - $vol
if [ -f $template ]
then
tmp=`fslstats $vol -r`
max_intensity=${tmp:`expr index "$tmp" ' '`:${#tmp}}
fslmaths -dt double $vol -div $subj_num $temp
fslmaths -dt double $temp -add $template $template -odt double
else
tmp=`fslstats $vol -r`
max_intensity=${tmp:`expr index "$tmp" ' '`:${#tmp}}
fslmaths -dt double $vol -div $subj_num $template
fi
done
cont=`ls *hdr | wc -l`
#smooth
fslmaths $template -kernel gauss 2 -fmean $template
mv $template $target_dir
rm -f $temp
echo $cont files processed.