-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCohCB.m
More file actions
120 lines (117 loc) · 3.11 KB
/
Copy pathCohCB.m
File metadata and controls
120 lines (117 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
if(UpdateCohPlot)
action = 'CohPlot';
tmpfig = gcf;
ii = TSfigInd(tmpfig.Number);
if length(TSc) >= ii
if ~isempty(TSc{ii})
h = findobj;
if(isempty(find(TSc{ii}.hAx==h)))
UpdateCohPlot = 0;
return
else
nOut = sum(TSc{ii}.CohInd(:,1));
nIn = sum(TSc{ii}.CohInd(:,2));
if(nOut == 0 | nIn == 0)
UpdateCohPlot = 0;
return
end
end
else
return
end
else
return
end
else
action = get(gcbo,'Tag');
ii = get(gcf,'UserData');
h = gcbo;
end
switch action
case 'CohCheckBox'
kk = get(h,'Value');
kl = get(h,'UserData');
k = kl(1); l = kl(2);
if kk==1
for j=1:3
TSc{ii}.CohInd(l,j) = 0;
ud = [ j l];
set(findobj('Tag','CohCheckBox','UserData',ud),'Value',0);
end
TSc{ii}.CohInd(l,k) = 1;
set(h,'Value',1);
else
TSc{ii}.CohInd(l,k) = 0;
end
case 'CohPlot'
FullTS = get(findobj('Tag','FullTS','Parent',TSc{ii}.hFig),'value');
in = find(TSc{ii}.CohInd(:,2));
out = find(TSc{ii}.CohInd(:,1));
given = find(TSc{ii}.CohInd(:,3));
inCh = [TSd{ii}.ch_id(in,:) TSd{ii}.sta(in,:)];
outCh = [ TSd{ii}.ch_id(out,:) TSd{ii}.sta(out,:)];
ctitle1 = ['R^2 : Input Channels: '];
ctitle2 = [];
if(length(in) <=2)
for k = 1:length(in);
ctitle1 = [ ctitle1 inCh(k,:) ';'];
end
else
for k = 1:2;
ctitle1 = [ ctitle1 inCh(k,:) ';'];
end
for k = 3:length(in);
ctitle2 = [ ctitle2 inCh(k,:) ';'];
end
end
if (~isempty(given))
giveCh = [ TSd{ii}.ch_id(given,:) TSd{ii}.sta(given,:)];
ctitle3 = ['Given channels:'];
for k = 1:length(given)
ctitle3 = [ctitle3 giveCh(k,:) ';'];
end
if(isempty(ctitle2))
ctitle = {ctitle1 ctitle3};
else
ctitle = {ctitle1 ctitle2 ctitle3};
end
else
if(isempty(ctitle2))
ctitle = {ctitle1};
else
ctitle = {ctitle1 ctitle2};
end
end
lgnd = [];
for k = 1:length(out)
lgnd{k} = outCh(k,:);
end
if FullTS
[dum,npts] = size(TSdata{ii});
i0 = 1; i1 = npts;
else
i0 = TSw{ii}.i0;
i1 = TSw{ii}.i1;
end
NcB = TSc{ii}.NcB;
[T,R,S] = mCoh(TSdata{ii}(:,i0:i1),in,out,given,NcB);
T = T.*TSd{ii}.dt; % periods in seconds
axes(TSc{ii}.hAx);
hold off
Hlines = semilogx(T,R);
set(Hlines,'Linewidth',2);
title(ctitle,'FontWeight','demi');
xlabel 'Period (s)';
legH = legend(Hlines,lgnd,'Location','Best');
set (legH,'Interpreter','none')
set(TSc{ii}.hAx,'FontWeight','demi',...
'Ylim',[0,1]);
case 'NcB'
NcohBand = str2num(get(h,'String'));
if NcohBand > 0
TSc{ii}.NcB=NcohBand;
else
set(h,'String',num2str(TSc{ii}.NcB));
end
end
UpdateCohPlot = 0;