diff --git a/remove_vols b/remove_vols index 79ad1ffac752bca93061588aba5affe0489b9b64..933e3985e4ab31ac8a58470beaa4c3083735b803 100755 --- a/remove_vols +++ b/remove_vols @@ -21,7 +21,7 @@ input_file=$1 output_file=$2 current_dir=`pwd` -if [ ! -e $input_file.hdr ]; then +if [ ! `imtest $input_file` ]; then echo Cant find $input_file exit fi @@ -36,7 +36,7 @@ if [ ! -e bvecs ]; then exit fi -avwsplit $input_file.hdr +avwsplit $input_file vol=0 num_vols=`expr $# - 2` @@ -51,39 +51,31 @@ while [ $vol -lt $num_vols ]; do v=$3 shift - if [ -e vol000${v}.hdr ]; then - rm vol000${v}.hdr -f - rm vol000${v}.img -f + if [ `imtest vol000${v}` ]; then + imrm vol000${v} fi - if [ -e vol00${v}.hdr ]; then - rm vol00${v}.hdr -f - rm vol00${v}.img -f + if [ `imtest vol00${v}` ]; then + imrm vol00${v} fi echo $v > tmp1 cat dodgy_vols tmp1 > tmp2 cat tmp2 > dodgy_vols + rm tmp* -f vol=`expr $vol + 1` done -echo "addpath('/usr/people/dtiuser/etc/FMRIB_bvals_bvecs/')">tmp3 -echo "remove_vols('$current_dir')">tmp4 -cat tmp3 tmp4 >tmp.m -cat tmp.m | matlab -rm tmp* -f +echo Removing dodgy volumes from bvals and bvecs +matlab -nodisplay -nojvm -nosplash 1> matlab.out1 2>&1 <<EOF + addpath('/usr/people/dtiuser/etc/FMRIB_bvals_bvecs/'); + remove_vols('$current_dir'); + exit +EOF +rm matlab.out1 -f echo "Merging Volumes" -avwmerge -t $output_file vol*.hdr +avwmerge -t $output_file `$FSLDIR/bin/imglob -oneperimage vol*` rm vol* -f rm dodgy_vols -f - - - - - - - - -