#!/bin/sh
# tacac   May 14/98
# This script runs the analysis program to perform  trace averages 
# based on the normalized locomotor activty in a waveform. 
# The average of frames occurring during the active period of a waveform 
# is created and saved. The average calculated during the inactive period is 
# appended to this file. QM is used to subtract the two frames and show 
# the difference. 

# In this version, the trace average obtained during the inactive 
# phase of the waveform is subtracted from that obtained during waveform 
# activity.

#USAGE: 
# 1. use analysis to set the analysis range and cycles in a waveform, 
# 2. choose this waveform for cycle selection (SCW),
# 3. set cycles in-phase delay and window
# 4. exit analysis saving the modified parameters.
# 5. run this script, eg. tacac mydata newdata bins_acive bins_inactive

if [ $# -ne 5 ]
then
echo "Usage: $0 runfile avgfile bins_active_phase bins_inactive_phase delay" >&2
exit 1
fi

analysis $1 <<!
sab$3
qqscsntnp100
qqatcgb$2ac
 Bins active=$3, Bins inactive=$4
ppscsyqqsab$4
qqatcgb$2in

ppqy

!
echo "y" | appendrun $2ac $2in
renamerun $2ac $2a$5
renamerun $2in $2i$5
qm $2a$5 <<!
t0
rcXA1
rcXA2
rcXA3
rcXA4
rcXA5
rcXA6
smt0
1
qm
pf$2a$5
q
!
qm $2a$5

	



