/
KdSimGUI.m
563 lines (438 loc) · 23.2 KB
/
KdSimGUI.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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
function varargout = KdSimGUI(varargin)
% KDSIMGUI MATLAB code for KdSimGUI.fig
% KdSimGUI is a GUI to assisst the user in generating simuated
% cellular volume change data. For details, please see the original
% paper.
% Last Modified by GUIDE v2.5 23-Mar-2017 20:34:11
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @KdSimGUI_OpeningFcn, ...
'gui_OutputFcn', @KdSimGUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before KdSimGUI is made visible.
function KdSimGUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to KdSimGUI (see VARARGIN)
% Choose default command line output for KdSimGUI
handles.output = hObject;
%----------------------------------------------
% define the experimental results to compare to:
%-----------------------------------------------
%volume changes (V_f calculated from V_total in this case)
handles.dV_exp=1-((1-[1.25 1.07 1 0.92 0.83 0.74])./.7);
% AcGFP1 mCherry dataset
handles.dG_exp = [0.15612 0.02111 0 -0.02719 -0.03498 -0.09905];
handles.dR_exp =[-0.08422 -0.02823 0 0.03719 0.10335 0.15899];
% GAPDH-PGK dataset
% handles.dG_exp= [0.03 0.001 0 -0.02 -0.03 -0.06];
% handles.dR_exp= [-0.04 -0.02 0 0.02 0.1 0.15];
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes KdSimGUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = KdSimGUI_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
%---------------------------------
% Executes on pushing the "run" button
%----------------------------------
set(hObject,'BackgroundColor','r');
pause(0.1);
V_choice=handles.dV_exp;
n_V=size(V_choice,2);
n_runs=str2double(get(handles.simNo,'string'))*n_V;
k_on=str2double(get(handles.kon,'string'));
k_off=str2double(get(handles.koff,'string'));
set(handles.Kd,'string',num2str(k_off/k_on));
stoiA=str2double(get(handles.stoiA,'string'));
stoiB=str2double(get(handles.stoiB,'string'));
E_C=str2double(get(handles.E_C,'string'));
R_i=zeros(n_runs,1);
G_i=R_i;
dG=R_i;
dR=R_i;
dV=R_i;ks_on=R_i;ks_off=R_i;
A_i=R_i;B_i=R_i;C_i=R_i;
for i=1:n_runs
[A_in,B_in]=deal(-1);
while (A_in<0)
A_in = (str2double(get(handles.A_conc,'string'))*randn(1)+6)*1e-6; % A from experimental distribution (sigma=6)
end
while (B_in/A_in<0.5||B_in/A_in>2)
B_in = (str2double(get(handles.B_conc,'string'))*randn(1)+6)*1e-6; % A from experimental distribution (sigma=6)
end
dV_i = V_choice(mod(i,size(V_choice,2))+1)+randn()*0.01; % dV from experimental values
start=[A_in B_in 0 dV_i k_on k_off E_C stoiA stoiB]; % run_simpleKd input
[R_i(i,1),G_i(i,1),dR(i,1),dG(i,1),dF(i,1),dV(i,1),A_i(i,1),B_i(i,1),C_i(i,1),ks_on(i,1),ks_off(i,1)]=run_simpleKd(start);
end
% If you want to remove outliers (as defined by the deleteoutliers.m
% function). Currently disabled.
%[~,idx,~] = deleteoutliers(dR);
idx=[];
h1=scatter(handles.axes1,dV(setdiff(1:size(dR,1),idx)),dG(setdiff(1:size(dR,1),idx)),'markeredgecolor','black','linewidth',1,'markerfacecolor','green' );
hold on
% Uncomment these two to compare with Exp. results
% h1p2=line(handles.axes1,V_choice,handles.dG_exp,'linestyle','none','marker','o','markeredgecolor','black','markerfacecolor','blue','markersize',15);
% h1p3=line(handles.axes1,nanmean(reshape(dV,n_V,n_runs/n_V)',1),nanmean(reshape(dG,n_V,n_runs/n_V)',1),'linewidth',5,'linestyle','none','marker','s','markeredgecolor','black','markerfacecolor','none','markersize',15);
hold off
ylabel(handles.axes1,'\chi_{green}');
set(handles.axes1,'xticklabel','');
h2=scatter(handles.axes6,dV(setdiff(1:size(dR,1),idx)),dR(setdiff(1:size(dR,1),idx)),'markeredgecolor','black','linewidth',1,'markerfacecolor','red');
hold on
% Uncomment these two to compare with Exp. results
% h2p2=line(handles.axes6,V_choice,handles.dR_exp,'linestyle','none','marker','o','markeredgecolor','black','markerfacecolor','blue','markersize',15);
% h2p3=line(handles.axes6,nanmean(reshape(dV,n_V,n_runs/n_V)',1),nanmean(reshape(dR,n_V,n_runs/n_V)',1),'linewidth',5,'linestyle','none','marker','s','markeredgecolor','black','markerfacecolor','none','markersize',15);
hold off
ylabel(handles.axes6,'\chi_{red}');
set(handles.axes6,'xticklabel','');
h3=scatter(handles.axes7,dV,dF,'markeredgecolor','black','linewidth',1,'markerfacecolor',[1 0.6 0]);
set([handles.axes1,handles.axes6],'userdata',[R_i,G_i,dR,dG,dF,dV,A_i,B_i,C_i,ks_on,ks_off]);
ylabel(handles.axes7,'\chi_{FRET}');
xlabel(handles.axes7,'$\tilde{V}$','Interpreter','LaTex','FontSize',20);
set([h1,h2],'ButtonDownFcn',@plotPoint);
set(hObject,'BackgroundColor',[0.940000000000000 0.940000000000000 0.940000000000000])
function plotPoint(src,evntData)
%----------------------------------------
% plot point when clicked on either green or red
%----------------------------------------
ax = get(src,'Parent');
ax2 = findobj(gcf,'tag','axes2');
axG = findobj(gcf,'tag','axes3');
axR = findobj(gcf,'tag','axes5');
axF = findobj(gcf,'tag','axes4');
table = findobj(gcf,'tag','pointTable');
E_C = str2double(get(findobj(gcf,'tag','E_C'),'string'));
kon = str2double(get(findobj(gcf,'tag','kon'),'string'));
koff = str2double(get(findobj(gcf,'tag','koff'),'string'));
stoiA=str2double(get(findobj(gcf,'tag','stoiA'),'string'));
stoiB=str2double(get(findobj(gcf,'tag','stoiB'),'string'));
Cp = get(ax,'CurrentPoint');
allData = get(ax,'userdata');
X = get(src,'xdata');
Y = get(src,'ydata');
Xp = Cp(2,1); % X-point
Yp = Cp(2,2); % Y-point
[dp,Ip] = min((X-Xp).^2+(Y-Yp).^2);
% Extract the closest coordinate values
Xc = X(Ip);
Yc = Y(Ip);
Xpos = find((X-Xc)==0);
% Add some text
str1 = sprintf('\\leftarrow %i',Xpos);
ht(1) = text(Xp,Yp,str1,'Clipping','off');
set(ht,'FontSize',8,'Color','red')
point = (allData(Xpos,:)); %point = [R_i,G_i,dR,dG,dV,A_i,B_i,C_i,k_on,k_off]
start = [point(7),point(8),point(9),point(6),kon,koff,E_C,stoiA,stoiB]; %start = [A_i,B_i,C_i,dV,k_on,k_off]
[R_i,G_i,dR,dG,dF,dV,A_i,B_i,C_i,k_on,k_off,t,A,B,C,R,G,F] = run_simpleKd(start);
delete(findobj([ax2 axR axG axF],'type','line'));
t_ini=900;%9e2;
t_fin=size(t,1);%1500;
h1=line('xdata',t(t_ini:t_fin),'ydata',[A(t_ini:t_fin)],'marker','.','parent',ax2,'color','g');
h2=line('xdata',t(t_ini:t_fin),'ydata',[B(t_ini:t_fin)],'marker','.','parent',ax2,'color','r');
h3=line('xdata',t(t_ini:t_fin),'ydata',[C(t_ini:t_fin)],'marker','.','parent',ax2,'color','b');
title(ax2,'Concentrations')
legend(ax2,'donor','acceptor','complex')
ylabel(ax2,'c (\muM)')
xlabel(ax2,'t (s)')
assignin('base','simul',[t; A; B; C; G; R; F]');
h31=line('xdata',t(t_ini:t_fin),'ydata',[G(t_ini:t_fin)],'marker','.','parent',axG,'color','g');
title(axG,'Green emission')
ylabel(axG,'F_{green} (AU)')
xlabel(axG,'t (s)')
h32=line('xdata',t(t_ini:t_fin),'ydata',[R(t_ini:t_fin)],'marker','.','parent',axR,'color','r');
title(axR,'Red emission')
ylabel(axR,'F_{red} (AU)')
xlabel(axR,'t (s)')
h33=line('xdata',t(t_ini:t_fin),'ydata',F(t_ini:t_fin),'marker','.','parent',axF,'color','m');
title(axF,'FRET')
ylabel(axF,'E_F (AU)')
xlabel(axF,'t (s)')
tableData=[{point(6)} ;{A(1)} ;{B(1)} ;{point(3)} ;{point(4)}];
set(table,'data',tableData);
function kon_Callback(hObject, eventdata, handles)
% hObject handle to kon (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of kon as text
% str2double(get(hObject,'String')) returns contents of kon as a double
% --- Executes during object creation, after setting all properties.
function kon_CreateFcn(hObject, eventdata, handles)
% hObject handle to kon (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on key press with focus on kon and none of its controls.
function kon_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to kon (see GCBO)
% eventdata structure with the following fields (see UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
function koff_Callback(hObject, eventdata, handles)
% hObject handle to koff (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of koff as text
% str2double(get(hObject,'String')) returns contents of koff as a double
% --- Executes during object creation, after setting all properties.
function koff_CreateFcn(hObject, eventdata, handles)
% hObject handle to koff (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Kd_Callback(hObject, eventdata, handles)
% hObject handle to Kd (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Kd as text
% str2double(get(hObject,'String')) returns contents of Kd as a double
% --- Executes during object creation, after setting all properties.
function Kd_CreateFcn(hObject, eventdata, handles)
% hObject handle to Kd (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on key press with focus on pushbutton1 and none of its controls.
function pushbutton1_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata structure with the following fields (see UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
function simNo_Callback(hObject, eventdata, handles)
% hObject handle to simNo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of simNo as text
% str2double(get(hObject,'String')) returns contents of simNo as a double
% --- Executes during object creation, after setting all properties.
function simNo_CreateFcn(hObject, eventdata, handles)
% hObject handle to simNo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on mouse press over axes background.
function axes1_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to axes1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function E_C_Callback(hObject, eventdata, handles)
% hObject handle to E_C (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of E_C as text
% str2double(get(hObject,'String')) returns contents of E_C as a double
% --- Executes during object creation, after setting all properties.
function E_C_CreateFcn(hObject, eventdata, handles)
% hObject handle to E_C (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function A_conc_Callback(hObject, eventdata, handles)
% hObject handle to A_conc (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of A_conc as text
% str2double(get(hObject,'String')) returns contents of A_conc as a double
% --- Executes during object creation, after setting all properties.
function A_conc_CreateFcn(hObject, eventdata, handles)
% hObject handle to A_conc (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function B_conc_Callback(hObject, eventdata, handles)
% hObject handle to B_conc (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of B_conc as text
% str2double(get(hObject,'String')) returns contents of B_conc as a double
% --- Executes during object creation, after setting all properties.
function B_conc_CreateFcn(hObject, eventdata, handles)
% hObject handle to B_conc (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in copyClp.
function copyClp_Callback(hObject, eventdata, handles)
%----------------------------------------
% Executes on "Copy data" button press
% copies all points in chi_red, chi_green, and chi_FRET to clipboard.
% format is [A_i B_i dV chi_G chi_R] for all volume changes.
% First two rows are AVG and SD of the data.
%----------------------------------------
set(hObject,'BackgroundColor','r')
pause(0.2);
format long;
allData=get(handles.axes1,'userdata');
selData=[allData(:,7),allData(:,8),allData(:,6) allData(:,5) allData(:,4) allData(:,3)]; %dV, dF, dG, dR
A_i=circshift(reshape(selData(:,1)',6,size(selData,1)/6)',[0 1]);
B_i=circshift(reshape(selData(:,2)',6,size(selData,1)/6)',[0 1]);
dV=circshift(reshape(selData(:,3)',6,size(selData,1)/6)',[0 1])-1;
dF=circshift(reshape(selData(:,4)',6,size(selData,1)/6)',[0 1]);
dG=circshift(reshape(selData(:,5)',6,size(selData,1)/6)',[0 1]);
dR=circshift(reshape(selData(:,6)',6,size(selData,1)/6)',[0 1]);
finalDataWorkspace=[dV(:,1) dG(:,1) dR(:,1); dV(:,2) dG(:,2) dR(:,2); dV(:,3) dG(:,3) dR(:,3); dV(:,4) dG(:,4) dR(:,4); dV(:,5) dG(:,5) dR(:,5) ;dV(:,6) dG(:,6) dR(:,6)];
finalData=[dV(:,1) dG(:,1) dR(:,1) dV(:,2) dG(:,2) dR(:,2) dV(:,3) dG(:,3) dR(:,3) dV(:,4) dG(:,4) dR(:,4) dV(:,5) dG(:,5) dR(:,5) dV(:,6) dG(:,6) dR(:,6)];
finalConc=[A_i(:,1) B_i(:,1) A_i(:,2) B_i(:,2) A_i(:,3) B_i(:,3) A_i(:,4) B_i(:,4) A_i(:,5) B_i(:,5) A_i(:,6) B_i(:,6)];
meanConc=reshape(mean(finalConc,'omitnan'),2,6)';
stdConc=reshape(std(finalConc,'omitnan'),2,6)';
meanData=reshape(mean(finalData,'omitnan'),3,6)';
stdData=reshape(std(finalData,'omitnan'),3,6)';
clipData=[meanConc(:,1) stdConc(:,1) meanConc(:,2) stdConc(:,2) meanData(:,1),stdData(:,1),meanData(:,2),stdData(:,2),meanData(:,3),stdData(:,3)];
assignin('base','allData',finalDataWorkspace);
mat2clip(finalDataWorkspace);
set(hObject,'BackgroundColor',[0.940000000000000 0.940000000000000 0.940000000000000])
% hObject handle to copyClp (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over copyClp.
function copyClp_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to copyClp (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in FitInit.
function FitInit_Callback(hObject, eventdata, handles)
%----------------------------------------
% Executes on "Fit" button press
% Executes a short minimization procedure using sseRun_simpleKd. Exp.
% values (dV_exp, dG_Exp, dR_exp) defined at gui startup.
%----------------------------------------
set(hObject,'BackgroundColor','r')
pause(0.5);
k_on=str2double(get(handles.kon,'string'));
k_off=str2double(get(handles.koff,'string'));
set(handles.Kd,'string',num2str(k_off/k_on));
stoiA=str2double(get(handles.stoiA,'string'));
stoiB=str2double(get(handles.stoiB,'string'));
E_C=str2double(get(handles.E_C,'string'));
A_in = str2double(get(handles.A_conc,'string'));
B_in = str2double(get(handles.B_conc,'string'));
x0 = log10(k_on);
lb=(0.5*x0);
ub=(1.2*x0);
opts = optimoptions(@fmincon,'Algorithm','interior-point','display','none');
start=[A_in B_in 0 0 k_on k_off E_C stoiA stoiB];
X=fmincon(@(x)sseRun_simpleKd(x,start,handles.dV_exp,handles.dR_exp,handles.dG_exp),x0,[],[],[],[],lb,ub,[],opts);
set(handles.kon,'String',num2str(10^X,'%2.2e'));
set(hObject,'BackgroundColor',[0.940000000000000 0.940000000000000 0.940000000000000])
function getAvg_Callback(hObject, eventdata, handles)
%----------------------------------------
% Executes on "Averages" button press
% Copy average and SD of the time trace for red, green and FRET
% fluorescence for all points to clipboard
%----------------------------------------
set(hObject,'BackgroundColor','r')
pause(0.5);
allData=get(handles.axes1,'userdata');
E_C = str2double(get(findobj(gcf,'tag','E_C'),'string'));
kon = str2double(get(findobj(gcf,'tag','kon'),'string'));
koff = str2double(get(findobj(gcf,'tag','koff'),'string'));
stoiA=str2double(get(findobj(gcf,'tag','stoiA'),'string'));
stoiB=str2double(get(findobj(gcf,'tag','stoiB'),'string'));
point = (allData(1,:)); %point = [R_i,G_i,dR,dG,dV,A_i,B_i,C_i,k_on,k_off]
start = [point(7),point(8),point(9),point(6),kon,koff,E_C,stoiA,stoiB]; %start = [A_i,B_i,C_i,dV,k_on,k_off]
[R_i,G_i,dR,dG,dF,dV,A_i,B_i,C_i,k_on,k_off,t] = run_simpleKd(start);
t_size=size(t,1);
R_raw=zeros(size(allData,1)/6,t_size,6);
G_raw=R_raw;
F_raw=R_raw;
for ii=1:size(allData,1)
point = (allData(ii,:)); %point = [R_i,G_i,dR,dG,dV,A_i,B_i,C_i,k_on,k_off]
start = [point(7),point(8),point(9),point(6),kon,koff,E_C,stoiA,stoiB]; %start = [A_i,B_i,C_i,dV,k_on,k_off]
[R_i,G_i,dR,dG,dF,dV,A_i,B_i,C_i,k_on,k_off,t,A,B,C,R_raw(ceil(ii/6),:,mod(ii,6)+1),G_raw(ceil(ii/6),:,mod(ii,6)+1),F_raw(ceil(ii/6),:,mod(ii,6)+1)] = run_simpleKd(start);
end
R_norm=R_raw./repmat(R_raw(:,round((t_size-2)/2),:),1,t_size,1);
G_norm=G_raw./repmat(G_raw(:,round((t_size-2)/2),:),1,t_size,1);
F_norm=F_raw./repmat(F_raw(:,round((t_size-2)/2),:),1,t_size,1);
for ii=1:size(R_norm,3)
R_normMean(:,2*ii-1:2*ii)=[mean(squeeze(R_norm(:,:,ii)'),2,'omitnan') std(squeeze(R_norm(:,:,ii)'),0,2,'omitnan')];
G_normMean(:,2*ii-1:2*ii)=[mean(squeeze(G_norm(:,:,ii)'),2,'omitnan') std(squeeze(G_norm(:,:,ii)'),0,2,'omitnan')];
F_normMean(:,2*ii-1:2*ii)=[mean(squeeze(F_norm(:,:,ii)'),2,'omitnan') std(squeeze(F_norm(:,:,ii)'),0,2,'omitnan')];
end
mat2clip([t R_normMean(1:t_size,:) G_normMean(1:t_size,:) F_normMean(1:t_size,:)]);
set(hObject,'BackgroundColor',[0.940000000000000 0.940000000000000 0.940000000000000])
function stoiA_Callback(hObject, eventdata, handles)
% hObject handle to stoiA (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of stoiA as text
% str2double(get(hObject,'String')) returns contents of stoiA as a double
% --- Executes during object creation, after setting all properties.
function stoiA_CreateFcn(hObject, eventdata, handles)
% hObject handle to stoiA (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function stoiB_Callback(hObject, eventdata, handles)
% hObject handle to stoiB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of stoiB as text
% str2double(get(hObject,'String')) returns contents of stoiB as a double
% --- Executes during object creation, after setting all properties.
function stoiB_CreateFcn(hObject, eventdata, handles)
% hObject handle to stoiB (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end