bleeck@3
|
1 % This external file is included as part of the 'aim-mat' distribution package
|
bleeck@3
|
2 % (c) 2011, University of Southampton
|
bleeck@3
|
3 % Maintained by Stefan Bleeck (bleeck@gmail.com)
|
bleeck@3
|
4 % download of current version is on the soundsoftware site:
|
bleeck@3
|
5 % http://code.soundsoftware.ac.uk/projects/aimmat
|
bleeck@3
|
6 % documentation and everything is on http://www.acousticscale.org
|
tomwalters@0
|
7 function str=getchange(sig,start1,stop1,start2,stop2,grafix)
|
tomwalters@0
|
8 % returns some information how the signal changes in the time at start1 and
|
tomwalters@0
|
9 % stop1 in reference to start2 and stop2
|
tomwalters@0
|
10 % this is used to define onset and offset effects of psths
|
tomwalters@0
|
11 % sig=signal
|
tomwalters@0
|
12 % start1= start of the part of the signal that has the effect
|
tomwalters@0
|
13 % stop1= stop of the part of the signal that has the effect
|
tomwalters@0
|
14 % start2= start of the part of the signal that is used as reference
|
tomwalters@0
|
15 % stop2= stop of the part of the signal that is used as reference
|
tomwalters@0
|
16
|
tomwalters@0
|
17 if nargin<6
|
tomwalters@0
|
18 grafix=0;
|
tomwalters@0
|
19 end
|
tomwalters@0
|
20
|
tomwalters@0
|
21 referencesig=getpart(sig,start2,stop2);
|
tomwalters@0
|
22 meanreference=mean(getvalues(referencesig));
|
tomwalters@0
|
23 % variability=std(getvalues(referencesig));
|
tomwalters@0
|
24
|
tomwalters@0
|
25 searchsig=getpart(sig,start1,stop1);
|
tomwalters@0
|
26 meansearchsig=mean(getvalues(searchsig));
|
tomwalters@0
|
27
|
tomwalters@0
|
28 if meanreference~=0
|
tomwalters@0
|
29 str.ampeffect=meansearchsig/meanreference;
|
tomwalters@0
|
30 else
|
tomwalters@0
|
31 str.ampeffect=0;
|
tomwalters@0
|
32 end
|
tomwalters@0
|
33
|
tomwalters@0
|
34 str.ampeffectstr=getsignificantstring(getvalues(searchsig),meanreference);
|
tomwalters@0
|
35
|
tomwalters@0
|
36 if grafix==1
|
tomwalters@0
|
37 % oldgraph=gcf;
|
tomwalters@0
|
38 % figure(234234098)
|
tomwalters@0
|
39 % clf
|
tomwalters@0
|
40 hold on
|
tomwalters@0
|
41 % set(gcf,'num','off')
|
tomwalters@0
|
42 % set(gcf,'name','changes in signal');
|
tomwalters@0
|
43 fill(sig,'b');
|
tomwalters@0
|
44 fill(referencesig,'r')
|
tomwalters@0
|
45 fill(searchsig,'g')
|
tomwalters@0
|
46
|
tomwalters@0
|
47
|
tomwalters@0
|
48 x0=getminimumtime(sig)*1000;
|
tomwalters@0
|
49 x1=getmaximumtime(sig)*1000;
|
tomwalters@0
|
50 line([x0 x1],[meanreference meanreference],'color','r')
|
tomwalters@0
|
51 line([x0 x1],[meansearchsig meansearchsig],'color','g')
|
tomwalters@0
|
52 set(gca,'xlim',[x0 x1]);
|
tomwalters@0
|
53 % set(gca,'ylim',[0 max(sig)*1.3]);
|
tomwalters@0
|
54 set(gca,'ylim',[min(0,min(sig)*1.3) max(sig)*1.3]);
|
tomwalters@0
|
55 x=(getmaximumtime(sig)*1000-getminimumtime(sig)*1000)/2;
|
tomwalters@0
|
56 x=(stop1*1000-start1*1000)/2;
|
tomwalters@0
|
57 y=max(sig);
|
tomwalters@0
|
58 text(x,y,sprintf('effect: %3.2f (%s)',str.ampeffect*100,str.ampeffectstr),'vert','botto','hor','left')
|
tomwalters@0
|
59 legend('Signal','reference','interesting bit');
|
tomwalters@0
|
60 % text(x,y,,'vert','top','hor','left')
|
tomwalters@0
|
61 % figure(oldgraph);
|
tomwalters@0
|
62 end
|
tomwalters@0
|
63
|
tomwalters@0
|
64 function sigstr=getsignificantstring(vals1,meanvals)
|
tomwalters@0
|
65 cv=ver('stats');
|
tomwalters@0
|
66 if length(cv)==0
|
tomwalters@0
|
67 sigstr='no stats box';
|
tomwalters@0
|
68 return
|
tomwalters@0
|
69 end
|
tomwalters@0
|
70 if sum(vals1)>0
|
tomwalters@0
|
71 if ttest(vals1,meanvals,0.001,1)
|
tomwalters@0
|
72 sigstr='*** more';
|
tomwalters@0
|
73 elseif ttest(vals1,meanvals,0.01,1)
|
tomwalters@0
|
74 sigstr='** more';
|
tomwalters@0
|
75 elseif ttest(vals1,meanvals,0.05,1)
|
tomwalters@0
|
76 sigstr='* more';
|
tomwalters@0
|
77 elseif ttest(vals1,meanvals,0.001,-1)
|
tomwalters@0
|
78 sigstr='*** less';
|
tomwalters@0
|
79 elseif ttest(vals1,meanvals,0.01,-1)
|
tomwalters@0
|
80 sigstr='** less';
|
tomwalters@0
|
81 elseif ttest(vals1,meanvals,0.05,-1)
|
tomwalters@0
|
82 sigstr='* less';
|
tomwalters@0
|
83 else
|
tomwalters@0
|
84 sigstr='not significant';
|
tomwalters@0
|
85 end
|
tomwalters@0
|
86 else
|
tomwalters@0
|
87 sigstr='cant determine';
|
tomwalters@0
|
88 end
|