From 20165ae8841545d55bbf5f9baaec5cb3e4d9a5c0 Mon Sep 17 00:00:00 2001
From: Saad Jbabdi <saad@fmrib.ox.ac.uk>
Date: Thu, 11 Mar 2010 10:11:01 +0000
Subject: [PATCH] back to copying input. this time it's called bvecs_unrotated

---
 rotate_bvecs | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/rotate_bvecs b/rotate_bvecs
index 84216b2..ce0670a 100755
--- a/rotate_bvecs
+++ b/rotate_bvecs
@@ -3,8 +3,7 @@
 if [ "$2" == "" ];then
     echo ""
     echo "Usage: rotate_bvecs <ecclogfile> <bvecs>"
-        echo "used to update bvecs based on eddy correction"
-    echo "will create a new bvecs file called <bvecs>_rot"
+    echo "will save bvecs file into <bvecs>_unrotated and create new bvecs file called <bvecs>"
     echo ""
     exit 1
 fi
@@ -12,21 +11,22 @@ fi
 ecclog=$1
 bvecs=$2
 
-if [ -f ${bvecs}_rot ];then
+if [ -f ${bvecs}_unrotated ];then
     echo ""
-    echo "Error: Found that ${bvecs}_rot already exists"
-    echo "This probably means that you have run this script before."
-    echo "To get this program to run, please remove the file ${bvecs}_rot"
+    echo "Error: Found that ${bvecs}_unrotated already exists"
+    echo "This probably means that you have run this script before. Be aware that this also means ${bvecs} have already been rotated!"
+    echo "If you want to force this program to run, please remove the file ${bvecs}_unrotated"
     echo ""
     exit 1
 fi
-
+/bin/cp ${bvecs} ${bvecs}_unrotated
+#/bin/rm -f ${bvecs}
 
 
 # this only works if the bvecs are in lines...
-Xs=$(cat ${bvecs} | head -1 | tail -1)
-Ys=$(cat ${bvecs} | head -2 | tail -1)
-Zs=$(cat ${bvecs} | head -3 | tail -1)
+Xs=$(cat ${bvecs}_unrotated | head -1 | tail -1)
+Ys=$(cat ${bvecs}_unrotated | head -2 | tail -1)
+Zs=$(cat ${bvecs}_unrotated | head -3 | tail -1)
 
 rnd=${$}
 cat ${ecclog} | while read line; do
@@ -96,7 +96,7 @@ for matfile in /tmp/grot${rnd}_*.mat;do
     i=$(echo "$i + 1" | bc) ;
 done
 
-echo "$rXs" > ${bvecs}_rot;
-echo "$rYs" >> ${bvecs}_rot;
-echo "$rZs" >> ${bvecs}_rot;
+echo "$rXs" > ${bvecs};
+echo "$rYs" >> ${bvecs};
+echo "$rZs" >> ${bvecs};
 
-- 
GitLab