-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsupport_PlotGrandERAConf.m
132 lines (106 loc) · 5.71 KB
/
support_PlotGrandERAConf.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
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
121
122
123
124
125
126
127
128
129
130
131
132
function FigHandle = support_PlotGrandERAConf(ERAConfCurves, Config, Meta)
if Config.Plot.GrandERA.EveryParticipant
for p = 1:size(ERAConfCurves,2)
yVals = ERAConfCurves(:, p);
% plot_time = 1:length(yVals);
plot_time = 0:(length(yVals)-1);
FigHandle = plot(plot_time, yVals, 'LineWidth', 2);
% Transform to milliseconds
set(FigHandle, 'XData', (get(FigHandle, 'XData')-1) / Meta.NomSRate * 1000 + Config.AnalyzeFromSec*1000);
end
else
% PUPSIZE_CURVE_GRAND = NaN(Config.AnalyzeLenSample, 1);
% PUPSIZE_CURVE_GRAND(1:Config.AnalyzeLenSample, 1) = mean(TEPRCurves, 2, 'omitnan');
ERAConfCurves_GRAND = mean(ERAConfCurves, 2, 'omitnan');
yVals = ERAConfCurves_GRAND;
% plot_time = 1:length(yVals);
plot_time = 0:(length(yVals)-1);
if ~isfield(Config.Plots, 'LayeredFigCounter')
Config.Plots.LayeredFigCounter = 1;
end
FigHandle = plot(plot_time, ERAConfCurves_GRAND, 'LineWidth', 2)
% Transform to milliseconds
set(FigHandle, 'XData', (get(FigHandle, 'XData')-1) / Meta.NomSRate * 1000 + Config.AnalyzeFromSec*1000);
end
if isnan(Config.Plot.GrandTEPR.XLim)
Config.Plot.GrandTEPR.XLim = [round(Config.AnalyzeFromSec*1000) round(Config.AnalyzeToSec*1000)];
% Config.Plot.GrandTEPR.XLim = [0 round(Config.AnalyzeToSec*1000)];
end
xlim(Config.Plot.GrandTEPR.XLim);
if ~isnan(Config.Plot.GrandERA.YLim)
ylim([0.85,1]);
end
if Config.Plots.Grid
grid on;
grid minor;
end
if Config.Plots.Markings.Enabled == true && Config.Plots.LayeredFigCounter < 2
currylim = ylim;
colorB = [0.3 0.3 0.9];
yDt = 5;
for t = (Config.AnalyzeFromSec*1000):(Config.AnalyzeToSec*1000)
% for t = Config.Plot.GrandTEPR.XLim(1):Config.Plot.GrandTEPR.XLim(2)
if ~Config.Plots.Markings.OnEdges && (t==Config.Plot.GrandTEPR.XLim(1) || t==Config.Plot.GrandTEPR.XLim(2))
continue;
end
if Config.AlignToStimOrResp == true % STIMULUS-ALIGNED
if Config.Plots.Markings.B && t~=0 && mod(t, Config.ISISec*1000) == Config.ISISec*1000 + (Config.BaselineFromSec+Config.BaselineToSec)/2*1000
xline(t, 'Color', colorB);
text(t, currylim(2)-(currylim(2)-currylim(1))/yDt,'B', 'Color', colorB)
end
if Config.Plots.Markings.S && mod(t, Config.ISISec*1000) == 0
% todo: ONLY IF STIMULUS-ALIGNED
xline(t, 'Color', colorB);
text(t, currylim(2)-(currylim(2)-currylim(1))/yDt,'S', 'Color', colorB)
end
if Config.Plots.Markings.F && t~=0 && mod(t, Config.ISISec*1000) == Config.ISISec*1000 - Config.FixBeforeStimSec*1000
xline(t, 'Color', colorB);
text(t, currylim(2)-(currylim(2)-currylim(1))/yDt,'F', 'Color', colorB)
end
elseif Config.AlignToStimOrResp == false % RESPONSE-ALIGNED
if Config.Plots.Markings.B && t~=0 && t/(Config.ISISec*1000) == Config.ISISec*1000 + (Config.BaselineFromSec+Config.BaselineToSec)/2*1000
xline(t, 'Color', colorB);
text(t, currylim(2)-(currylim(2)-currylim(1))/yDt,'B', 'Color', colorB)
end
if Config.Plots.Markings.R && t/(Config.ISISec*1000) == 0
xline(t, 'Color', colorB);
text(t, currylim(2)-(currylim(2)-currylim(1))/yDt,'R', 'Color', colorB)
end
end
% if mod(t, Config.ISISec*1000) == 0
% xline(t+ (Config.BaselineFromSec+Config.BaselineToSec)/2*1000, 'Color', colorB);
% text(t+ (Config.BaselineFromSec+Config.BaselineToSec)/2*1000, currylim(2)-(currylim(2)-currylim(1))/yDt,'B', 'Color', colorB)
%
% xline(t, 'Color', colorB);
% text(t, currylim(2)-(currylim(2)-currylim(1))/yDt,'S', 'Color', colorB)
%
% xline(t -Config.FixBeforeStimSec*1000, 'Color', colorB);
% text(t -Config.FixBeforeStimSec*1000, currylim(2)-(currylim(2)-currylim(1))/yDt,'F', 'Color', colorB)
%
% end
end
end
set(gcf, 'Position', get(0, 'Screensize')*Config.Plots.ScaleFactor);
% title(['ERA confidence averaged across all Participants']);
xlabel(['Time [ms]']);
ylabel(['Confidence']);
OutFilePath = ['~RESULTS/' Meta.RootDirTag '/' ];
if ~exist(OutFilePath, 'dir')
mkdir(OutFilePath);
end
OutFileName = ['ERA'];
OutFileName = [OutFileName ' alignSR=' num2str(Config.AlignToStimOrResp)];
OutFileName = [OutFileName ' skipN=' num2str(Config.SkipFirstNtrials)];
OutFileName = [OutFileName ' filt=' num2str(Config.Filter.Behav.Enabled)];
OutFileName = [OutFileName ' (' Config.Filter.Behav.FriendlyName ')'];
if Config.Plot.GrandTEPR.EveryParticipant
OutFileName = [OutFileName '_EP'];
end
OutFileName = [OutFileName '.png'];
OutFileName = char(OutFileName);
% set(gcf, 'Position', get(0, 'Screensize'));
set(gcf, 'Position', get(0, 'Screensize')*Config.Plots.ScaleFactor);
saveas(gcf,[OutFilePath OutFileName]);
hold off;
pause(0.5)
end