forked from jooh/python-fsl-batchbrain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dti_motion
executable file
·48 lines (37 loc) · 1.64 KB
/
dti_motion
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
#!/bin/sh
#Script written by Mark Jenkinson of FMRIB; posted in reply to Charlotte's question on the FSL forum 11/01/2011
if [ $# -lt 1 ] ; then
echo "Usage: `basename $0` <eddy current ecclog file>"
exit 1;
fi
logfile=$1;
basenm=`basename $logfile .ecclog`;
nums=`grep -n 'Final' $logfile | sed 's/:.*//'`;
touch grot_ts.txt
touch grot.mat
firsttime=yes;
m=1;
for n in $nums ; do
echo "Timepoint $m"
n1=`echo $n + 1 | bc` ;
n2=`echo $n + 5 | bc` ;
sed -n "$n1,${n2}p" $logfile > grot.mat ;
if [ $firsttime = yes ] ; then firsttime=no; cp grot.mat grot.refmat ; cp grot.mat grot.oldmat ; fi
absval=`$FSLDIR/bin/rmsdiff grot.mat grot.refmat $basenm`;
relval=`$FSLDIR/bin/rmsdiff grot.mat grot.oldmat $basenm`;
cp grot.mat grot.oldmat
echo $absval $relval >> ec_disp.txt ;
$FSLDIR/bin/avscale --allparams grot.mat $basenm | grep 'Rotation Angles' | sed 's/.* = //' >> ec_rot.txt ;
$FSLDIR/bin/avscale --allparams grot.mat $basenm | grep 'Translations' | sed 's/.* = //' >> ec_trans.txt ;
m=`echo $m + 1 | bc`;
done
echo "absolute" > grot_labels.txt
echo "relative" >> grot_labels.txt
$FSLDIR/bin/fsl_tsplot -i ec_disp.txt -t 'Eddy Current estimated mean displacement (mm)' -l grot_labels.txt -o ec_disp.png
echo "x" > grot_labels.txt
echo "y" >> grot_labels.txt
echo "z" >> grot_labels.txt
$FSLDIR/bin/fsl_tsplot -i ec_rot.txt -t 'Eddy Current estimated rotations (radians)' -l grot_labels.txt -o ec_rot.png
$FSLDIR/bin/fsl_tsplot -i ec_trans.txt -t 'Eddy Current estimated translations (mm)' -l grot_labels.txt -o ec_trans.png
# clean up temp files
/bin/rm grot_labels.txt grot.oldmat grot.refmat grot.mat