'This script finds EPSPs according to triggers and measures time and amplitude of EPSPs 'it also measures stimulus amplitude var curs1,curs2,curs3,kanal,janein$,datachan%,MemChan%,evint,test1,test2,spike,delay1,delay2,amplitude; var trigmem%:=-1, trigamp,stimchan; janein$:="yes"; ToolbarClear();'Creates Toolbar ToolbarSet(1, "trigger", trigger%); ToolbarSet(2, "EPSPs", find%); ToolbarSet(3, "Stop", stop%); repeat Toolbar("",1023); until 0; Halt; func find%() 'select EPSP channel, triggerchannel and stimuluschannel DlgCreate("Set EPSP Channel"); DlgChan(1,"Select EPSP data channel",1); Dlgchan(2,"Triggerchannel?",2); Dlgchan(3,"Stimulus channel?",1); DlgShow(Kanal,trigmem%,stimchan); 'Make new cursors Cursordelete(-1); CursorNew(); cursor(1,0+0.01); CursorNew(); Cursornew(); delay1:=0.05; delay2:=0.1; 'Loop to find PSP janein$:="yes"; while janein$="yes" do spike:=nexttime(trigmem%,Cursor(1));'find next trigger Cursor(1,spike);'set cursor1 to trigger draw(cursor(1)-0.2,0.5);'move window to trigger trigamp:=chanmeasure(stimchan,8,cursor(1)-0.001, cursor(1)+0.000001);'determine stimulus amplitude Cursor(2,Cursor(1)+delay1);'set cursor2 to next trigger but same position Cursor(3,Cursor(1)+delay2);'set cursor3 to next trigger but same position interact("Set Cursor2 on minimum and cursor3 on maximum",1023);'let user correct cursor curs2:=chanvalue(kanal,Cursor(2));'measure resting potential curs3:=chanmeasure(kanal,8,cursor(3)-0.025,cursor(3)+0.04);'measure maximum potential ' curs3:=chanvalue(kanal,Cursor(3)); amplitude:=curs3-curs2;'calculate amplitude of EPSP Printlog("Stimtime\t",cursor(1),"\t","time on min\t",Cursor(2),"\t","minimum potential\t",curs2,"\t","timeon max\t",Cursor(3),"\t","maximum potential\t",curs3,"\t","amplitude\t",Amplitude,"\t","triggeramplitude\t",trigamp); janein$:=input$("again?","yes");'ask to continue delay1:=Cursor(2)-Cursor(1);'calculate new position of the cursors delay2:=Cursor(3)-Cursor(1); wend ; end; func trigger%() 'this script is an enhanced version for finding spike events in a waveform channel. It uses a threshold, but after that looks for the maximum of the spike and uses this 'as the event time '--------------------------------------- 'select data channel from which trigger will be get var dataChan%,evint,test1,test2,risefall; evint:=0.008; 'minimum interval from one spike to next (8ms); evint:=evint*1000; 'to have minimum interval im ms 'select data channel from which trigger will be get DlgCreate("Set Trigger Channel"); DlgChan(1,"Select waveform data channel",1); Dlgreal(2,"Minimum delay to next triggerpoint in ms?",0,5000); Dlglist(3,"rising or falling waveform?","rising|falling"); DlgShow(dataChan%,evint,risefall); 'evint:=Input("Minimum delay to next triggerpoint in ms?", evint, 0, 5000); evint:=evint/1000; 'to get it back to sec trigmem%:=MemChan(3,0); 'make trigchannel CursorDelete(-1); 'delete all Cursors CursorNew(XLow()+1); 'make new cursor at left window edge + 1 sec CursorNew(Xhigh()-1); 'make new cursor at right window edge - 1 sec Interact("Place the cursors around the region to be analysed...", 1023); 'select range CursorRenumber(); 'renumbered cursor -> left cursor becomes cursor 1 HCursorDelete(1);HCursorNew(dataChan%); 'make new horizontal cursor Interact("place Hcursor", 1023); var newmem,firstnewmem,pre,post,countit,mini,maxi,minitime,maxitime; 'define a couple of new variable newmem:=MemChan(2); 'make new memchannel 'we will not show this channel. It is just temporary if risefall=0 then MemImport(newmem, dataChan%, Cursor(1), Cursor(2), 2, evint, HCursor(1)); 'write all spike / artifact events to memchannel, rising waveforn else MemImport(newmem, dataChan%, Cursor(1), Cursor(2), 3, evint, HCursor(1)); 'write all spike / artifact events to memchannel, falling waveform endif; test1:=Cursor(1); '2 variable which remember the cursor times test2:=Cursor(2); 'now lets find the maximum of each spike / artifact and make new memory channel firstnewmem:=nexttime(newmem,0); 'find first spike / artifact event CursorNew(); 'make new cursor draw(firstnewmem-0.02,0.04); 'draw window around first event 'place cursors around first spike/artifact Cursor(1,firstnewmem-0.01); Cursor(2,firstnewmem); Cursor(3,firstnewmem+0.01); interact("set Cursor1 to start of spike/artifact Cursor2 to maximum/minimum and Cursor3 to end",1023); 'let user set the beginning, maximum and end of spike/artifact pre:=Cursor(2)-Cursor(1); 'pre has the time between beginning and maximum of spike/artifact post:=Cursor(3)-Cursor(2); 'post has the time between maximum and end of spike/artifact countit:=firstnewmem; ' now walk along the memchannel with the spike events and find maxima While countit>=0 do minmax(dataChan%,countit-pre,countit+post,mini,maxi,minitime,maxitime); 'maxitime hat zeit des maximums if risefall=0 then Memsetitem(trigmem%, 0, maxitime); 'schreib in Memchan, rising waveforn else Memsetitem(trigmem%, 0, minitime); 'schreib in Memchan, falling waveforn endif; countit:=nexttime(newmem,countit); wend; Chandelete(newmem,0); 'delete the temporary memory channel chantitle$(trigmem%,"trigger"); 'give it a name Chanshow(trigmem%); ' and show the trigger channel Draw(test1,test2-test1); 'draw the selected range return; end; func stop%() halt; end;