-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathInteractionDelayReconstruction_plotting.m
More file actions
executable file
·109 lines (94 loc) · 3.07 KB
/
Copy pathInteractionDelayReconstruction_plotting.m
File metadata and controls
executable file
·109 lines (94 loc) · 3.07 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
function []=InteractionDelayReconstruction_plotting(cfg, TEpermtest)
% FUNCTION INTERACTIONDELAYRECONSTRUCTION_PLOTTING
%
% plots raw TE values versus assumed delay u from the output of
% InteractionDelayReconstruction_calculate.
%
% INPUTS:
% TEpermtest output structure with TE estimates from
% InteractionDelayReconstruction_calculate
%
% cfg configuration structure with fields
%
% cfg.standardize = 'yes' or 'no' - shift and z-standardize TE values
% for individual signal combinations
% (default = 'no')
%
% cfg.scaletype = 'log' or 'lin' - the predictiontime u scale
% (default = 'lin')
%
% cfg.ch_per_fig = no. channels that are plotted within one Figure,
% if the number of channels in the data set is
% higher, each channel is plotted into a new Figure
% (default = 8)
%
% Version 1.1 by Patricia Wollstadt Michael Wibral, Viola Priesemann
%
% Frankfurt 2015
% CHANGELOG:
%
% 2012.02.27 NP: plot for multiple channel combination;
% 2012.07.05 NP: adding scaletype for ploting
% 2014.12.01 PW: added correction for negative TE values (dividing by the
% max abs value doesn't work for negative values)
% 2014.12.02 PW: compatibility with new delay reconstruction
% 2015/01/30 PW: changed the way figures are handled (now called without the indexing),
% this caused problems with multiple calls to the function
%% set defaluts
if ~isfield(cfg,'scaletype'); cfg.scaletype = 'lin'; end;
if ~isfield(cfg,'standardize'); cfg.standardize = 'no'; end;
if ~isfield(cfg,'ch_per_fig'); cfg.ch_per_fig = 8; end;
%%
TEmat = TEpermtest.TEbyU;
uvec = ...
TEpermtest.TEprepare.cfg.predicttimemin_u: ...
TEpermtest.TEprepare.cfg.predicttimestepsize: ...
TEpermtest.TEprepare.cfg.predicttimemax_u;
optu = TEpermtest.TEpermvalues(:,end);
n_channels = size(TEmat, 1);
n_u = size(TEmat, 2);
% shift all values if there are TE values smaller than 0 (otherwise
% dividing by max abs doesn't work)
if strcmp(cfg.standardize, 'yes')
if any(TEmat < 0)
TEmat = TEmat + abs(min(min(TEmat)));
end
TEmat = TEmat ./ repmat(max(TEmat,[],2), 1, n_u);
maxTE = ones(n_channels,1);
ylab = 'TE [z-score]';
else
maxTE = max(TEmat, [], 2);
ylab = 'TE [arb. units]';
end
%% get channel labels for legend
labels = cell(1, n_channels);
for c=1:n_channels
labels{c} = [...
strrep(TEpermtest.sgncmb{c,1}, '_', ' ') ...
' - ' ...
strrep(TEpermtest.sgncmb{c,2}, '_', ' ')];
end
%%
if n_channels < cfg.ch_per_fig
figure
hold all
plot(uvec,TEmat)
scatter(optu, maxTE, 'r')
h = gca;
legend(labels)
xlabel('u [ms]'); ylabel(ylab);
else
h = zeros(1, n_channels);
for c=1:n_channels
figure
plot(uvec,TEmat(c,:))
h(c) = gca;
legend(labels{c})
xlabel('u [ms]'); ylabel(ylab);
end
end
set(h, ...
'Xlim', [uvec(1)-1 uvec(end)+1], ...
'Box', 'on' ...
)
end