-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotCoh3.m
83 lines (53 loc) · 1.63 KB
/
plotCoh3.m
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
function [ax,F] = plotCoh3(volPsd,H)
if ~exist('H','var'); H = []; end
if isempty(H); H = figure('WindowStyle','docked'); end
switch class(H)
case 'matlab.graphics.layout.TiledChartLayout'
F = H.Parent;
case 'matlab.ui.Figure'
F = H;
otherwise
end
figure(F);
ax = {};
ax{end+1} = nexttile;
if isempty(volPsd.svd.COH)
ax = []; F = []; return
end
%%% coherence spectrum
f = squeeze(volPsd.svd.f);
c = squeeze(volPsd.svd.COH(:,:,:,:,:,:,:,1));
plot(f,c,'k')
grid on
axis tight
xlabel('f (Hz)')
ylabel('coherence')
if isfield(volPsd.svd,'COH_fdr') && ~isempty(volPsd.svd.COH_fdr)
fdr = squeeze(volPsd.svd.COH_fdr(:,:,:,:,:,:,:,1));
end
K = volPsd.svd.K;
T = volPsd.svd.T;
[TW,W] = K2W(T,K,0);
paramStr = ['(K=' num2str(K) '; 2W=' num2str(W*2,'%0.4f') 'Hz; T=' num2str(T,'%0.2f') 'sec)'];
title(['coherence spectrum ' paramStr])
yLim = [1/K max(c(f>0.01))];
ylim(yLim);
xlim([0 f(end)])
addW([],volPsd.svd)
% if isfield(volPsd,'svdTrialGram')
% fStim = 1/mean(diff(volPsd.svdTrialGram.param.onsetList));
% xline(fStim,'Color','r','linestyle','--')
% end
if isfield(volPsd,'svdTrialGram')
onsetList = volPsd.svdTrialGram.onsetList;
ondurList = volPsd.svdTrialGram.durList;
fStim = 1/mean(diff(onsetList));
xline(fStim,'Color','r','linestyle','--')
if length(unique(ondurList))==1
xline(1/mean(ondurList(1)),'Color','g','linestyle','--')
offsetList = onsetList + ondurList;
offdurList = onsetList(2:end) - offsetList(1:end-1);
xline(1/mean(offdurList),'Color','b','linestyle','--')
end
end
ax = [ax{:}];