-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplotcAPData.m
217 lines (204 loc) · 7.55 KB
/
plotcAPData.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
function [] = plotcAPData()
%Use this to plot previously analyzed and normalized cAP data. Will make a
%set of normalized cAP plots, and also plot APD values against a defined
%dose.
%%%%SEARCH PLOT TO CONTROL PLOT SIZE
%Define variables
allAvg_apd30 = zeros(1);
allAvg_apd50 = zeros(1);
allAvg_apd90 = zeros(1);
allstd_apd30 = zeros(1);
allstd_apd50 = zeros(1);
allstd_apd90 = zeros(1);
allAvg_cAPD30 = zeros(1);
allAvg_cAPD50 = zeros(1);
allAvg_cAPD90 = zeros(1);
allstd_cAPD30 = zeros(1);
allstd_cAPD50 = zeros(1);
allstd_cAPD90 = zeros(1);
Treatment = zeros(1); %create an x value corresponding to the current file
%select .mat files generated from apdCalc analyze
[Filelist,Pathname] = uigetfile('C:\Users\Steven Boggess\Documents\Miller Lab\Data\*.mat','File Selector','MultiSelect','on');
allData = struct();
numFiles = numel(Filelist);
outputName = input('Please provide a name: ');
figure('name',outputName,'numbertitle','off');
hold on
for iFile = 1:numFiles % Loop over found files
Data = load(fullfile(Pathname, Filelist{1,iFile}));
currentfilename = fullfile(Filelist{iFile});
% Data = rmfield(Data , 'cAP_Data') ; %remove the table from files, avoid error
Fields = fieldnames(Data);
for iField = 1:numel(Fields) % Loop over fields of current file
aField = Fields{iField};
switch (aField)
case 'avg_apd30'
avg_apd30 = Data.(aField);
case 'avg_apd50'
avg_apd50 = Data.(aField);
case 'avg_apd90'
avg_apd90 = Data.(aField);
case 'std_apd30'
std_apd30 = Data.(aField);
case 'std_apd50'
std_apd50 = Data.(aField);
case 'std_apd90'
std_apd90 = Data.(aField);
case 'avg_cAPD30'
avg_cAPD30 = Data.(aField);
case 'avg_cAPD50'
avg_cAPD50 = Data.(aField);
case 'avg_cAPD90'
avg_cAPD90 = Data.(aField);
case 'std_cAPD30'
std_cAPD30 = Data.(aField);
case 'std_cAPD50'
std_cAPD50 = Data.(aField);
case 'std_cAPD90'
std_cAPD90 = Data.(aField);
case 'normcAP'
normcAP = Data.(aField);
case 'meancAP'
meancAP = Data.(aField);
end
end
%%Read length of meancAP to plot time
disp (currentfilename) %Show the file you are working with
% Fs = input('What was the sampling rate? '); %Ask for the sampling rate to give input for apdCalc (in Hz or fps)
Fs = 200 ;
dataTitle = input('What would you like to call this data set? ');
numframes = length (meancAP);
timeElap = numframes*(1/Fs);
time = zeros (numframes,1); %pre-allocate;
cnt = 1; %start the count;
for ii = (1:numframes)
time(cnt) = (ii/Fs);
cnt = cnt + 1;
end
time = time*1000;
%plot the normal cAPs and the meancAP
% subplot (1, 1, iFile); %Edit this to adjust the ap plot dimensions
subplot (1, 1, 1); %Edit this to adjust the ap plot dimensions
hold on;
numEvents = length(normcAP);
for i= 1:numEvents
numframes2 = length (normcAP{i,1});
timeElap2 = numframes2*(1/Fs);
time2 = zeros (numframes2,1); %pre-allocate;
cnt = 1; %start the count;
for ii = (1:numframes2)
time2(cnt) = (ii/Fs);
cnt = cnt + 1;
end
time2 = time2*1000;
plot (time2, normcAP{i,1});
end
plotColor = input ('What color for this plot? Use matlab shortcuts ');
plot (time,meancAP,'LineWidth',3,...
'Color' , plotColor);
title(dataTitle);
xlabel('Time(ms)');
ylabel('Intensity');
%END OF PLOTTING cAP's FOR CURRENT FILE
%%Store apd and cAPD values to create linear plot of APD vs treatment
% %Define the treatment value
% Treatment = input('Input the treatment value (Drug conc., stimulation, etc.): ');
%
% %Insert and combine values
% if (allAvg_apd50(1,1) == 0)
% allAvg_apd30 = avg_apd30;
% allAvg_apd50 = avg_apd50;
% allAvg_apd90 = avg_apd90;
% allstd_apd30 = std_apd30;
% allstd_apd50 = std_apd50;
% allstd_apd90 = std_apd90;
% allAvg_cAPD30 = avg_cAPD30;
% allAvg_cAPD50 = avg_cAPD50;
% allAvg_cAPD90 = avg_cAPD90;
% allstd_cAPD30 = std_cAPD30;
% allstd_cAPD50 = std_cAPD50;
% allstd_cAPD90 = std_cAPD90;
% allTreatment = Treatment;
% else
% allAvg_apd30(end+1) = avg_apd30;
% allAvg_apd50(end+1) = avg_apd50;
% allAvg_apd90(end+1) = avg_apd90;
% allstd_apd30(end+1) = std_apd30;
% allstd_apd50(end+1) = std_apd50;
% allstd_apd90(end+1) = std_apd90;
% allAvg_cAPD30(end+1) = avg_cAPD30;
% allAvg_cAPD50(end+1) = avg_cAPD50;
% allAvg_cAPD90(end+1) = avg_cAPD90;
% allstd_cAPD30(end+1) = std_cAPD30;
% allstd_cAPD50(end+1) = std_cAPD50;
% allstd_cAPD90(end+1) = std_cAPD90;
% allTreatment(end+1) = Treatment;
% end
%
% end
%
% % % Plot all values
% figure('name',input('Give experiment title: '),'numbertitle','off');
%
% subplot(2,1,1);
% hold on;
% title('Uncorrected');
% xlabel(input('Provide x-axis: '));
% ylabel('Duration (ms)');
% xlim([-1 inf])
% errorbar (allTreatment , allAvg_apd50 , allstd_apd50 , allstd_apd50, 'o', ...
% 'Color', 'b', ...
% 'MarkerFaceColor' , 'b' , ...
% 'MarkerEdgeColor' , 'b'); %plotting details
% % % 'LineWidth' , 2 , ...
% choice = questdlg('Would you like to plot in logx?','XAxis Modification', ...
% 'Yes Please','No Thank You','No Thank You');
%
% if (strcmp(choice,'Yes Please'))
% set(gca,'xscale','log');
% end
%
% errorbar (allTreatment , allAvg_apd90 , allstd_apd90 , allstd_apd90, 'o', ...
% 'Color', 'r', ...
% 'MarkerFaceColor' , 'r' , ...
% 'MarkerEdgeColor' , 'r'); %plotting details
% % % 'LineWidth' , 2 , ...
% errorbar (allTreatment , allAvg_apd30 , allstd_apd30 , allstd_apd30, 'o', ...
% 'Color', 'g', ...
% 'MarkerFaceColor' , 'g' , ...
% 'MarkerEdgeColor' , 'g'); %plotting details
% % % 'LineWidth' , 2 , ...
% legend('APD 50' , 'APD 90' , 'APD 30','Location' , 'best');
%
% subplot(2,1,2);
% hold on;
% title('Corrected');
% xlabel(input('Provide x-axis: '));
% ylabel('Duration (ms)');
% xlim([-1 inf])
% errorbar (allTreatment , allAvg_cAPD50 , allstd_cAPD50 , allstd_cAPD50, 'o', ...
% 'Color', 'b', ...
% 'MarkerFaceColor' , 'b' , ...
% 'MarkerEdgeColor' , 'b'); %plotting details
% % % 'LineWidth' , 2 , ...
% choice = questdlg('Would you like to plot in logx?','XAxis Modification', ...
% 'Yes Please','No Thank You','No Thank You');
%
% if (strcmp(choice,'Yes Please'))
% set(gca,'xscale','log');
% end
% errorbar (allTreatment , allAvg_cAPD90 , allstd_cAPD90 , allstd_cAPD90, 'o', ...
% 'Color', 'r', ...
% 'MarkerFaceColor' , 'r' , ...
% 'MarkerEdgeColor' , 'r'); %plotting details
% % % 'LineWidth' , 2 , ...
% errorbar (allTreatment , allAvg_cAPD30 , allstd_cAPD30 , allstd_cAPD30, 'o', ...
% 'Color', 'g', ...
% 'MarkerFaceColor' , 'g' , ...
% 'MarkerEdgeColor' , 'g'); %plotting details
% % % 'LineWidth' , 2 , ...
% legend('cAPD 50' , 'cAPD 90' , 'cAPD 30' ,'Location' , 'best');
%
%
% % write something here to save everything!
end