
if test $# != 4
then
   echo "Create a 2D Synthetic Image Series;"
   echo "  K-Matrix analysis of each pixel and selected reference spectra."
   echo "Usage:"
   echo "  imKMatrix.ksh imageTemplate refRootName refCount outTemplate"
   echo "Example:"
   echo "  imKMatrix.ksh tpo_2800/ir%03d.dat class 3 tpo_2800_kmat/ir%03d.dat"
   echo "  (Assumes 1D references class001.dat class002.dat etc)"
   echo " "
   echo "  imClassify tpo_2800_kmat/* summary.dat"
   exit 0
fi

namep=$(printf $1 1)

xyz2pipe -in $1 -z \
| nmrPipe -fn MAC -macro $NMRTXT/imKMatrixRel.M -noWr -outHdr None -verb \
          -str refName $2%03.0f.dat planeName $namep -var refCount $3    \
| nmrPipe -fn IMG -median                                                \
| pipe2xyz -out $4 -x -ov

sleep 10
