-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreateAllRawVoltagePlots.m
280 lines (241 loc) · 11.3 KB
/
CreateAllRawVoltagePlots.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
close all;
clear;
addpath(genpath('include'));
%% GLOBAL SETTINGS
dir_exports = 'figures';
if ~exist(dir_exports, 'dir')
mkdir(dir_exports)
end
set(0,'DefaultAxesFontSize', 20);
% set(0,'DefaultFigureVisible','off');
highlight_CAP1_peak = false; % mark the location of the peak of CAP1 with a white line
%% EXPERIMENT SETTINGS
Experiments = { ...
% ELECTRICAL & LASER EXPERIMENT (9 HOURS TOTAL)
struct( ...
'id', 'ElectricalAndLaser9Hours', ...
'title', '9 Hours With Laser (2016-05-27)', ...
'data', 'data/hl_201605027/AllChartsProcessed.mat', ...
'VoltageRangeForMesh', [-30 45], ... % in uV
'ColorRangeForMesh', [-10 30], ... % in uV -- voltages outside this range will saturate
'SampleTimeRangeForMesh', [12, 140], ... % in ms
'TrialTimeRangeForMesh', struct( ...
'Hours1to2', '[0 sum(DurationsPerChart(1:2))]', ... % in sec -- first 2 charts = 2 hr 1 min 35 sec
'FullExperiment', '[0 sum(DurationsPerChart)]' ... % in sec -- all charts = 9 hr 10 min 10 sec
), ...
'TracesToHighlight', struct( ...
'Hours1to2', [ ...
1 ... % first trial
3594 ... % during the laser-on period exactly 0.5 hours into the experiment
7221 ... % first trial after laser is turned off around the end of hour 1
10774 ... % during the laser-on period exactly 1.5 hours into the experiment
14505 ... % first trial after laser is turned off around the end of hour 2
], ...
'FullExperiment', [ ...
1 ... % first trial
] ...
) ...
) ...
% ELECTRICAL ONLY EXPERIMENT (9 HOURS TOTAL)
struct( ...
'id', 'ElectricalOnly9Hours', ...
'title', '9 Hours Without Laser (2016-10-11)', ...
'data', 'data/10.11.2016/AllChartsProcessed.mat', ...
'VoltageRangeForMesh', [-75 75], ... % in uV
'ColorRangeForMesh', [-10 30], ... % in uV -- voltages outside this range will saturate
'SampleTimeRangeForMesh', [12, 140], ... % in ms
'TrialTimeRangeForMesh', struct( ...
'Hours1to2', '[0 DurationsPerChart(1)]', ... % in sec -- first chart = 2 hr 1 min 27 sec
'FullExperiment', '[0 sum(DurationsPerChart)]' ... % in sec -- all charts = 9 hr 20 min 43 sec
), ...
'TracesToHighlight', struct( ...
'Hours1to2', [ ...
1 ... % first trial
3583 ... % exactly 0.5 hours into the experiment
7186 ... % exactly 1 hour into the experiment
10787 ... % exactly 1.5 hours into the experiment
14391 ... % exactly 2 hours into the experiment
], ...
'FullExperiment', [ ...
1 ... % first trial
] ...
) ...
) ...
% ELECTRICAL & LASER EXPERIMENT (8 HOURS TOTAL)
struct( ...
'id', 'ElectricalAndLaser8Hours', ...
'title', '8 Hours With Laser (2016-05-31)', ...
'data', 'data/hl_201605031/AllChartsProcessed.mat', ...
'VoltageRangeForMesh', [-50 50], ... % in uV
'ColorRangeForMesh', [-10 25], ... % in uV -- voltages outside this range will saturate
'SampleTimeRangeForMesh', [12, 140], ... % in ms
'TrialTimeRangeForMesh', struct( ...
'Hours1to2', '[0 sum(DurationsPerChart(1:2))]', ... % in sec -- first 2 charts = 2 hr 18 min 11 sec
'FullExperiment', '[0 sum(DurationsPerChart)]' ... % in sec -- all charts = 8 hr 33 min 33 sec
), ...
'TracesToHighlight', struct( ...
'Hours1to2', [ ...
1 ... % first trial
], ...
'FullExperiment', [ ...
1 ... % first trial
] ...
) ...
) ...
% ELECTRICAL & LASER EXPERIMENT (7 HOURS TOTAL)
struct( ...
'id', 'ElectricalAndLaser7Hours', ...
'title', '7 Hours With Laser (2016-05-17)', ...
'data', 'data/hl_201605017/AllChartsProcessed.mat', ...
'VoltageRangeForMesh', [-30 20], ... % in uV
'ColorRangeForMesh', [ -5 15], ... % in uV -- voltages outside this range will saturate
'SampleTimeRangeForMesh', [12, 140], ... % in ms
'TrialTimeRangeForMesh', struct( ...
'Hours1to2', '[0 sum(DurationsPerChart(1:2))]', ... % in sec -- first 2 charts = 2 hr 1 min 15 sec
'FullExperiment', '[0 sum(DurationsPerChart)]' ... % in sec -- all charts = 7 hr 11 min 44 sec
), ...
'TracesToHighlight', struct( ...
'Hours1to2', [ ...
1 ... % first trial
], ...
'FullExperiment', [ ...
1 ... % first trial
] ...
) ...
) ...
% ELECTRICAL & LASER EXPERIMENT (8 HOURS TOTAL, LAST 5 HOURS UNATTENDED)
struct( ...
'id', 'ElectricalAndLaser8Hours2', ...
'title', '8 Hours With Laser (2016-04-29)', ...
'data', 'data/hl_20160429/AllChartsProcessed.mat', ...
'VoltageRangeForMesh', [-50 25], ... % in uV
'ColorRangeForMesh', [ -7 20], ... % in uV -- voltages outside this range will saturate
'SampleTimeRangeForMesh', [12, 160], ... % in ms
'TrialTimeRangeForMesh', struct( ...
'Hours1to2', '[0 sum(DurationsPerChart(1:2))]', ... % in sec -- first 2 charts = 2 hr 14 min 46 sec
'FullExperiment', '[0 sum(DurationsPerChart)]' ... % in sec -- all charts = 8 hr 18 min 10 sec
), ...
'TracesToHighlight', struct( ...
'Hours1to2', [ ...
1 ... % first trial
], ...
'FullExperiment', [ ...
1 ... % first trial
] ...
) ...
) ...
};
%% TIME SPAN SETTINGS
TimeSpans = { ...
% HOURS 1 - 2
struct( ...
'id', 'Hours1to2', ...
'title', 'First 2 Hours', ...
'TrialSkippingFactor', 1, ...
'TimeMarkers', '(1:2) * 3600', ... % in sec
'TimeMarkersType', struct( ...
'ViewAngle60', 'none', ...
'ViewAngle90', 'lines' ...
), ...
'SampleMarkers', 'CAP1Window', ... % in ms
'SampleMarkersType', struct( ...
...'VewAngle60', 'lines', ...
...'ViewAngle90', 'lines' ...
'ViewAngle60', 'none', ...
'ViewAngle90', 'none' ...
), ...
'DesiredTrialTimeUnits', 'min' ...
) ...
% FULL EXPERIMENT
struct( ...
'id', 'FullExperiment', ...
'title', 'Full Experiment', ...
'TrialSkippingFactor', 5, ...
'TimeMarkers', '(1:ceil(sum(DurationsPerChart)/3600)) * 3600', ... % in sec
'TimeMarkersType', struct( ...
'ViewAngle60', 'lines', ...
'ViewAngle90', 'lines' ...
), ...
'SampleMarkers', 'CAP1Window', ... % in ms
'SampleMarkersType', struct( ...
...'ViewAngle60', 'lines', ...
...'ViewAngle90', 'lines' ...
'ViewAngle60', 'none', ...
'ViewAngle90', 'none' ...
), ...
'DesiredTrialTimeUnits', 'hr' ...
) ...
};
%% VIEW ANGLE SETTINGS
ViewAngles = [ ...
60 ...
90 ...
];
%% CREATE PLOTS
for i = 1:length(Experiments)
ex = Experiments{i};
load(ex.data);
for j = 1:length(TimeSpans)
ts = TimeSpans{j};
for va = ViewAngles
PlotTitle = [
ex.title, ' - ' ...
'Raw Voltage Contour - ' ...
ts.title ...
];
FigureFileName = [
dir_exports '/' ...
ex.id, ' - ' ...
'RawVoltage - ' ...
ts.id, ' - ' ...
'ViewAngle', num2str(va) ...
...' - SmallArtifactsOnlyWithAP1Alignment' ...
'.png' ...
];
figure();
PlotEpisodicVoltageMesh( ...
CAPsignalAllCharts, ... % m-by-n matrix of voltages, in uV
SampleTimes, ... % n sample times for x-axis, in ms
TrialTimesAllCharts, ... % m trial times for y-axis, in sec
ts.TrialSkippingFactor, ... % y indices downsampling factor
ex.SampleTimeRangeForMesh, ... % x-axis range, in ms
eval(ex.TrialTimeRangeForMesh.(ts.id)), ... % y-axis range, in sec
ex.VoltageRangeForMesh, ... % z-axis range, in uV
ex.ColorRangeForMesh, ... % color range, in uV
ts.DesiredTrialTimeUnits, ... % y-axis units ('sec', 'min', or 'hr')
eval(ts.TimeMarkers), ... % y-axis marker locations, in sec
ts.TimeMarkersType.(['ViewAngle', num2str(va)]), ... % y-axis marker type ('none', 'lines', or 'planes')
eval(ts.SampleMarkers), ... % x-axis marker locations, in ms
ts.SampleMarkersType.(['ViewAngle', num2str(va)]), ... % x-axis marker type ('none', 'lines', or 'planes')
ex.TracesToHighlight.(ts.id), ... % y indices to highlight
va, ... % plot view angle, in degrees
PlotTitle ... % plot title
);
if highlight_CAP1_peak
% depending on the desired y-axis units for the plot, determine
% a time conversion factor
switch ts.DesiredTrialTimeUnits
case 'sec'
% units are already in sec
TrialTimeConversionFactor = 1;
case 'min'
TrialTimeConversionFactor = 60;
case 'hr'
TrialTimeConversionFactor = 3600;
otherwise
error('Unknown DesiredTrialTimeUnits ''%s''!', ts.DesiredTrialTimeUnits);
end
plot3(...
CAP1TimesAllCharts, ...
TrialTimesAllCharts / TrialTimeConversionFactor, ...
CAP1HeightsAllCharts, ...
'color', 'w', ...
'linewidth', 2 ...
);
end
set(gcf, 'Units', 'normalized', 'Position', [0,0,1,1]);
hgexport(gcf, FigureFileName, hgexport('factorystyle'), 'Format', 'png');
close all;
end % for ViewAngles
end % for TimeSpans
end % for Experiments