-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGUI.m
More file actions
1297 lines (1009 loc) · 53.3 KB
/
GUI.m
File metadata and controls
1297 lines (1009 loc) · 53.3 KB
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
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function varargout = GUI(varargin)
% GUI MATLAB code for GUI.fig
% GUI, by itself, creates a new GUI or raises the existing
% singleton*.
%
% H = GUI returns the handle to a new GUI or the handle to
% the existing singleton*.
%
% GUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI.M with the given input arguments.
%
% GUI('Property','Value',...) creates a new GUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before GUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to GUI_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help GUI
% Last Modified by GUIDE v2.5 21-Nov-2018 10:42:31
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @GUI_OpeningFcn, ...
'gui_OutputFcn', @GUI_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 GUI is made visible.
function GUI_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 GUI (see VARARGIN)
% Choose default command line output for GUI
handles.output = hObject;
% Update handles structure
set(handles.pattern_panel, 'SelectionChangeFcn', @pattern_panel_SelectionChangeFcn);
set(handles.bleach_corr_check, 'Value', 1);
UpdatePinholeGraph(handles)
pattern_data_nr_Callback(hObject, eventdata, handles)
handles = guidata(hObject);
guidata(hObject, handles);
switch handles.pattern_panel.SelectedObject.String
case 'Microlenses'
handles.expected_period = str2double(handles.ulens_period_edit.String);
case 'Widefield'
handles.expected_period = str2double(handles.wf_period_edit.String);
end
addpath(genpath('../PR_Reconstruction'))
guidata(hObject, handles);
% UIWAIT makes GUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = GUI_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;
function pattern_panel_SelectionChangeFcn(hObject, eventdata)
handles = guidata(hObject);
switch get(eventdata.NewValue, 'Tag' )
case 'radio_ulens'
handles.expected_period = str2double(handles.ulens_period_edit.String);
case 'radio_wf'
handles.expected_period = str2double(handles.wf_period_edit.String);
end
update_pattern_id_im(hObject, handles)
handles = guidata(hObject); %Get updated version of handles
guidata(hObject, handles)
function data_edit_Callback(hObject, eventdata, handles)
% hObject handle to data_edit (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 data_edit as text
% str2double(get(hObject,'String')) returns contents of data_edit as a double
% --- Executes during object creation, after setting all properties.
function data_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to data_edit (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 widefield_edit_Callback(hObject, eventdata, handles)
% hObject handle to widefield_edit (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 widefield_edit as text
% str2double(get(hObject,'String')) returns contents of widefield_edit as a double
% --- Executes during object creation, after setting all properties.
function widefield_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to widefield_edit (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 pattern_edit_Callback(hObject, eventdata, handles)
% hObject handle to pattern_edit (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 pattern_edit as text
% str2double(get(hObject,'String')) returns contents of pattern_edit as a double
% --- Executes during object creation, after setting all properties.
function pattern_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to pattern_edit (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 widefield_edit.
function Load_widefield_Callback(hObject, eventdata, handles)
% hObject handle to widefield_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[LoadFileName,LoadPathName] = uigetfile({'*.*'}, 'Load data file');
filepath = strcat(LoadPathName, LoadFileName);
handles.widefield_edit.String = filepath;
wf_data = load_image_stack(filepath);
wf_im = mean(wf_data, 3);
handles.wf_im = wf_im;
guidata(hObject, handles)
axes(handles.wf_axis);
imshow(wf_im, []);
% --- Executes on button press in Load_data.
function Load_data_Callback(hObject, eventdata, handles)
% hObject handle to Load_data (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[LoadFileName,LoadPathName] = uigetfile({'*.*'}, 'Load data file');
filepath = strcat(LoadPathName, LoadFileName);
handles.data_edit.String = filepath;
spl = strsplit(filepath, '.');
if strcmp(spl{end}, 'hdf5')
cropping_data = get_cropping_data(filepath);
handles.cropping_data = cropping_data;
end
h = msgbox('This could be a second. Patience...','Importing data','help');
child = get(h,'Children');
delete(child(3))
raw_data = load_image_stack(filepath);
close(h)
i_nr = str2double(handles.Interleaved_nr_edit.String);
for i = 1:i_nr
data{i} = raw_data(:,:,i:i_nr:end);
if round(sqrt(size(data{i}, 3))) ~= sqrt(size(data{i}, 3))
waitfor(msgbox('Wrong number of frames, check data or interleaved data settings', 'Warning'));
return
end
end
%corrected_raw_data = frame_correction(raw_data);
handles.raw_data = data;
handles.rotated_text.String = '';
set(handles.rotate_data_button,'Enable','on');
update_pattern_id_im(hObject, handles)
close(h)
handles = guidata(hObject);%Get updated version of handles
guidata(hObject, handles)
% --- Executes on button press in Load_pattern.
function Load_pattern_Callback(hObject, eventdata, handles)
% hObject handle to Load_pattern (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[LoadFileName,LoadPathName] = uigetfile({'*.*'}, 'Load data file');
filepath = strcat(LoadPathName, LoadFileName);
handles.pattern_edit.String = filepath;
pattern_data = load_image_stack(filepath);
pattern_im = mean(pattern_data, 3);
handles.pattern_im = pattern_im;
update_pattern_id_im(hObject, handles)
handles = guidata(hObject); %Get updated version of handles (necessary?)
guidata(hObject, handles)
% --- Executes on button press in Load_HPCmap.
function Load_HPCmap_Callback(hObject, eventdata, handles)
% hObject handle to Load_HPCmap (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[LoadFileName,LoadPathName] = uigetfile({'*.*'}, 'Load data file');
filepath = strcat(LoadPathName, LoadFileName);
handles.HPCedit.String = filepath;
HPC_im = load_image(filepath);
handles.HPC_im = HPC_im;
% handles = guidata(hObject); %Get updated version of handles
guidata(hObject, handles)
% --- Executes on button press in HPCcorrbox.
function HPCcorrbox_Callback(hObject, eventdata, handles)
% hObject handle to HPCcorrbox (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of HPCcorrbox
update_pattern_id_im(hObject, handles)
handles = guidata(hObject); %Get updated version of handles
guidata(hObject, handles)
% --- Executes on button press in run_reconstruction.
function run_reconstruction_Callback(hObject, eventdata, handles)
% hObject handle to run_reconstruction (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
run_reconstruction(hObject, eventdata, handles, handles.active_data_set);
% --- Executes on button press in find_pattern.
function find_pattern_Callback(hObject, eventdata, handles)
% hObject handle to find_pattern (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
find_pattern(hObject, eventdata, handles, 'auto')
handles = guidata(hObject); %Get updated version of handles
Update_pattern_edits_fr_handles(hObject, eventdata, handles)
Show_pattern(hObject, eventdata, handles)
% --- Executes on button press in find_pat_man.
function find_pat_man_Callback(hObject, eventdata, handles)
% hObject handle to find_pat_man (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
find_pattern(hObject, eventdata, handles, 'man')
handles = guidata(hObject); %Get updated version of handles
Update_pattern_edits_fr_handles(hObject, eventdata, handles)
Show_pattern(hObject, eventdata, handles)
function ulens_period_edit_Callback(hObject, eventdata, handles)
% hObject handle to ulens_period_edit (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 ulens_period_edit as text
% str2double(get(hObject,'String')) returns contents of ulens_period_edit as a double
UpdatePinholeGraph(handles)
% --- Executes during object creation, after setting all properties.
function ulens_period_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to ulens_period_edit (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 wf_period_edit_Callback(hObject, eventdata, handles)
% hObject handle to wf_period_edit (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 wf_period_edit as text
% str2double(get(hObject,'String')) returns contents of wf_period_edit as a double
% --- Executes during object creation, after setting all properties.
function wf_period_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to wf_period_edit (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 pixel_size_edit_Callback(hObject, eventdata, handles)
% hObject handle to pixel_size_edit (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 pixel_size_edit as text
% str2double(get(hObject,'String')) returns contents of pixel_size_edit as a double
% --- Executes during object creation, after setting all properties.
function pixel_size_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to pixel_size_edit (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 pinhole_edit_Callback(hObject, eventdata, handles)
% hObject handle to pinhole_edit (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 pinhole_edit as text
% str2double(get(hObject,'String')) returns contents of pinhole_edit as a double
UpdatePinholeGraph(handles)
% --- Executes during object creation, after setting all properties.
function pinhole_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to pinhole_edit (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 slider movement.
function slider_Callback(hObject, eventdata, handles)
% hObject handle to slider (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
sliderValue = get(handles.slider,'Value');
set(handles.bg_sub_edit,'String', num2str(sliderValue))
handles = guidata(hObject);
update_recon_im(hObject, handles);
handles = guidata(hObject);
update_recon_axis(hObject, handles);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function slider_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function bg_sub_edit_Callback(hObject, eventdata, handles)
% hObject handle to bg_sub_edit (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 bg_sub_edit as text
% str2double(get(hObject,'String')) returns contents of bg_sub_edit as a double
editValue = get(handles.bg_sub_edit,'String')
set(handles.slider,'Value', str2double(editValue))
update_recon_im(hObject, handles);
handles = guidata(hObject);
update_recon_axis(hObject, handles);
handles = guidata(hObject);
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function bg_sub_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to bg_sub_edit (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 bleach_corr_check.
function bleach_corr_check_Callback(hObject, eventdata, handles)
% hObject handle to bleach_corr_check (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of bleach_corr_check
% --- Executes on selection change in bleach_corr_dropdown.
function bleach_corr_dropdown_Callback(hObject, eventdata, handles)
% hObject handle to bleach_corr_dropdown (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns bleach_corr_dropdown contents as cell array
% contents{get(hObject,'Value')} returns selected item from bleach_corr_dropdown
% --- Executes during object creation, after setting all properties.
function bleach_corr_dropdown_CreateFcn(hObject, eventdata, handles)
% hObject handle to bleach_corr_dropdown (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 save_button.
function save_button_Callback(hObject, eventdata, handles)
% hObject handle to save_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
filepath = handles.data_edit.String;
slider_val = handles.slider.Value;
cent_g = str2double(handles.pinhole_edit.String);
bg_g = handles.BG_FWHM_check.Value * str2double(handles.BGFWHM_edit.String);
cb = handles.Const_bg_check.Value;
if isfield(handles, 'wf_im')
save_image(handles.showing_im, slider_val, cent_g, bg_g, cb, filepath, 'tif', 'widefield', handles.wf_im);
else
save_image(handles.showing_im, slider_val, cent_g, bg_g, cb, filepath, 'tif');
end
% --- Executes on selection change in WF_recon_mode.
function WF_recon_mode_Callback(hObject, eventdata, handles)
% hObject handle to WF_recon_mode (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns WF_recon_mode contents as cell array
% contents{get(hObject,'Value')} returns selected item from WF_recon_mode
% --- Executes during object creation, after setting all properties.
function WF_recon_mode_CreateFcn(hObject, eventdata, handles)
% hObject handle to WF_recon_mode (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu 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 update_pattern_id_im(hObject, handles)
% hObject handle to WF_recon_mode (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
ads = handles.active_data_set;
if handles.radio_ulens.Value == 1 && isfield(handles, 'raw_data')
handles.pattern_id_im = mean(handles.raw_data{ads}, 3);
if handles.HPCcorrbox.Value && isfield(handles, 'HPC_im')
handles.pattern_id_im = handles.pattern_id_im - double(handles.HPC_im);
end
axes(handles.pattern_axis);
imshow(handles.pattern_id_im, []);
elseif handles.radio_wf.Value == 1 && isfield(handles, 'pattern_im') && isfield(handles, 'raw_data')
if handles.pattern_cropping_opt.Value == 2
handles.pattern_id_im = crop_image(handles.pattern_im, handles.cropping_data);
else
handles.pattern_id_im = handles.pattern_im;
end
axes(handles.pattern_axis);
imshow(handles.pattern_id_im, []);
end
guidata(hObject, handles);
% --- Executes on slider movement.
function low_lim_slider_Callback(hObject, eventdata, handles)
% hObject handle to low_lim_slider (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
update_recon_axis(hObject, handles);
% --- Executes during object creation, after setting all properties.
function low_lim_slider_CreateFcn(hObject, eventdata, handles)
% hObject handle to low_lim_slider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on slider movement.
function up_lim_slider_Callback(hObject, eventdata, handles)
% hObject handle to up_lim_slider (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,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
update_recon_axis(hObject, handles);
% --- Executes during object creation, after setting all properties.
function up_lim_slider_CreateFcn(hObject, eventdata, handles)
% hObject handle to up_lim_slider (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes on button press in chessb_corr_but_old.
function chessb_corr_but_old_Callback(hObject, eventdata, handles)
% hObject handle to chessb_corr_but_old (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
im = handles.showing_im;
square_side = sqrt(handles.nframes);
corrected = chessboard_correction_old(im, square_side);
handles.showing_im = corrected;
update_recon_axis(hObject, handles)
guidata(hObject, handles);
function ReconGaussSize_Callback(hObject, eventdata, handles)
% hObject handle to ReconGaussSize (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 ReconGaussSize as text
% str2double(get(hObject,'String')) returns contents of ReconGaussSize as a double
% --- Executes during object creation, after setting all properties.
function ReconGaussSize_CreateFcn(hObject, eventdata, handles)
% hObject handle to ReconGaussSize (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 Multi_frame_recon.
function Multi_frame_recon_Callback(hObject, eventdata, handles)
% hObject handle to Multi_frame_recon (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[fileNames, LoadDataPathName] = uigetfile('*.*','Select the files to reconstruct', 'MultiSelect', 'on');
file_indeces = 1:length(fileNames);
base_preset = [0 0 0];
base_preset(1) = str2double(handles.pinhole_edit.String) / str2double(handles.pixel_size_edit.String);
if handles.BG_FWHM_check.Value
base_preset(2) = str2double(handles.BGFWHM_edit.String) / str2double(handles.pixel_size_edit.String);
end
if handles.Const_bg_check.Value
base_preset(3) = 1;
end
data_sets = str2double(handles.Interleaved_nr_edit.String);
pattern = handles.pattern;
slider_val = handles.slider.Value;
for i = file_indeces
disp(strcat('Reconstructing: ', fileNames{i}));
filepath = strcat(LoadDataPathName, '\', fileNames{i});
raw_data = load_image_stack(filepath);
ssrot = str2double(handles.ssrot_edit.String);
for ads = 1:data_sets
raw_data_set = raw_data(:,:,ads:data_sets:end);
%corrected_raw_data = frame_correction(raw_data);
imsize = size(raw_data_set);
if handles.radio_ulens.Value() || handles.WF_recon_mode.Value == 2
dbl_lines = str2double(handles.dbl_lines_edit.String);
dbl_cols = str2double(handles.dbl_cols_edit.String);
flip_ss = handles.flip_subsq_cb.Value;
simp_pin = handles.simp_pin_cb.Value;
microlens_recon_alg(hObject, handles, raw_data_set, imsize, pattern, base_preset, ssrot, flip_ss, simp_pin, dbl_lines, dbl_cols)
handles = guidata(hObject); %Get updated version of handles (updated in microlens_recon_alg())
else
waitfor(msgbox('Widefield RESOLFT not up to date here', 'Oops..'));
% if handles.bleach_corr_check.Value
% data = bleaching_correction(corrected_raw_data, 'Additive');
% end
% camera_pixel = str2double(handles.pixel_size_edit.String);
% objp = 20 / camera_pixel;
% number_scanning_steps = sqrt(size(data,3)) - 1;
% shift_per_step = handles.expected_period / number_scanning_steps / camera_pixel;
% pinhole_size = str2double(handles.pinhole_edit.String);
% recon_gauss = str2double(handles.ReconGaussSize.String);
% if pinhole_size == recon_gauss
% [central_signal, bg_signal] = signal_extraction_fast(data, pattern, objp, shift_per_step, pinhole_size/camera_pixel);
% else
% [central_signal, bg_signal] = signal_extraction_STHLM2(data, pattern, objp, shift_per_step, pinhole_size/camera_pixel, recon_gauss/camera_pixel);
% end
% handles.central_signal = central_signal;
% handles.bg_signal = bg_signal;
end
if handles.noise_corr_check.Value
recon = (1-slider_val)*handles.central_signal_ncorr + slider_val*handles.bg_signal_ncorr;
else
recon = (1-slider_val)*handles.central_signal + slider_val*handles.bg_signal;
end
if i == 1
stacks{ads} = recon;
else
stacks{ads} = cat(3, stacks{ads}, recon);
end
end
end
skew_fac = str2double(handles.skew_fac_edit.String);
line_px = str2double(handles.line_px_edit.String);
lines_p_square = handles.fr_p_line;
for ads = 1:data_sets
if handles.hide_frame_cb.Value
stacks{ads} = stacks{ads}(handles.fr_p_column + 1:end - handles.fr_p_column, handles.fr_p_line + 1:end - handles.fr_p_line,:);
end
if handles.multi_f_cb.Value
stacks{ads} = chessboard_correction_multi_f(stacks{abs}, lines_p_square);
end
for i = 1:size(stacks{ads}, 3)
stacks{ads}(:,:,i) = Skew_stripe_corr(skew_fac, line_px, stacks{ads}(:,:,i), lines_p_square, handles.rotate_skewstripe_cb.Value);
end
end
cent_g = str2double(handles.pinhole_edit.String);
bg_g = str2double(handles.BGFWHM_edit.String);
cb = handles.Const_bg_check.Value;
for ads = 1:data_sets
save_image(stacks{ads}, slider_val, cent_g, bg_g, cb, filepath, 'hdf5')
end
handles = guidata(hObject); %Get updated version of handles (updated in update_recon_im())
guidata(hObject, handles);
function HPCedit_Callback(hObject, eventdata, handles)
% hObject handle to HPCedit (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 HPCedit as text
% str2double(get(hObject,'String')) returns contents of HPCedit as a double
% --- Executes during object creation, after setting all properties.
function HPCedit_CreateFcn(hObject, eventdata, handles)
% hObject handle to HPCedit (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 skew_fac_edit_Callback(hObject, eventdata, handles)
% hObject handle to skew_fac_edit (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 skew_fac_edit as text
% str2double(get(hObject,'String')) returns contents of skew_fac_edit as a double
% --- Executes during object creation, after setting all properties.
function skew_fac_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to skew_fac_edit (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 line_px_edit_Callback(hObject, eventdata, handles)
% hObject handle to line_px_edit (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 line_px_edit as text
% str2double(get(hObject,'String')) returns contents of line_px_edit as a double
% --- Executes during object creation, after setting all properties.
function line_px_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to line_px_edit (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 skew_stripe_corr.
function skew_stripe_corr_Callback(hObject, eventdata, handles)
% hObject handle to skew_stripe_corr (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
skew_fac = str2double(handles.skew_fac_edit.String);
line_px = str2double(handles.line_px_edit.String);
lines_p_square = handles.fr_p_line;
handles.showing_im = Skew_stripe_corr(skew_fac, line_px, handles.showing_im, lines_p_square, handles.rotate_skewstripe_cb.Value);
update_recon_axis(hObject, handles)
guidata(hObject, handles);
% --- Executes on button press in reset_corr_btn.
function reset_corr_btn_Callback(hObject, eventdata, handles)
% hObject handle to reset_corr_btn (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
update_recon_im(hObject, handles)
handles = guidata(hObject);
update_recon_axis(hObject, handles)
guidata(hObject, handles);
function dbl_lines_edit_Callback(hObject, eventdata, handles)
% hObject handle to dbl_lines_edit (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 dbl_lines_edit as text
% str2double(get(hObject,'String')) returns contents of dbl_lines_edit as a double
% --- Executes during object creation, after setting all properties.
function dbl_lines_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to dbl_lines_edit (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 dbl_cols_edit_Callback(hObject, eventdata, handles)
% hObject handle to dbl_cols_edit (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 dbl_cols_edit as text
% str2double(get(hObject,'String')) returns contents of dbl_cols_edit as a double
% --- Executes during object creation, after setting all properties.
function dbl_cols_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to dbl_cols_edit (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 BGFWHM_edit_Callback(hObject, ~, handles)
% hObject handle to BGFWHM_edit (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 BGFWHM_edit as text
% str2double(get(hObject,'String')) returns contents of BGFWHM_edit as a double
UpdatePinholeGraph(handles)
% --- Executes during object creation, after setting all properties.
function BGFWHM_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to BGFWHM_edit (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 BG_FWHM_check.
function BG_FWHM_check_Callback(hObject, eventdata, handles)
% hObject handle to BG_FWHM_check (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
UpdatePinholeGraph(handles)
% Hint: get(hObject,'Value') returns toggle state of BG_FWHM_check
% --- Executes on button press in Const_bg_check.
function Const_bg_check_Callback(hObject, eventdata, handles)
% hObject handle to Const_bg_check (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
UpdatePinholeGraph(handles)
% Hint: get(hObject,'Value') returns toggle state of Const_bg_check
% --- Executes on button press in Noise_corr_but.
function Noise_corr_but_Callback(hObject, eventdata, handles)
% hObject handle to Noise_corr_but (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[handles.central_signal handles.bg_signal] = Noise_corr(handles.central_signal, handles.bg_signal, handles.presets);
update_recon_im(hObject, handles)
handles = guidata(hObject);
update_recon_axis(hObject, handles)
Guidata(hObject, handles);
% --- Executes on button press in noise_corr_check.
function noise_corr_check_Callback(hObject, eventdata, handles)
% hObject handle to noise_corr_check (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of noise_corr_check
% --- Executes on button press in show_denoised_check.
function show_denoised_check_Callback(hObject, eventdata, handles)
% hObject handle to show_denoised_check (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of show_denoised_check
update_recon_im(hObject, handles);
handles = guidata(hObject);
update_recon_axis(hObject, handles);
handles = guidata(hObject);
guidata(hObject, handles);
function ssrot_edit_Callback(hObject, eventdata, handles)
% hObject handle to ssrot_edit (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 ssrot_edit as text
% str2double(get(hObject,'String')) returns contents of ssrot_edit as a double
% --- Executes during object creation, after setting all properties.
function ssrot_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to ssrot_edit (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 chessb_corr_but_new.
function chessb_corr_but_new_Callback(hObject, eventdata, handles)
% hObject handle to chessb_corr_but_new (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.working_text.String = 'Correcting chessboard...'
im = handles.showing_im;
im = im - min(im(:));
square_side = sqrt(handles.nframes);
if handles.Sequential_cc_cb.Value
corrected = chessboard_correction_pyramid(im, square_side);
else
corrected = chessboard_correction_LS(im, square_side);
end
handles.showing_im = corrected;
handles.working_text.String = 'Finished correcting chessboard'
update_recon_axis(hObject, handles)
guidata(hObject, handles);
% --- Executes on button press in rotate_skewstripe_cb.
function rotate_skewstripe_cb_Callback(hObject, eventdata, handles)
% hObject handle to rotate_skewstripe_cb (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of rotate_skewstripe_cb
% --- Executes on button press in flip_subsq_cb.
function flip_subsq_cb_Callback(hObject, eventdata, handles)
% hObject handle to flip_subsq_cb (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of flip_subsq_cb