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.
create_tissue_prob_maps.sh
#!/bin/bash subjs_root=../Female/segmented target_dir=$PWD cd $subjs_root cont=0 white_map=white.nii.gz grey_map=grey.nii.gz csf_map=csf.nii.gz temp_white=temp_white.nii.gz temp_grey=temp_grey.nii.gz temp_csf=temp_csf.nii.gz if [ -f $white_map ] then rm $white_map fi if [ -f $grey_map ] then rm $grey_map fi if [ -f $csf_map ] then rm $csf_map fi ls *hdr | while read vol; do cont=$(($cont + 1)) echo $cont - $vol #obtain white matter fslmaths $vol -thr 3 -bin $temp_white #obtain csf fslmaths $vol -uthr 1 -bin $temp_csf #obtain grey fslmaths $vol -thr 2 $temp_grey fslmaths $temp_grey -uthr 2 -bin $temp_grey #sum white if [ -f $white_map ] then fslmaths $white_map -add $temp_white $white_map else cp $temp_white $white_map fi if [ -f $grey_map ] then fslmaths $grey_map -add $temp_grey $grey_map else cp $temp_grey $grey_map fi if [ -f $csf_map ] then fslmaths $csf_map -add $temp_csf $csf_map else cp $temp_csf $csf_map fi done cont=`ls *hdr | wc -l` #normalize fslmaths -dt float $white_map -div $cont $white_map -odt float fslmaths -dt float $grey_map -div $cont $grey_map -odt float fslmaths -dt float $csf_map -div $cont $csf_map -odt float #smooth fslmaths $white_map -kernel gauss 2 -fmean $white_map fslmaths $grey_map -kernel gauss 2 -fmean $grey_map fslmaths $csf_map -kernel gauss 2 -fmean $csf_map #move to target directory mv $white_map $target_dir mv $grey_map $target_dir mv $csf_map $target_dir rm $temp_white rm $temp_csf rm $temp_grey echo $cont files processed.