-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfarm_plot_coherence.m
69 lines (51 loc) · 1.71 KB
/
farm_plot_coherence.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
function varargout = farm_plot_coherence( data, coh, cfg )
% FARM_PLOT_TFA will plot the result of the farm_time_frequency_analysis_emg_acc
%
% SYNTAX
% FARM_PLOT_TFA( data, coh )
% figH = FARM_PLOT_TFA( data, coh )
%
% INPUTS
% - data : see <a href="matlab: help farm_check_data">farm_check_data</a>
% - coh : output of <a href="matlab: help farm_coherence_analysis_emg_acc">farm_coherence_analysis_emg_acc</a>
% - cfg :
% foi // (Hz) default=[4 6] frequency of interest
% logtransform // (0/1) default=1 log-transform the result before display
%
% NOTES
%
%
% See also farm_time_frequency_analysis_emg_acc
if nargin==0, help(mfilename('fullpath')); return; end
%% Input parsing
if ~exist('cfg','var')
cfg = [];
end
foi = ft_getopt(cfg, 'foi', [4 6]); % (Hz) frequency of interest
logtransform = ft_getopt(cfg, 'logtransform', 1); % (0/1) log-transform the result before display
%% Plot
foi_idx = coh.freq >= foi(1) & coh.freq <= foi(2);
figH = figure('Name',data.cfg.datafile,'NumberTitle','off');
figH.UserData = mfilename;
ax = axes(figH);
Title = sprintf('mean(coherence@[%g %g])', foi(1), foi(2));
img = mean(coh.cohspctrm(:,:,foi_idx),3);
if logtransform
Title = ['log( ' Title ' )'];
imagesc(ax, log(img));
else
imagesc(ax, img );
end
ax.Title.String = Title;
figH.Colormap = jet();
ax.XTick = 1:length(coh.label);
ax.XTickLabel = coh.label;
ax.XTickLabelRotation = 45;
ax.YTick = 1:length(coh.label);
ax.YTickLabel = coh.label;
ax.TickLabelInterpreter = 'none';
%% Output ?
if nargout
varargout{1} = figH;
end
end % function