-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplot_FFF_app.m
95 lines (63 loc) · 2.23 KB
/
plot_FFF_app.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
function out = plot_FFF_app (savepath, add_info)
FFF_select = add_info.FFF_select;
FFF_select
stim_idx = add_info.stim_idx;
FFF_panel = add_info.FFF_panel;
%% General variables
S = matfile(findfile_app(stim_idx,savepath,'FFF_average.mat'),'Writable',false);
S = S.FFF_average;
idx = [S.cell_idx] == FFF_select;
S = S(idx);
FFF_data = S.traces;
raster_spikes = S.spikes;
clear S
M = matfile(findfile_app(stim_idx,savepath,'Bined_spikes'),'Writable',false);
M = M.Bined_spikes(1,1);
binsize = M.bins_info(1).binsize;
nr_colours = size(FFF_data,2);
nr_bins_per_repeat = size(FFF_data,1);
stim_duration = nr_colours*nr_bins_per_repeat*binsize;
x_values = (binsize:binsize:stim_duration);
y_values = reshape(FFF_data,[1,size(x_values,2)]);
y_values = y_values*(1/binsize);
out.x_values = x_values;
out.y_values = y_values;
%% Raster plot
reshape1 = nr_colours*size(raster_spikes,1);
reshape2 = size(raster_spikes,2);
raster_spikes_plot = NaN(reshape1,reshape2);
for rr = 1:reshape2
raster_spikes_plot(:,rr) = reshape(raster_spikes(:,rr,:),[reshape1,1]);
raster_spikes_plot(raster_spikes_plot==0) = NaN;
end
ax1 = subplot(3,1,1,'parent',FFF_panel);
plot_raster(raster_spikes_plot,1,ax1);
raster_lim = size(raster_spikes_plot,2)*0.25+1;
ylim(ax1,[0,raster_lim]);
%ylabel(ax1,'Repeats')
%% Trace plot
% ax1 =
ax2 = subplot(3,1,2,'parent',FFF_panel);
plot(ax2,x_values,y_values,'k')
%ylabel(ax2,'Spikes in [Hz]');
%% Stimulus plot
%Create colour array for plotting
stim_fig = ones(1, size(x_values,2));
RGB_values = zeros(size(x_values,2),3);
RGB = [1 0 0; 0 1 0; 0 0 1; 1 0 1];
for ii = 1:nr_colours
idx_start = (ii-1)*nr_bins_per_repeat+1;
idx_black_start = idx_start + nr_bins_per_repeat/2;
RGB_values(idx_start:idx_black_start-1,:) = repmat(RGB(ii,:),floor(nr_bins_per_repeat/2),1);
end
%Plot stimulus
ax3 = subplot(3,1,3,'parent',FFF_panel);
stimulus_plot = bar(ax3,x_values,stim_fig,2,'FaceColor','flat','EdgeColor','flat');
%ylabel(ax3,'Stimulus');
%xlabel(ax3,'Time in [s]');
for kk = 1:length(RGB_values)
stimulus_plot.CData(kk,:) = RGB_values(kk,:);
end
linkprop([ax1,ax2,ax3],{'XLim'});
%linkaxes([ax1,ax2,ax3],'x');
end