bleeck@3: % 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 tomwalters@0: function str=getchange(sig,start1,stop1,start2,stop2,grafix) tomwalters@0: % returns some information how the signal changes in the time at start1 and tomwalters@0: % stop1 in reference to start2 and stop2 tomwalters@0: % this is used to define onset and offset effects of psths tomwalters@0: % sig=signal tomwalters@0: % start1= start of the part of the signal that has the effect tomwalters@0: % stop1= stop of the part of the signal that has the effect tomwalters@0: % start2= start of the part of the signal that is used as reference tomwalters@0: % stop2= stop of the part of the signal that is used as reference tomwalters@0: tomwalters@0: if nargin<6 tomwalters@0: grafix=0; tomwalters@0: end tomwalters@0: tomwalters@0: referencesig=getpart(sig,start2,stop2); tomwalters@0: meanreference=mean(getvalues(referencesig)); tomwalters@0: % variability=std(getvalues(referencesig)); tomwalters@0: tomwalters@0: searchsig=getpart(sig,start1,stop1); tomwalters@0: meansearchsig=mean(getvalues(searchsig)); tomwalters@0: tomwalters@0: if meanreference~=0 tomwalters@0: str.ampeffect=meansearchsig/meanreference; tomwalters@0: else tomwalters@0: str.ampeffect=0; tomwalters@0: end tomwalters@0: tomwalters@0: str.ampeffectstr=getsignificantstring(getvalues(searchsig),meanreference); tomwalters@0: tomwalters@0: if grafix==1 tomwalters@0: % oldgraph=gcf; tomwalters@0: % figure(234234098) tomwalters@0: % clf tomwalters@0: hold on tomwalters@0: % set(gcf,'num','off') tomwalters@0: % set(gcf,'name','changes in signal'); tomwalters@0: fill(sig,'b'); tomwalters@0: fill(referencesig,'r') tomwalters@0: fill(searchsig,'g') tomwalters@0: tomwalters@0: tomwalters@0: x0=getminimumtime(sig)*1000; tomwalters@0: x1=getmaximumtime(sig)*1000; tomwalters@0: line([x0 x1],[meanreference meanreference],'color','r') tomwalters@0: line([x0 x1],[meansearchsig meansearchsig],'color','g') tomwalters@0: set(gca,'xlim',[x0 x1]); tomwalters@0: % set(gca,'ylim',[0 max(sig)*1.3]); tomwalters@0: set(gca,'ylim',[min(0,min(sig)*1.3) max(sig)*1.3]); tomwalters@0: x=(getmaximumtime(sig)*1000-getminimumtime(sig)*1000)/2; tomwalters@0: x=(stop1*1000-start1*1000)/2; tomwalters@0: y=max(sig); tomwalters@0: text(x,y,sprintf('effect: %3.2f (%s)',str.ampeffect*100,str.ampeffectstr),'vert','botto','hor','left') tomwalters@0: legend('Signal','reference','interesting bit'); tomwalters@0: % text(x,y,,'vert','top','hor','left') tomwalters@0: % figure(oldgraph); tomwalters@0: end tomwalters@0: tomwalters@0: function sigstr=getsignificantstring(vals1,meanvals) tomwalters@0: cv=ver('stats'); tomwalters@0: if length(cv)==0 tomwalters@0: sigstr='no stats box'; tomwalters@0: return tomwalters@0: end tomwalters@0: if sum(vals1)>0 tomwalters@0: if ttest(vals1,meanvals,0.001,1) tomwalters@0: sigstr='*** more'; tomwalters@0: elseif ttest(vals1,meanvals,0.01,1) tomwalters@0: sigstr='** more'; tomwalters@0: elseif ttest(vals1,meanvals,0.05,1) tomwalters@0: sigstr='* more'; tomwalters@0: elseif ttest(vals1,meanvals,0.001,-1) tomwalters@0: sigstr='*** less'; tomwalters@0: elseif ttest(vals1,meanvals,0.01,-1) tomwalters@0: sigstr='** less'; tomwalters@0: elseif ttest(vals1,meanvals,0.05,-1) tomwalters@0: sigstr='* less'; tomwalters@0: else tomwalters@0: sigstr='not significant'; tomwalters@0: end tomwalters@0: else tomwalters@0: sigstr='cant determine'; tomwalters@0: end