#!/bin/tcsh -f
if ("$1" == '' || "$1" == '-h' || "$1" == '-help') then
	goto USAGE
endif

set or = `echo "$1" | cut -c1`
set or = ($or `echo "$1" | cut -c2`)
set or = ($or `echo "$1" | cut -c3`)

set di = ($or)
#echo "$di"
#where is the Right direction?
set cnt = 1
foreach tmp ($or)
   if ($tmp == 'r' || $tmp == 'R') then
      set di[1] = $cnt
   else if ($tmp == 'l' || $tmp == 'L') then
      set di[1] = -$cnt
   endif
   @ cnt ++
end

#where is the Anterior direction?
set cnt = 1
foreach tmp ($or)
   if ($tmp == 'a' || $tmp == 'A') then
      set di[2] = $cnt
   else if ($tmp == 'p' || $tmp == 'P') then
      set di[2] = -$cnt
   endif
   @ cnt ++
end

#where is the Inferior direction?
set cnt = 1
foreach tmp ($or)
   if ($tmp == 'i' || $tmp == 'I') then
      set di[3] = $cnt
   else if ($tmp == 's' || $tmp == 'S') then
      set di[3] = -$cnt
   endif
   @ cnt ++
end


echo $di

goto ENDALL

USAGE:
	echo "Usage: `basename $0` <Orientation code> ....."
	echo "returns the index map fo the RAI directions"
	echo ""
	echo "examples:"
   echo "`basename $0` RAI"
   echo "returns: 1 2 3"
   echo "`basename $0` LSP"
   echo "returns: -1 -3 -2"
	echo ""
   echo "Ziad Saad (ziad@nih.gov)"
   echo "SSCC/NIMH/ National Institutes of Health, Bethesda Maryland"
	goto ENDALL
ENDALL:


syntax highlighted by Code2HTML, v. 0.9.1