You can use the 2dseq file and just grep and awk the info from the d3proc and acqp files. Here's the bash script that I use - you milage my vary. You'll need to change the mygawk and mygrep variables and maybe change the bytorda part, too:
Quote
#!/bin/bash
progname=`basename $0`
version='1.0 23-AUG-2005'
cwd=$PWD
MYGAWK=/app/abt/nosw/bin/gawk
MYGREP=/usr/bin/grep
# Subroutines
######################
usage ()
{
echo "USAGE: $progname input"
echo " * for input use 'subject' (to convert all image sets) or '2dseq' (to convert just one)"
echo " * output filenames are automatically generated in the base directory like directory.subject.recon+orig.HEAD"
}
getpar ()
{
${MYGREP} $2 $1 | awk -F= '{print $2}'
}
getpar2 ()
{
${MYGAWK} "BEGIN{ ORS=\" \";OFS=\"\" } \$1~/$2/{ getline ; for(i=1;i<=NF;i++) print \$i }" "$1"
}
p2a ()
{
SESSION=$1
RAWFILE=$2
rawdir=`dirname $RAWFILE`
subjdir=`dirname $rawdir`
subjdir=`dirname $subjdir`
reno=`basename $rawdir`
sno=`dirname $rawdir`
sno=`dirname $sno`
sno=`basename $sno`
sno=`printf "%2.2d" $sno`
bname=`basename $SESSION`
outfile="${bname}.${sno}.${reno}"
# echo "$RAWFILE -> $SESSION : $outfile"
file="${rawdir}/d3proc"
# echo "$file"
param="PR_STA="
fov=`getpar2 $file $param`
xfov=`echo $fov | awk '{print $1}'`
xfov=`echo "$xfov * 10" | bc`
yfov=`echo $fov | awk '{print $2}'`
yfov=`echo "$yfov * 10" | bc`
# echo "fov(mm): $xfov X $yfov"
param="\$DATTYPE"
DATTYPE=`getpar $file $param`
# echo "DATTYPE: $DATTYPE"
case $DATTYPE in
"ip_int")
dtype="i"
;;
"ip_short")
dtype=""
;;*)
dtype=""
esac
param="\$IM_SIX"
nx=`getpar $file $param`
# echo "NX: $nx"
param="\$IM_SIY"
ny=`getpar $file $param`
# echo "ny: $ny"
param="\$IM_SIZ"
zlength=`getpar $file $param`
# echo "zlength: $zlength"
# file="${rawdir}/procs"
# echo "$file"
# param="\$YMAX_p"
# max=`getpar $file $param`
# echo "max: $max"
# param="\$YMIN_p"
# min=`getpar $file $param`
# echo "min: $min"
file="${subjdir}/acqp"
# echo "$file"
param="\$NI"
nz=`getpar $file $param`
# echo "nz: $nz"
param="\$NR"
nt=`getpar $file $param`
# echo "nt: $nt"
nznt=`echo "${nz} * ${nt}" | bc`
param="\$BYTORDA"
BYTORDA=`getpar $file $param`
if [ "${BYTORDA}" == "little" ]
then
if [ "${dtype}" == "i" ]
then
swap="-4swap"
else
swap="-2swap"
fi
else
swap=""
fi
# param="ACQ_slice_sepn="
# sl_sepn=`getpar2 $file $param`
# echo "sl_sepn: $sl_sepn"
# param="ACQ_slice_thick="
# sl_thick=`getpar $file $param`
# echo "sl_thick: $sl_thick"
# param="ACQ_slice_sepn_mode="
# sl_mode=`getpar $file $param`
# echo "sl_mode: $sl_mode"
# sl_gap=`echo "scale=2; $sl_sepn - $sl_thick" | bc`
# echo "sl_gap: $sl_gap"
# xstep=`echo "scale=6; $xfov / $nx" | bc`
# ystep=`echo "scale=6; $yfov / $ny" | bc`
# zstep=`echo "scale=6; ( ( $zlength * $sl_sepn ) - $sl_gap ) / $zlength" | bc`
# echo "steps: $xstep $ystep $zstep"
xdir=`echo "scale=2; $xfov/2.0" | bc`
xdir="${xdir}R-L"
ydir=`echo "scale=2; $yfov/2.0" | bc`
ydir="${ydir}S-I"
zdir=`echo "scale=2; $zlength/2.0" | bc`
zdir="${zdir}P-A"
if [ $nt -gt 1 ]
then
timestr="-time:zt $nz $nt 1ms zero"
else
timestr=""
fi
cmd="to3d $timestr -omri ${swap} -prefix $outfile -session $SESSION -view orig -xFOV $xdir -yFOV $ydir -zFOV $zdir"
cmd="${cmd} -skip_outliers 3D${dtype}:0:0:${nx}:${ny}:${nznt}:${RAWFILE}"
echo ""
echo "***> ${cmd} <***"
echo ""
$cmd
if [ -f ${SESSION}/${outfile} ]
then
mv ${SESSION}/${outfile} ${SESSION}/${outfile}.1D
fi
}
# main
#if [ $# -lt 1 -o $# -gt 2 ]
if [ $# -ne 1 ]
then
usage
exit
fi
fqifile=${cwd}/${1}
inputfile=`basename $1`
case $inputfile in
"subject")
smode=1
;;
"2dseq")
smode=0
;;
*)
echo "${usage}"
exit
;;
esac
if [ $smode -eq "1" ]
then
SESSION=`dirname $fqifile`
cd $SESSION
for dir in `/bin/ls -1 $SESSION/`
do
if [ -d $dir ]
then
for reno in `/bin/ls -1 ${SESSION}/${dir}/pdata`
do
RAWFILE="${SESSION}/${dir}/pdata/${reno}/2dseq"
if [ -f $RAWFILE ]
then
p2a $SESSION $RAWFILE
fi
done
fi
done
else
RAWFILE="$fqifile"
reno=`dirname $fqifile`
sno=`dirname $reno`
reno=`basename $reno`
sno=`dirname $sno`
SESSION=`dirname $sno`
if [ -f $RAWFILE ]
then
p2a $SESSION $RAWFILE
fi
fi
cd $cwd
exit
reno=`dirname $RAWFILE`
sno=`dirname $reno`
reno=`basename $reno`
sno=`dirname $sno`
SESSION=`dirname $sno`
bname=`basename $SESSION`
sno=`basename $sno`
outfile="${bname}.${sno}.${reno}"
echo "$RAWFILE -> $SESSION : $outfile"
reno=`dirname $fqifile`
sno=`dirname $reno`
reno=`basename $reno`
sno=`dirname $sno`
SESSION=`dirname $sno`
bname=`basename $SESSION`
sno=`basename $sno`
cd $SESSION
outfile="${bname}.${sno}.${reno}"
echo "$RAWFILE -> $SESSION : $outfile"