# This script is a modification of the "runext" script.  
# It performs a cycle based waveform average on a specific run file.
# This differs from "runext" in that it compares stimulator 1 against 
# stimulator 3.  In order to be used with files with and without frames 
# the user must enter the waveform which contains the Stim Marker 
# in the command line following the run file and average file names.

 if [ $# -ne 3 ]
then
	echo "script for WF average of response to stim 3 vs stim 1" >&2
	echo "Usage: $0 runfile binfile marker_wf" >&2
	exit 1
fi

analysis $1 <<!
w$3
sss1706.54
e0
dmax
tadqqqk
qawcsab1
qqsaw2,3,4,5,6,7,8,9,10,11,12
d-200ms
w500ms
qqqscw$3
qqsctyqqgb$2-stim

w$3
sss307.252
e0
d1816.41
tadqqqk
qawcsab1
qqsaw2,3,4,5,6,7,8,9,10,11,12
d-200ms
w500ms
qqqscw$3
qqsctyqqgb$2-ctrl

!
echo "y" | appendrun $2-stim $2-ctrl
qm $2-stim
