' this littel program lets you copy a part of a waveform channel from one file to another ' USE CHANSAVE NEXT TIME IT COMES WITH AN OPTION FOR SAVING TO DIFFERENT FILE windowvisible (3); var n,memochan,binSz,waveSize%,eTime, sTime,waveChan%,nTime,skale,offset,comparechan,letzterwert, Differenzwert; waveChan%:=input("what channel",2); 'the channel to read from 'interact("Cursor1 links und Cursor2 rechts von auzuschneidenden Datenteil positionieren",1023); sTime:=0;'Cursor(1); 'set start time eTime:=maxtime();'Cursor(2); 'set end time binSz:=Binsize(waveChan%); 'get Binsize of datachannel skale:=ChanScale(wavechan%); offset:=Chanoffset(wavechan%); waveSize%:=Trunc((eTime-sTime)/binSz)+1; 'calculate size of array 'skale:=100; copyn(); 'call copy function halt; func copyn() 'copy function var waveData[waveSize%]; 'create array var anzahl, zaehl, resFile%, ok%, Differenz; anzahl:=Chandata(waveChan%,waveData[],stime,etime); 'and copy data in it 'interact("neues File in den Vordergrund bringen!!!!",1023); 'change file by bringing them to foreground resFile%:=FileOpen("",0,0); ' Open result file View(resFile%); WindowVisible(1); 'memochan:=input("neuen Memorykanal anlegen (0) oder in bestehenden Kanal schreiben (Nummer angeben)?",0); memochan:=0; if memochan=0 then 'make memorychannel if necessary memochan:=MemChan(1,0,binsz); chanscale(memochan,skale); ChanOffset(memochan,offset); Chanshow(memochan); endif; Interact("bring Cursor1 to time for inserting data",1023); nTime:=Cursor(1); 'Cursor gives the new start time 'nTime:=0; 'hier waren 100 'Differenz:=waveData[0]-nTime; 'Chanwritewave(memochan,waveData[],nTime); 'write data to memory channel 'for zaehl:=0 to anzahl do 'MemSetItem(401,0,waveData[zaehl]-Differenz); 'THE following is to prevent the provblem that spike2 starts the Bins of a waveform channel at thepositionof the first datavalue ' and then copying different channels into one will cause a time shift when bin-starts dont match perfectly comparechan:=input("is there a reference channel that has the same binsize? (0 for no)",0); if comparechan=0 then 'do nothing else letzterwert:=nextTime(comparechan,0); Differenzwert:=Cursor(1)-letzterwert; 'difference Differenzwert:=Differenzwert/binsz; ' in "how many bins" Differenzwert:=Trunc(Differenzwert); ' get integer of binnumber Differenzwert:=Differenzwert*binsz; ' in sec Cursor(1,letzterwert+Differenzwert);'place cursor at exact multiple of Binsize ntime:=Cursor(1); endif; MemSetItem(memochan,0,ntime,waveData[]); ' next; return; end;