tomwalters@0: % support file for 'aim-mat' tomwalters@0: % tomwalters@0: % This external file is included as part of the 'aim-mat' distribution package bleeck@3: % (c) 2011, University of Southampton bleeck@3: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@3: % download of current version is on the soundsoftware site: bleeck@3: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@3: % documentation and everything is on http://www.acousticscale.org bleeck@3: tomwalters@0: tomwalters@0: function sig=reversecorrelate(a,st,von,bis) tomwalters@0: % signal muss ein Signal sein tomwalters@0: % st muss ein Spiketrain sein tomwalters@0: % das Ergebnissignal hat die Länge bis-von tomwalters@0: tomwalters@0: if ~isobject(a) tomwalters@0: disp('error: Signal must be an Object signal') tomwalters@0: end tomwalters@0: tomwalters@0: if nargin < 4 tomwalters@0: bis=0.01; %standart: 10 ms nach 0 tomwalters@0: end tomwalters@0: tomwalters@0: if nargin < 3 tomwalters@0: von=-0.05; %standart: 50 ms vor 0 tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: duration=bis-von; % so lang ist das ErgebnisSignal tomwalters@0: sr=getsr(a); tomwalters@0: sig=signal(duration,sr); %mache ein neues Signal tomwalters@0: nrpoints=getnrpoints(sig); tomwalters@0: tomwalters@0: nr_spikes=length(st); tomwalters@0: orglen=GetLength(a); tomwalters@0: tomwalters@0: for i=1:nr_spikes tomwalters@0: spiketime=st(i); tomwalters@0: start=spiketime+von; tomwalters@0: stop=spiketime+bis; tomwalters@0: off=0; tomwalters@0: if start<0 tomwalters@0: off=-start; tomwalters@0: start=0; tomwalters@0: end tomwalters@0: if stop>orglen-1/sr tomwalters@0: stop=orglen-1/sr; tomwalters@0: end tomwalters@0: temp=getpart(a,start,stop); tomwalters@0: sig=add(sig,temp,off); tomwalters@0: end tomwalters@0: tomwalters@0: sig=getpart(sig,0,duration); tomwalters@0: sig=setstarttime(sig,von);