-
Notifications
You must be signed in to change notification settings - Fork 1
/
fdt_rotate_bvecs
70 lines (60 loc) · 2.1 KB
/
fdt_rotate_bvecs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
if [ "$3" == "" ] ; then
echo "Usage: <original bvecs> <rotated bvecs> <ecclog>"
echo ""
echo "<ecclog> is the output log file from ecc"
echo ""
exit 1;
fi
i=$1
o=$2
ecclog=$3
if [ ! -e $1 ] ; then
echo "Source bvecs $1 does not exist!"
exit 1
fi
if [ ! -e $ecclog ]; then
echo "Ecc log file $3 does not exist!"
exit 1
fi
ii=1
rm -f $o
tmpo=${o}$$
cat ${ecclog} | while read line; do
echo $ii
if [ "$line" == "" ];then break;fi
read line;
read line;
read line;
echo $line > $tmpo
read line
echo $line >> $tmpo
read line
echo $line >> $tmpo
read line
echo $line >> $tmpo
read line
m11=`avscale $tmpo | grep Rotation -A 1 | tail -n 1| awk '{print $1}'`
m12=`avscale $tmpo | grep Rotation -A 1 | tail -n 1| awk '{print $2}'`
m13=`avscale $tmpo | grep Rotation -A 1 | tail -n 1| awk '{print $3}'`
m21=`avscale $tmpo | grep Rotation -A 2 | tail -n 1| awk '{print $1}'`
m22=`avscale $tmpo | grep Rotation -A 2 | tail -n 1| awk '{print $2}'`
m23=`avscale $tmpo | grep Rotation -A 2 | tail -n 1| awk '{print $3}'`
m31=`avscale $tmpo | grep Rotation -A 3 | tail -n 1| awk '{print $1}'`
m32=`avscale $tmpo | grep Rotation -A 3 | tail -n 1| awk '{print $2}'`
m33=`avscale $tmpo | grep Rotation -A 3 | tail -n 1| awk '{print $3}'`
X=`cat $i | awk -v x=$ii '{print $x}' | head -n 1 | tail -n 1 | awk -F"E" 'BEGIN{OFMT="%10.10f"} {print $1 * (10 ^ $2)}' `
Y=`cat $i | awk -v x=$ii '{print $x}' | head -n 2 | tail -n 1 | awk -F"E" 'BEGIN{OFMT="%10.10f"} {print $1 * (10 ^ $2)}' `
Z=`cat $i | awk -v x=$ii '{print $x}' | head -n 3 | tail -n 1 | awk -F"E" 'BEGIN{OFMT="%10.10f"} {print $1 * (10 ^ $2)}' `
rX=`echo "scale=7; ($m11 * $X) + ($m12 * $Y) + ($m13 * $Z)" | bc -l`
rY=`echo "scale=7; ($m21 * $X) + ($m22 * $Y) + ($m23 * $Z)" | bc -l`
rZ=`echo "scale=7; ($m31 * $X) + ($m32 * $Y) + ($m33 * $Z)" | bc -l`
if [ "$ii" -eq 1 ];then
echo $rX > $o;echo $rY >> $o;echo $rZ >> $o
else
cp $o $tmpo
(echo $rX;echo $rY;echo $rZ) | paste $tmpo - > $o
fi
let "ii+=1"
done
rm -f $tmpo