-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPlotTools.m
139 lines (123 loc) · 4.52 KB
/
PlotTools.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
classdef PlotTools
properties
samples = 54;
end
methods
function self = PlotTools(data_ref)
%init method
if data_ref == 'y'
self.samples = 32;
end
end
function [] = plot_wvs(self, wv_data, x0, xN, pos, step)
%Plots waveform data with channels down columns
figure;
%pos is position of synchronous spikes (from fet file)
%x0 is start value, xN is end value; m is step size (wrt pos)
if nargin < 3
%assumes only one spike is being plotted
for i=1:8;
subplot(8, 1, i);
plot(wv_data(i, :));
ylim([min(min(wv_data)), max(max(wv_data))]);
xlim([0, self.samples]);
end
return
end
if nargin < 5
%assumes that x0 is positive
pos = [1:1:xN];
step = 1;
end
if nargin < 6
step = 1;
end
dim = size(wv_data);
set = reshape(wv_data(:, :, pos), dim(1), []);
min_amp = min(min(set));
max_amp = max(max(set));
for y=x0:xN;
diff = xN-x0+1;
%add optional array of timestamps here
for i=1:8;
subplot(8*step, diff, (((y-x0)+1)+(diff*(i-1))));
plot(wv_data(i, :, pos(y)));
ylim([min_amp, max_amp]);
xlim([0, self.samples]);
if i == 1
title(int2str(y));
end
end
end
end
function [] = plot_wv_overlays(self, wvs, clus, clu_set, num)
%Plots overlayed series of random waveforms from a given cluster
% reproduces the waveform feature in Klusters
%Input: clu_set takes an array of integers
% wvs, clus, expect array (i.e. index into the cell)
%To plot all input wvs overlayed
if nargin < 3
clus = [1:size(wvs, 3)];
clu_set = clus;
num = 1;
end
dim = size(wvs);
for i=1:length(clu_set)
c = clu_set(i);
pos = randsample(find(clus==c), num);
set = reshape(wvs(:, :, pos), dim(1), []);
min_amp = min(min(set));
max_amp = max(max(set));
%add optional array of timestamps here
for j=1:8;
subplot(8, length(clu_set), ((i)+(length(clu_set)*(j-1))));
hold on;
for k=1:num
plot(wvs(j, :, pos(k)));
ylim([min_amp, max_amp]);
xlim([0, self.samples]);
end
hold off;
if j == 1
title(int2str(i));
end
end
end
end
%DON'T USE WITHOUT MODIFICATIONS
%{
function [] = plot_interval_wvs(self, wv_data, channel, samples, synch)
%plots intervals of given channel with width 'samples'
%if samples does not divide 54, truncate lagging elements
truncate = mod(54, samples);
num_intervals = (54-truncate)/samples;
figure;
ref_wvs = randsample(1:max(size(wv_data)), length(synch));
for i=1:num_intervals
subplot(2, num_intervals, i)
hold on
for j=1:length(synch)
plot(wv_data(channel, ((i-1)*samples)+1:i*samples, synch(j)));
end
ylim([-1000, 1000]);
if i == 1
title('synch waveforms');
ylabel(strcat('channel ', int2str(channel)));
end
hold off
subplot(2, num_intervals, i+num_intervals)
hold on
for j=1:length(synch)
plot(wv_data(channel, ((i-1)*samples)+1:i*samples, ref_wvs(j)));
end
ylim([-1000, 1000]);
if i == 1
title('random reference waveforms');
ylabel(strcat('channel ', int2str(channel)));
end
hold off
end
end
%}
end
end