var eventCh11%, eventCh12%, eventCh1%, inputch1%, stime, etime, mindelay1, setCutOff1, SetCutOff11,updown; var updownquery,ok%,dummy1,dummy2,mintime,maxitime; WindowVisible (3); 'sets the time view to the front ToolbarSet (2, "Windowdiscriminator",discriminate%); ToolbarSet (1,"Exit",abort%); 'quit (and close data file) button ToolbarEnable (-1,1); 'dim (disable) Write button to begin with Toolbar("Select option...",1023); 'activate toolbar and pop up message '''Note: the script does not continue beyond the toolbar code unless one of ' the procedures (functions) that are called returns the value 0. All ' functions return a 1 except the abort function. Halt; 'stop script NB. all following code is in procedures/functions 'that are called from the toolbar func abort%(); HALT; end; func discriminate%(); DlgCreate("windowdiscriminator"); DlgList(1,"Choose","FALLING|RISING"); DlgChan(2, "What channel?",1+16); ok% := DlgShow(updown, inputch1%); if not ok% then return 1; endif; if CursorExists(1)=0 then CursorNew(); endif; if CursorExists(2)=0 then CursorNew(); endif; CursorLabel(3,-1); 'updown:=Query("rising or falling waveforms", "rising", "falling"); ' if updown=1 rising if updown=1 then rising(); endif; if updown=0 then 'falling waveform falling(); endif; End; func rising(); 'inputCh1%:=input("what channel do you want to analyze?",2,0,5000); interact("set Cursors around region to analyze",1023); sTime:=Cursor(1); eTime:=Cursor(2); if stime=0 then stime:=stime+0.0001; endif; if HCursorExists(1)=0 then HCursorNew(inputch1%); endif; HCursorLabel(3,-1); interact("set horizontal Cursor1. Alle events ABOVE will be counted!",1023); if HCursorExists(2)=0 then HCursorNew(inputch1%); endif; HCursorLabel(3,-1); interact("set horizontal Cursor2. Alle events BELOW will be counted!",1023); setCutoff1:=HCursor(1); setCutOff11:=HCursor(2); 'get minimum delay from one spike to another mindelay1 := Input("minimum delay from one spike to another in sec?", 0.005, 0, 5000); 'mindelay1:=mindelay1/1000; eventCh11% := MemChan(2); MemImport(eventCh11%, inputCh1%, sTime, eTime, 2, mindelay1, setCutOff1); eventCh12% := MemChan(2); MemImport(eventCh12%, inputCh1%, sTime, eTime, 3, 0.0005, setCutOff1); 'minimum delay set to 0,5ms since all rising waveforms MUST be followed by a falling eventCh1% := MemChan(2); '########################## 'WOLFIE'S CHUNK OF CODE (I TRANSLATED THE CODE COMMENTS INTO ENGLISH) 'THIS NIFTY CHUNK OF CODE WORKS AS FOLLOWS: ' 1. IT RECORDS EVENTS THAT CROSS THE TWO HORIZONTAL CURSORS (FOR NEURON 1, THEY'RE "setCutOff1" and "setCutOff6") ' 2. IT RECORDS THE RISING TIME (from eventCh6% and called "punkt1a") AND FALLING TIME (from eventCh7% and called "punkt1b") FOR EVENTS THAT CROSS THE FIRST HORIZONTAL CURSOR ("setCutOff1") ' 3. IT MEASURES THE PEAK VOLTAGE BETWEEN THE RISING TIME AND THE FALLING TIME FOR THOSE RECORDED IN #2 AND RECORDS IT ' 4. IT THEN ASKS IF THE PEAK VOLTAGE FROM #3 IS LOWER THAN THE 2ND HORIZONTAL CURSOR ("setCutOff6")...IF SO, IT RECORDS IT AS AN EVENT (eventCh1%) var punkt1a; 'variable defining the rising time of the spike var punkt1b; 'variable defining the falling time of the spike var peakamp1; ' variable defining the peak voltage of the spike punkt1a:=sTime; while punkt1a>0 do punkt1a:=nexttime(eventCh11%,punkt1a); 'rising time of spike punkt1b:=nexttime(eventCh12%,punkt1a); 'falling time of spike if punkt1a>0 then MinMax(inputch1%,punkt1a,punkt1b,dummy1,peakamp1, mintime,maxitime); ' peakamp1:=ChanMeasure(inputCh1%,8,punkt1a,punkt1b); 'amplitude of spike endif; if peakamp10 do punkt1a:=nexttime(eventCh11%,punkt1a); 'falling time of spike punkt1b:=nexttime(eventCh12%,punkt1a); 'rising time of spike if punkt1a>0 then MinMax(inputch1%,punkt1a,punkt1b,peakamp1,dummy1,mintime,maxitime); 'peakamp1:=ChanMeasure(inputCh1%,9,punkt1a,punkt1b); 'minimum (amplitude) of spike endif; if peakamp1>setCutOff11 then 'look for time of AP peak and write to channel MemSetItem(eventCh1%,0,mintime); 'MemImport(eventCh1%, inputCh1%, punkt1a, punkt1b, 0, 0, 0); 'finds the time for the peak voltage 'BESSER: MINMAX!!! endif; wend; ChanShow(eventCh1%); end;