Heartprints - A Dynamical Portrait of Cardiac Arrhythmia 1.0.0

File: <base>/src/heartprint (1,574 bytes)
#!/bin/sh
# file: heartprint
#
# Create a heartprint for a given record and annotator
#
# This script creates an RR interval list using ann2rr,
# then pipes it to hp_rrlist to generate the heartprint.

HPOPT=""

while [ $# -gt 0 ]
do
  case $1 in
    -a) ANNOTATOR=$2; shift ;;
    -f) START=$2; shift ;;
    -m) HPOPT="$HPOPT -m $2"; shift ;;
    -M) HPOPT="$HPOPT -M $2"; shift ;;
    -r) RECORD=$2; shift ;;
    -t) END=$2; shift ;; 
    -T) HPOPT="$HPOPT -T $2"; shift ;;
    -*) cat <<EOF
 usage: $0 -r RECORD -a ANNOTATOR [ OPTIONS ... ]
 where RECORD and ANNOTATOR specify the input, and OPTIONS may include:
  -f TIME   start at the specified TIME
  -h        print (this) usage summary
  -m NNmin  discard NN intervals less than NNmin
  -M NNmax  discard NN intervals greater than NNmax
  -t TIME   stop at the specified TIME
  -T FORMAT write to the standard output in the specified FORMAT
            (FORMAT may be eps, pdf, png, or ps;  if the -T option
            is not used, the output will appear on-screen)
EOF
        exit 1 ;;
  esac
  shift
done

echo -n >/tmp/echo.$$
if [ -s echo.$$ ]
then
   P1=""
   P2="\\c"
else
   P1="-n"
   P2=""
fi
rm -f /tmp/echo.$$

if [ x$RECORD = x ]; then
  echo $P1 "Enter the record name: " $P2
  read RECORD
fi

if [ x$ANNOTATOR = x ]; then
  echo $P1 "Enter the annotator name: " $P2
  read ANNOTATOR
fi

if [ x$START = x ]; then
  START=0
fi

if [ x$END = x ]; then
  END=e
fi

rec=`basename $RECORD`
FREQ=`sampfreq $RECORD`

ann2rr -r $RECORD -a $ANNOTATOR -f $START -t $END -c -i s -w |
 hp_rrlist -F $FREQ $HPOPT