-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisualize_data.m
56 lines (45 loc) · 1.35 KB
/
visualize_data.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
%% Plot sniff peaks against signal
% Define window to plot
window = 30000;
win_beg = 170000;
win_end = win_beg + window;
% Find nearest peak to window start and ending
beg_diff = abs(locs - win_beg);
end_diff = abs(locs - win_end);
[~, beg_idx] = min(beg_diff);
[~, end_idx] = min(end_diff);
% Plot
clf
plot(sniff_smooth(locs(beg_idx):win_end))
hold on
scatter(locs(beg_idx:end_idx)-locs(beg_idx), pks(beg_idx:end_idx))
axis([0 window min(sniff_smooth) max(sniff_smooth)]); % Scale axes
%% Visualize Ephys channels with inhalation times
% Set up plot
clf
cmap = colormap('jet');
colorIndices = round(linspace(1, size(cmap, 1), nchannels));
for ii = 1:4:nchannels
% Plot traces
p = plot(ephysx_rs(ii, win_beg:win_end));
color = cmap(colorIndices(ii), :);
p.Color = color; % Set the color
% Add a label at the trace and legend
label_str = "Ch " + num2str(ii);
p.DisplayName = "Ch " + num2str(ii);
end_val = ephysx_rs(ii, win_end); % Y position of label
t = text(window+50, end_val, label_str, 'HorizontalAlignment', 'left', 'VerticalAlignment', 'bottom');
t.Color = color;
hold on
end
% Sniff signal and peaks
% plot(sniff_smooth(locs(beg_idx):win_end))
% hold on
% for ii = beg_idx:end_idx
% disp(ii)
% x_value = locs(ii)-locs(beg_idx);
% line([x_value x_value], ylim)
% hold on
% end
legend()
hold off