From eda25c23514382b2ebe1640467e8461a88cdad47 Mon Sep 17 00:00:00 2001
From: Tim Behrens <behrens@fmrib.ox.ac.uk>
Date: Wed, 21 Apr 2004 12:37:32 +0000
Subject: [PATCH] *** empty log message ***

---
 Makefile     |  2 +-
 eddy_correct | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)
 create mode 100644 eddy_correct

diff --git a/Makefile b/Makefile
index 1ba6537..0f67ade 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,7 @@ FTBOBJS=find_the_biggest.o
 PJOBJS=proj_thresh.o
 MEDOBJS=medianfilter.o 
 
-
+SCRIPTS = eddy_correct
 XFILES = dtifit probtrack find_the_biggest medianfilter
 RUNTCLS = Fdt
 
diff --git a/eddy_correct b/eddy_correct
new file mode 100644
index 0000000..6159a3b
--- /dev/null
+++ b/eddy_correct
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+Usage() {
+echo ""
+echo "Usage: eddy_coorect <4dinput> <4doutput> <reference_no>"
+echo ""
+exit
+}
+
+[ "$1" = "" ] && Usage
+[ "$2" = "" ] && Usage
+[ "$3" = "" ] && Usage
+
+input=`basename ${1} .hdr`
+input=`basename ${input} .img`
+output=`basename ${2} .hdr`
+output=`basename ${output} .img`
+ref=${3}
+
+if [ ! -e ${input}.hdr -o ! -e ${input}.img ];then
+    echo "Input does not exist or is not in analyze format"
+    exit
+fi
+
+avwroi ${input} ${$}ref ${ref} 1
+
+nvols=`avwval ${input} dim4`
+avwsplit ${input}
+i=0;
+avwmaths vol0000 newvol0000
+while [ ${i} -lt ${nvols} ];do
+    echo ${i} volumes completed
+    inp=`zeropad $i 4`;
+    flirt -in vol${inp} -ref ${$}ref  -nosearch -o newvol${inp}
+    i=`expr $i + 1`; 
+done
+rm vol* ${$}*
+avwmerge -t ${output} newvol*.hdr
+
+rm newvol*
+
+
+
-- 
GitLab