-
Notifications
You must be signed in to change notification settings - Fork 2
/
Plot_Raster_Ensembles.m
63 lines (55 loc) · 1.43 KB
/
Plot_Raster_Ensembles.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
function vectorSeq = Plot_Raster_Ensembles(raster,sequence,name,newFigure,colors)
% Plot raster sorted by ensembles
%
% vectorSeq = Plot_Raster_Ensembles(raster,sequence,name,newFigure,colors)
%
% default: name = ''; newFigure = false; colors = [];
%
% Jesus Perez-Ortega, Dec 2019
% Modified Jan 2020
% Modified Feb 2020
% Modified Mar 2020
% Modified May 2020
% Modified Jun 2020
switch nargin
case 2
name = '';
newFigure = true;
colors = [];
case 3
newFigure = true;
colors = [];
case 4
colors = [];
end
if iscolumn(sequence)
sequence = sequence';
end
[cells,frames] = size(raster);
ensembles = unique(sequence);
rasterColor = [];
ids = [];
for i = ensembles
% Get the raster form ensemble i
id = find(sequence==i);
rasterSingle = double(raster(:,id));
rasterSingle(rasterSingle>0) = -1;
rasterSingle(rasterSingle==0) = i;
rasterColor = [rasterColor rasterSingle];
ids = [ids id];
end
if isempty(colors)
colors = Read_Colors(length(ensembles));
colors = (colors+2*ones(size(colors)))/3;
end
if newFigure
Set_Figure(['Peaks on Raster (' name ')'],[0 0 1220 300]);
end
axis([0.5 frames 0.5 cells+0.5]); hold on
imagesc(rasterColor,[-1 length(ensembles)]);
colormap(gca,[0 0 0;1 1 1;colors])
ylabel('neurons')
title(strrep(name,'_','-'))
if nargout
vectorSeq = ids;
end