annotate aim-mat/tools/reversecorrelate.m @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 20ada0af3d7d
children
rev   line source
tomwalters@0 1 % support file for 'aim-mat'
tomwalters@0 2 %
tomwalters@0 3 % This external file is included as part of the 'aim-mat' distribution package
bleeck@3 4 % (c) 2011, University of Southampton
bleeck@3 5 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 6 % download of current version is on the soundsoftware site:
bleeck@3 7 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 8 % documentation and everything is on http://www.acousticscale.org
bleeck@3 9
tomwalters@0 10
tomwalters@0 11 function sig=reversecorrelate(a,st,von,bis)
tomwalters@0 12 % signal muss ein Signal sein
tomwalters@0 13 % st muss ein Spiketrain sein
tomwalters@0 14 % das Ergebnissignal hat die Länge bis-von
tomwalters@0 15
tomwalters@0 16 if ~isobject(a)
tomwalters@0 17 disp('error: Signal must be an Object signal')
tomwalters@0 18 end
tomwalters@0 19
tomwalters@0 20 if nargin < 4
tomwalters@0 21 bis=0.01; %standart: 10 ms nach 0
tomwalters@0 22 end
tomwalters@0 23
tomwalters@0 24 if nargin < 3
tomwalters@0 25 von=-0.05; %standart: 50 ms vor 0
tomwalters@0 26 end
tomwalters@0 27
tomwalters@0 28
tomwalters@0 29 duration=bis-von; % so lang ist das ErgebnisSignal
tomwalters@0 30 sr=getsr(a);
tomwalters@0 31 sig=signal(duration,sr); %mache ein neues Signal
tomwalters@0 32 nrpoints=getnrpoints(sig);
tomwalters@0 33
tomwalters@0 34 nr_spikes=length(st);
tomwalters@0 35 orglen=GetLength(a);
tomwalters@0 36
tomwalters@0 37 for i=1:nr_spikes
tomwalters@0 38 spiketime=st(i);
tomwalters@0 39 start=spiketime+von;
tomwalters@0 40 stop=spiketime+bis;
tomwalters@0 41 off=0;
tomwalters@0 42 if start<0
tomwalters@0 43 off=-start;
tomwalters@0 44 start=0;
tomwalters@0 45 end
tomwalters@0 46 if stop>orglen-1/sr
tomwalters@0 47 stop=orglen-1/sr;
tomwalters@0 48 end
tomwalters@0 49 temp=getpart(a,start,stop);
tomwalters@0 50 sig=add(sig,temp,off);
tomwalters@0 51 end
tomwalters@0 52
tomwalters@0 53 sig=getpart(sig,0,duration);
tomwalters@0 54 sig=setstarttime(sig,von);