forked from DeNardoLab/BehaviorDEPOT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotTrajectoryMap.m
104 lines (89 loc) · 3.48 KB
/
plotTrajectoryMap.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
function beh_plot = plotTrajectoryMap(Metrics, frame1, Params, Behavior, analyzed_folder_name)
X = Metrics.Location(1,:);
Y = Metrics.Location(2,:);
if Params.plotBeh % if plotting behavior, loop through behaviors and make individual figures
beh_icons = {'ksquare', 'k^','kdiamond', 'kv', 'k+', 'k*', 'kpentagram', 'khexagram'};
beh_name = fieldnames(Behavior);
beh_cell = struct2cell(Behavior);
for i = 1:length(beh_cell) % loop through behaviors
close;
figure;
I = imshow(frame1);
set(I, 'AlphaData', 0.2) % set to 0 if don't want arena image superimposed
hold on
title('Behavior Mapping');
leg = [];
if Params.plotSpaceTime
leg = [leg, 'location'];
sz = 1:length(X);
scatter(X, Y, 5, sz, 'filled');
colormap('jet');
colorbar;
colorbar('Ticks',[100,(length(X)-100)],'TickLabels',{'Start','End'})
elseif Params.plotSpace
leg = [leg, 'trajectory'];
scatter(X, Y, 5, 'filled');
end
i_beh_name = string(beh_name(i)); % load behvavior name
i_beh_vec = beh_cell{i}.Vector; % load behavior vector
i_beh_loc = Metrics.Location(:,~~i_beh_vec);
scatter(i_beh_loc(1,:),i_beh_loc(2,:),beh_icons{i});
leg = [leg, i_beh_name];
if Params.do_roi
for i = 1:length(Params.roi)
plot(polyshape(Params.roi{i}), 'FaceAlpha', 0.1);
leg = [leg, strcat('ROI #',string(i))];
end
end
legend(leg);
beh_plot = gcf;
cd(analyzed_folder_name)
savename = strcat(i_beh_name, ' Map');
savefig(beh_plot, (savename));
end
elseif Params.plotSpaceTime
figure;
I = imshow(frame1);
set(I, 'AlphaData', 0.2) % set to 0 if don't want arena image superimposed
hold on
title('Behavior Mapping');
leg = [];
leg = [leg, 'location'];
sz = 1:length(X);
scatter(X, Y, 5, sz, 'filled');
colormap('jet');
colorbar;
colorbar('Ticks',[100,(length(X)-100)],'TickLabels',{'Start','End'})
if Params.do_roi
for i = 1:length(Params.roi)
plot(polyshape(Params.roi{i}), 'FaceAlpha', 0.1);
leg = [leg, strcat('ROI #',string(i))];
end
end
legend(leg);
beh_plot = gcf;
cd(analyzed_folder_name)
savename = 'Behavior Map';
savefig(beh_plot, (savename));
elseif Params.plotSpace
figure;
I = imshow(frame1);
set(I, 'AlphaData', 0.2) % set to 0 if don't want arena image superimposed
hold on
title('Behavior Mapping');
leg = [];
leg = [leg, 'trajectory'];
scatter(X, Y, 5, 'filled');
if Params.do_roi
for i = 1:length(Params.roi)
plot(polyshape(Params.roi{i}), 'FaceAlpha', 0.1);
leg = [leg, strcat('ROI #',string(i))];
end
end
legend(leg);
beh_plot = gcf;
cd(analyzed_folder_name)
savename = 'Behavior Map';
savefig(beh_plot, (savename));
end
end