var a,b,c,d,e,f,g,h,i,j,yes,k; var trigmem%,evint,l,m,n,o,p,curs3,vh%; 'this program finds peaks and troughs in a waveform channel, resolution either 1ms maximum binsize ' it does so by either using searching reversal points in the waveform channel (according to a change in the sign of the slope) ' or by using a trigger channel (e.g. stimulus artifacts or separate stimulus channel). With stimulus channel, ' a time can be set by which the maximum or minimum is allowed to vary and within this time the maximum/minimum is searched. ' ' CUrsor 3 moves along the time axis ' b=value of waveform channel ' c=valueof waveform channel , both are compared to find either positive or negative slope ' d=starting time (Cursor 1) ' e=determines whether to look for Peak or trough. ALWAYS START WITH PEAK!! ' f= Channelnumber ' g=Channelvalue Cursor 3 (Peak or trough) ' h=Endtime (Cursor 2) ' i=delay after each Peak/trough in which is NOT measured. ' j=increment for measurement (resolution) ' trigmem%=trigger channek if available ' evint = minimum delay between trigger events ' l=Cursor1 position temporarily ' m,n,o hold cursor positions and then the time delays from stimulus to start / end of EPSP ' p=max. time variance in which peak/trough of Vm may occur ' curs3 hold position of cursor3 (peaks and troughs vh%:=View(); 'get view of data file 'clear log window View(LogHandle()); EditSelectAll(); EditClear(); 'bring data file to front again View(vh%); yes:=Query("Look for reversal points or use trigger?", "reversal points", "trigger + min/max search"); ' if yes = 1 then search trace for reversal points if yes=1 then f:=input("channel number which holds peaks and troughs?",2); i:=input("give minimum delay to next search after peak/trough",10); i:=i/1000; j:=input("give stepwidth for search (larger = less accurate)",1); j:=j/1000; Cursordelete(-1); Cursornew(); Cursornew(); Cursornew(); interact("set Cursor1 directly in front of 1. EPSP, Cursor 2 directly behind the peak of the last EPSP",1023); b:=Chanvalue(f,Cursor(1)); 'mV membranpotential Printlog("Baseline_starting_membrane_potential"," ","time: "," ",Cursor(1)," ","mV: "," ",b); h:=Cursor(2); d:=Cursor(1); e:=-1; 'determines whether peak or trough is find at first repeat b:=Chanvalue(f,d); 'mV membranpotential Cursor(3,d); d:=d+j; c:=Chanvalue(f,d); 'mV membranpotential zum vergleich if cb and e>0 then interact("Change Cursor, if necessary",1023); g:=Chanvalue(f,Cursor(3)); 'mV membranpotential Printlog("trough_found"," ","time: "," ",Cursor(3)," ","mV: "," ",g); d:=Cursor(3); e:=-1; d:=d+i; 'increase increment by user defined delay endif; until d>h; endif; ' if yes = 2 then use trigger! if yes=0 then f:=input("number of channel which holds peaks and troughs?",2); k:=input("Trigger channel?",3); 'create memory channel trigmem%:=MemChan(3,0); CursorDelete(-1); 'delete all vertical cursors CursorNew(XLow()+0.3); 'create new vertical cursors CursorNew(Xhigh()-0.3); Interact("Place the cursors around the region to be analysed...", 1023); 'Allow user to set cursors (everything allowed = 1023) CursorRenumber(); 'renumbered cursor -> left cursor becomes cursor 1 HCursorDelete(-1);HCursorNew(k); 'delete all hCursors and create new one Interact("set Hcursor in trigger channel", 1023); ' let user set HCursor in Trigger channel ' get minimum delay to next triggerpoint evint:=10; evint:=Input("Minimum delay to next triggerpoint in msec?", evint, 0, 5000); evint:=evint/1000; ' fill memory channel with trigger events MemImport(trigmem%, k, Cursor(1), Cursor(2), 2, evint, HCursor(1)); 'schreib in Memchan ChanShow(trigmem%); ' get first and last event times: l:=nexttime(trigmem%,0); o:=lasttime(trigmem%,Cursor(2)); 'set Cursor(1) to first stimulus Cursor(1,l); ' let user set Cursor2 to baseline directly in front of first EPSP interact("Set Cursor2 directly in front of 1. EPSP (baseline Vm)",1023); ' make new Cursor and let user set this Cursor to peak of EPSP CursorNew(); interact("set Cursor3 to peak of 1. EPSP",1023); ' get maximum variability in sec. This is the time in which the peak of the EPSP can vary to both sides of the Cursor p:=input("maximum variavility to left and right by which peak is allowed to vary in msec",10); p:=p/1000; 'p holds maximum variability of peak / trough in sec ' get values: k:=Chanvalue(f,Cursor(2)); 'baseline membrane potential m:=Cursor(2)-Cursor(1); 'delay from stim to PSP start (=also to the trough) n:=Cursor(3)-Cursor(1); ' delay from stim to PSP max ' write reference potential to logfile Printlog("Baseline_starting_potential"," ","time: "," ",Cursor(2)," "," V: "," ",k); 'get first peak g:=Chanvalue(f,Cursor(3)); 'g holds the membrane potential of the first peak, Cursor3 the time Printlog("found_Peak"," ","Zeit: "," ",Cursor(3)," ","norm_Zeit: ",Cursor(3)-Cursor(1)," V: "," ",g); ' find other peaks and troughs: repeat ' jump to next stimulus event l:=nexttime(trigmem%,l); Cursor(3,l+m); 'set Cursor to estimated trough ' now look for real trough: curs3:=Chansearch(f,2,Cursor(3)-p,Cursor(3)+p); 'search channel for trough in range of p (variability) around Cursor(3) Cursor(3,curs3); interact("correct Cursor3, if necessary",1023); 'let user correct Cursor if necessary g:=Chanvalue(f,Cursor(3)); 'mV membranpotential trough Printlog("found_trough"," ","time: "," ",Cursor(3)," ","norm_Zeit: ",Cursor(3)-Cursor(1)," V: "," ",g); 'write values to Logfile ' set Cursor to estimated (according to stimulus and time delay) peak Cursor(3,l+n); curs3:=Chansearch(f,1,Cursor(3)-p,Cursor(3)+p); ' search channel for peak in range of p (variability) around Cursor3 Cursor(3,curs3); interact("correct Cursor3, if necessary",1023); 'let user correct Cursor if necessary g:=Chanvalue(f,Cursor(3)); 'mV membranpotential peak Printlog("found_Peak"," ","time: "," ",Cursor(3)," ","norm_Zeit: ",Cursor(3)-Cursor(1)," V: "," ",g); until l=o; 'repeat procedure until last trigger point is reached endif;