From 03b7cb37402c64247def9160b4a31bacd53a1852 Mon Sep 17 00:00:00 2001
From: Rita Nunes <rita@fmrib.ox.ac.uk>
Date: Wed, 6 Oct 2004 13:34:54 +0000
Subject: [PATCH] changed the script to be compatible with any image format

---
 remove_vols | 38 +++++++++++++++-----------------------
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/remove_vols b/remove_vols
index 79ad1ff..933e398 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    
-
-
-
-
-
-
-
-
-
-- 
GitLab