This repository has been archived by the owner on Nov 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathplotstats.m
112 lines (98 loc) · 7.32 KB
/
plotstats.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
function plotstats(cfg)
nrows = 1;
ncols = 4;
SpikeDensity_timelocked = spikeTrialDensity(cfg);
for ipart = 1 : size(SpikeDensity_timelocked, 2)
for markername = string(fields(SpikeDensity_timelocked{ipart}.sdf_bar))'
nrows = max([nrows, size(SpikeDensity_timelocked{ipart}.stat.(markername), 2)]);
end
end
for ipart = 1 : size(SpikeDensity_timelocked, 2)
fig = figure;
orient(fig, 'portrait');
col = 1;
for markername = string(fields(SpikeDensity_timelocked{ipart}.sdf_bar))'
disp(size(SpikeDensity_timelocked{ipart}.sdf_bar.(markername).label, 2));
row = 1;
for itemp = 1 : size(SpikeDensity_timelocked{ipart}.sdf_bar.(markername).label, 2)
subaxis(nrows, ncols, (row-1) * ncols + col, 'SpacingVert', 0.01);
hold on
if size(SpikeDensity_timelocked{ipart}.sdf_bar.(markername).label, 2) == 1
bar(SpikeDensity_timelocked{ipart}.sdf_bar.(markername).time, SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg, 1, 'facecolor', [127/255,127/255,127/255], 'edgecolor', 'none');
else
bar(SpikeDensity_timelocked{ipart}.sdf_bar.(markername).time, SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg(itemp, :), 1, 'facecolor', [127/255,127/255,127/255], 'edgecolor', 'none');
end
if isfield(SpikeDensity_timelocked{ipart}.stat.(markername){itemp}, 'posclusters')
for ipos = 1 : size(SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.posclusters, 2)
if SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.posclusters(ipos).prob < cfg.stats.alpha
sel = find(SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.posclusterslabelmat == ipos);
if size(SpikeDensity_timelocked{ipart}.sdf_bar.(markername).label, 2) == 1
lag = size(SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg, 1) - size(SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.mask, 2);
if length(sel) == 1
bar([SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.time(sel)-0.001, SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.time(sel)+0.01], [SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg( sel+lag), SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg(sel+lag)], 1, 'facecolor', [252/255,187/255,62/255], 'edgecolor', 'none');
else
bar( SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.time(sel), SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg(sel+lag), 1, 'facecolor', [252/255,187/255,62/255], 'edgecolor', 'none');
end
else
lag = size(SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg, 2) - size(SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.mask, 2);
if length(sel) == 1
bar([SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.time(sel)-0.001, SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.time(sel)+0.01], [SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg(itemp, sel+lag), SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg(itemp, sel+lag)], 1, 'facecolor', [252/255,187/255,62/255], 'edgecolor', 'none');
else
bar( SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.time(sel), SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg(itemp, sel+lag), 1, 'facecolor', [252/255,187/255,62/255], 'edgecolor', 'none');
end
end
end
end
end
if isfield(SpikeDensity_timelocked{ipart}.stat.(markername){itemp}, 'negclusters')
for ineg = 1 : size(SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.negclusters, 2)
if SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.negclusters(ineg).prob < cfg.stats.alpha
sel = find(SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.negclusterslabelmat == ineg);
if size(SpikeDensity_timelocked{ipart}.sdf_bar.(markername).label, 2) == 1
lag = size(SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg, 1) - size(SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.mask, 2);
if length(sel) == 1
bar([SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.time(sel)-0.001, SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.time(sel)+0.01], [SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg( sel+lag), SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg(sel+lag)], 1, 'facecolor', [70/255,93/255,250/255], 'edgecolor', 'none');
else
bar( SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.time(sel), SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg(sel+lag), 1, 'facecolor', [70/255,93/255,250/255], 'edgecolor', 'none');
end
else
lag = size(SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg, 2) - size(SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.mask, 2);
if length(sel) == 1
bar([SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.time(sel)-0.001, SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.time(sel)+0.01], [SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg(itemp, sel+lag), SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg(itemp, sel+lag)], 1, 'facecolor', [70/255,93/255,250/255], 'edgecolor', 'none');
else
bar( SpikeDensity_timelocked{ipart}.stat.(markername){itemp}.time(sel), SpikeDensity_timelocked{ipart}.sdf_bar.(markername).avg(itemp, sel+lag), 1, 'facecolor', [70/255,93/255,250/255], 'edgecolor', 'none');
end
end
end
end
end
box off
set(gca, 'TickDir', 'out');
xlim(cfg.epoch.toi.(markername));
ytick = get(gca, 'ytick');
set(gca, 'ytick', ytick(end));
if row ~= size(SpikeDensity_timelocked{ipart}.sdf_bar.(markername).label, 2)
set(gca,'xtick',[]);
set(gca,'xticklabel',[]);
set(gca,'XColor','none')
else
xlabel('Time (seconds)');
ylabel('Count');
end
set(gca,'FontSize', 4);
if row == 1
title(markername);
end
row = row + 1;
end
col = col + 1;
end
% print ISI to file
fig.Renderer = 'Painters'; % Else pdf is saved to bitmap
set(fig,'PaperOrientation','portrait');
set(fig,'PaperUnits','normalized');
set(fig,'PaperPosition', [0 0 1 1]);
fname_fig = fullfile(cfg.imagesavedir, 'stats', strcat(cfg.prefix, 'p', num2str(ipart), '_stats_bargraphs'));
exportgraphics(fig, [fname_fig, '.jpg'], 'resolution', 150);
exportgraphics(fig, [fname_fig, '.pdf']);
end