forked from bdgrier/whole-cell-data-analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexportGUI.m
263 lines (233 loc) · 10.3 KB
/
exportGUI.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
function exportGUI
%% initialize variables
% export parameters
exportGroup = 'Amplitude';
numEvents = 200;
freqChoice = 'From first N events';
eventsChoice = 'Exactly N events';
riseStartValue = 10; % start of average trace rise measurement
riseEndValue = 90; % end of average trace rise measurement
decayStartValue = 80; % start of average trace rise measurement
decayEndValue = 20; % end of average trace rise measurement
nameMatch = '';
%% initialize export GUI
% create and position main panel
mainPanel = uifigure;
mainPanelWidth = mainPanel.Position(3);
mainPanelHeight = mainPanel.Position(4);
% radio button group for export group selection
exportGroupHeight = 0.2*mainPanelHeight;
exportGroupWidth = 0.2*mainPanelWidth;
exportGroupCheck = uibuttongroup('Parent',mainPanel,...
'Title','Group to Export',...
'SelectionChangedFcn',@exportGroupChange,...
'Position',[mainPanelWidth*0.15-(exportGroupWidth/2) mainPanelHeight*0.675 exportGroupWidth exportGroupHeight]);
uiradiobutton('Parent',exportGroupCheck,...
'Text','Full event',...
'Position',[10 0.55*exportGroupHeight 100 15]);
uiradiobutton('Parent',exportGroupCheck,...
'Text','Amplitude',...
'Position',[10 0.3*exportGroupHeight 100 15],...
'Value',true);
uiradiobutton('Parent',exportGroupCheck,...
'Text','Frequency',...
'Position',[10 0.05*exportGroupHeight 100 15]);
% labels and fields defining event number limits
numEeventsHeight = 0.2*mainPanelHeight;
numEventsWidth = 0.25*mainPanelWidth;
numEventsCheck = uibuttongroup('Parent',mainPanel,...
'Title','Event # Limits',...
'SelectionChangedFcn',@eventsChange,...
'Position',[mainPanelWidth*0.45-(numEventsWidth/2) mainPanelHeight*0.675 numEventsWidth numEeventsHeight]);
uiradiobutton('Parent',numEventsCheck,...
'Text','Exactly N events',...
'Position',[10 0.425*numEeventsHeight 150 15]);
uiradiobutton('Parent',numEventsCheck,...
'Text','Up to N events',...
'Position',[10 0.1*numEeventsHeight 150 15]);
% radio button group for frequency calculation preference
freqpPrefHeight = 0.2*mainPanelHeight;
freqPrefWidth = 0.3*mainPanelWidth;
freqPrefCheck = uibuttongroup('Parent',mainPanel,...
'Title','Frequency Calculation',...
'SelectionChangedFcn',@freqPrefChange,...
'Position',[mainPanelWidth*0.8-(freqPrefWidth/2) mainPanelHeight*0.675 freqPrefWidth freqpPrefHeight]);
uiradiobutton('Parent',freqPrefCheck,...
'Text','From first N events',...
'Position',[10 0.425*freqpPrefHeight 150 15]);
uiradiobutton('Parent',freqPrefCheck,...
'Text','From all events',...
'Position',[10 0.1*freqpPrefHeight 150 15]);
% labels and fields relating to the number of events to export
uilabel('Parent',mainPanel,...
'Text','Number of Events (N)',...
'fontweight', 'bold',...
'HorizontalAlignment','Center',...
'Position',[mainPanelWidth*0.20-(150/2) mainPanelHeight*0.55 150 20]);
exportNumField = uieditfield(mainPanel,...
'numeric',...
'Value',numEvents,...
'ValueChangedFcn',@numEventsUpdate,...
'Position',[mainPanelWidth*0.35-(30/2) mainPanelHeight*0.55 30 20],...
'HorizontalAlignment','Center');
% string field for file name match
uilabel('Parent',mainPanel,...
'Text','Export file names that include',...
'fontweight', 'bold',...
'HorizontalAlignment','Center',...
'Position',[mainPanelWidth*0.62-(175/2) mainPanelHeight*0.55 175 20]);
nameMatchField = uieditfield(mainPanel,...
'text',...
'Value','',...
'ValueChangedFcn',@nameMatchUpdate,...
'Position',[mainPanelWidth*0.85-(75/2) mainPanelHeight*0.55 75 20],...
'HorizontalAlignment','Center');
% average trace rise measurement preferences
uilabel('Parent',mainPanel,...
'Text','Average Trace',...
'fontweight', 'bold',...
'HorizontalAlignment','Center',...
'Position',[mainPanelWidth*0.333-(200/2) mainPanelHeight*0.42 200 20]);
uilabel('Parent',mainPanel,...
'Text','Rise Measurement',...
'fontweight', 'bold',...
'HorizontalAlignment','Center',...
'Position',[mainPanelWidth*0.333-(200/2) mainPanelHeight*0.38 200 20]);
riseStartField = uieditfield(mainPanel,...
'numeric',...
'Value',riseStartValue,...
'ValueChangedFcn',@averageTraceMeasurementUpdate,...
'Position',[mainPanelWidth*0.376-(30/2) mainPanelHeight*0.32 30 20],...
'HorizontalAlignment','Center');
uilabel('Parent',mainPanel,...
'Text','Begin %',...
'fontweight', 'bold',...
'HorizontalAlignment','Center',...
'Position',[mainPanelWidth*0.296-(50/2) mainPanelHeight*0.32 60 20]);
riseEndField = uieditfield(mainPanel,...
'numeric',...
'Value',riseEndValue,...
'ValueChangedFcn',@averageTraceMeasurementUpdate,...
'Position',[mainPanelWidth*0.376-(30/2) mainPanelHeight*0.26 30 20],...
'HorizontalAlignment','Center');
uilabel('Parent',mainPanel,...
'Text','End %',...
'fontweight', 'bold',...
'HorizontalAlignment','Center',...
'Position',[mainPanelWidth*0.296-(50/2) mainPanelHeight*0.26 50 20]);
% average trace decay measurement preferences
uilabel('Parent',mainPanel,...
'Text','Average Trace',...
'fontweight', 'bold',...
'HorizontalAlignment','Center',...
'Position',[mainPanelWidth*0.667-(225/2) mainPanelHeight*0.42 225 20]);
uilabel('Parent',mainPanel,...
'Text','Decay Measurement',...
'fontweight', 'bold',...
'HorizontalAlignment','Center',...
'Position',[mainPanelWidth*0.667-(225/2) mainPanelHeight*0.38 225 20]);
decayStartField = uieditfield(mainPanel,...
'numeric',...
'Value',decayStartValue,...
'ValueChangedFcn',@averageTraceMeasurementUpdate,...
'Position',[mainPanelWidth*0.71-(30/2) mainPanelHeight*0.32 30 20],...
'HorizontalAlignment','Center');
uilabel('Parent',mainPanel,...
'Text','Begin %',...
'fontweight', 'bold',...
'HorizontalAlignment','Center',...
'Position',[mainPanelWidth*0.63-(50/2) mainPanelHeight*0.32 60 20]);
decayEndField = uieditfield(mainPanel,...
'numeric',...
'Value',decayEndValue,...
'ValueChangedFcn',@averageTraceMeasurementUpdate,...
'Position',[mainPanelWidth*0.71-(30/2) mainPanelHeight*0.26 30 20],...
'HorizontalAlignment','Center');
uilabel('Parent',mainPanel,...
'Text','End %',...
'fontweight', 'bold',...
'HorizontalAlignment','Center',...
'Position',[mainPanelWidth*0.63-(50/2) mainPanelHeight*0.26 50 20]);
uibutton('Parent',mainPanel,...
'Text',sprintf('%s\n%s','Begin','Export'),...
'ButtonPushedFcn',@beginButton,...
'fontweight', 'bold',...
'Position',[mainPanelWidth*0.2-(100/2) mainPanelHeight*0.1 100 40]);
uibutton('Parent',mainPanel,...
'Text','Exit',...
'ButtonPushedFcn',@exitButton,...
'fontweight', 'bold',...
'Position',[mainPanelWidth*0.8-(100/2) mainPanelHeight*0.1 100 40]);
%% wait for user input
uiwait(mainPanel);
%% export functions
function beginButton(~,~)
switch exportGroup
case 'Amplitude'
exportGroup = 'amplitude';
case 'Full Event'
exportGroup = 'full';
end
switch freqChoice
case 'From first N events'
freqChoice = 'limited';
case 'From all events'
freqChoice = 'all';
end
switch eventsChoice
case 'Exactly N events'
eventsChoice = 'exactly';
case 'Up to N events'
eventsChoice = 'all';
end
args = {...
'exportedGroup',exportGroup,...
'frequencyCalculation',freqChoice,...
'numberOfEvents',numEvents,...
'eventLimit',eventsChoice,...
'riseLimits',[riseStartValue riseEndValue],...
'decayLimits',[decayStartValue decayEndValue],...
'match',nameMatch};
[OrganizedData, RawDataMatrix_AllCells, RawDataTable_AllCells, AverageTrace_AllCells]...
= exportFromFile(args{:});
% export variables to workspace
assignin('base','AverageTrace_AllCells',AverageTrace_AllCells);
assignin('base','OrganizedData',OrganizedData);
assignin('base','RawDataMatrix_AllCells',RawDataMatrix_AllCells);
assignin('base','RawDataTable_AllCells',RawDataTable_AllCells);
message = 'Export completed.';
uialert(mainPanel,message,'','Icon','success');
end
function exitButton(~,~)
% exit the GUI
delete(mainPanel);
end
function exportGroupChange(~,event)
% changes which group is auto-exported
exportGroup = event.NewValue.Text;
end
function freqPrefChange(~,event)
% changes how frequency is calculated during export
freqChoice = event.NewValue.Text;
end
function eventsChange(~,event)
% changes the limits on event numbers
eventsChoice = event.NewValue.Text;
end
function numEventsUpdate(~,~)
% changes how many events are exported
numEvents = exportNumField.Value;
end
function nameMatchUpdate(~,~)
% string to match in file names
nameMatch = nameMatchField.Value;
end
function averageTraceMeasurementUpdate(~,~)
% changes the start and end values for average trace kinetics
% measurements
riseStartValue = riseStartField.Value;
riseEndValue = riseEndField.Value;
decayStartValue = decayStartField.Value;
decayEndValue = decayEndField.Value;
end
end