' this script finds the spikes of the same neuron on 2 different recordings, e.g. ' 2 recordings of the same nerve. It looks for the time delay from a spike ' on one recording to the spike on the 2nd recording. It uses the fact, ' that neurons have different conduction velocities in a nerv. ' ****************** ' The script needs you to make 2 event channels from the two recordings ' and from those 2 event channels you need to generate an event correlation ' result view which tells you the time delays of the different units in you recording. var a,b,c,d,e,f,g,h,i,x,list%[100]; var chan1,chan2, views$; var c1,c2,c3; var range1,range2,allow1,allow2,nachricht$; var trigchan,lookchan,memo,fiu,fiu2; chan1:=13; chan2:=14; fiu:=View(); 'get current view interact("go to the event correlation window",1023); 'find the result window view (max 100 windows) Viewlist(list%[],16); 'get views for all result windows, list%[0] contains number of result windows if list%[0] > 1 then 'if more than 1 result window for i:= 1 to list%[0] do views$:=views$+STR$(list%[i]); views$:=views$+" , "; next; views$:="there are more than one result views with the following viewhandles: "+views$; message(views$); fiu2:=input("please tell me the correct view handle",0); endif; if list%[0] < 1 then 'if no result window message("there are no result windows - I am using the main window! DOES NOT WORK"); fiu2:=fiu; 'we need a reference cursor in the main window for measuring the time difference endif; if list%[0] = 1 then 'if exactly one result window fiu2:=list%[1]; endif; Frontview(fiu2); 'bring result window to front CursorDelete(-1); 'and delete all cursors, then make new cursors CursorNew(); interact("place Cursor 1 on maximum of the desired spike count",1023); CursorNew(); CursorNew(); interact("place Cursor 2 (left) and 3 (right) on maximum borders of the desired spike count",1023); c1:=Cursor(1); c2:=Cursor(2); c3:=Cursor(3); if list%[0] > 0 then 'if result window with bins is used we have to convert bins to seconds c1:=bintox(c1); c2:=bintox(c2); c3:=bintox(c3); endif; range1:=c1-c2; 'holds the left time range range2:=c3-c1; 'holds the right time range 'c1 holds the time shift of the spike 'now go back to the main window to search for spikes interact("go back to the data window",1023); Frontview(fiu); 'interact("go to the data window",1023); trigchan:=input("which channel holds the trigger spikes?",14); lookchan:=input("which channel to look for correlated spikes?",13); Cursordelete(-1); CursorNew(); CursorNew(); interact("place Cursors around area to analyze",1023); 'create memchan memo:=memchan(2,0); Chanshow(memo); x:=0; a:=Cursor(1); 'set a to Cursor(1) 'now search for spikes that match the criteria repeat a:=nexttime(trigchan,a); 'a contains the next spike on trigchan Cursor(1,a); 'move Cursor1 to spike position allow1:=a+c1-range1; 'the spike must be later than allow1 to match criteria allow2:=a+c1+range2; 'the spike must be earlier than allow2 to match criteria b:=nexttime(lookchan,allow1); 'b contains the first spike in lookchan that is possibly associated with spike in trigchan 'check whether this spike is in the allowed range if b>allow1 and b Cursor(2); 'repeat until Cursor 1 is bigger than Cursor 2 'inform user about results nachricht$:="there were "+STR$(x)+" spikes found."; 'write comment to channel Chancomment$(memo,nachricht$); Chantitle$(memo,"spikes"); ' and tell user nachricht$:=nachricht$+" This was copied to the comment of the memory channel"; message(nachricht$);