-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathLFITv2_GUI_SinglePanel.m
1776 lines (1422 loc) · 69.8 KB
/
LFITv2_GUI_SinglePanel.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
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 = LFITv2_GUI_SinglePanel(varargin)
% LFITV2_GUI_SINGLEPANEL MATLAB code for LFITv2_GUI_SinglePanel.fig
% LFITV2_GUI_SINGLEPANEL, by itself, creates a new LFITV2_GUI_SINGLEPANEL or raises the existing
% singleton*.
%
% H = LFITV2_GUI_SINGLEPANEL returns the handle to a new LFITV2_GUI_SINGLEPANEL or the handle to
% the existing singleton*.
%
% LFITV2_GUI_SINGLEPANEL('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in LFITV2_GUI_SINGLEPANEL.M with the given input arguments.
%
% LFITV2_GUI_SINGLEPANEL('Property','Value',...) creates a new LFITV2_GUI_SINGLEPANEL or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before LFITv2_GUI_SinglePanel_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to LFITv2_GUI_SinglePanel_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 LFITv2_GUI_SinglePanel
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @LFITv2_GUI_SinglePanel_OpeningFcn, ...
'gui_OutputFcn', @LFITv2_GUI_SinglePanel_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 LFITv2_GUI_SinglePanel is made visible.
function LFITv2_GUI_SinglePanel_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 LFITv2_GUI_SinglePanel (see VARARGIN)
% Set default values internally and in GUI boxes
handles.colormapList = {'gray';'jet';'hsv';'hot';'cool';'spring';'summer';'autumn';'winter';'bone';'copper';'pink';'lines'};
handles.travelVectorTypes = {'Square','Circle','Cross','Path from File...'};
handles.contrastList = {'none','slice','stack'};
handles = setDefaults(hObject,handles);
% Load last run if present
if ~isempty(dir('lastGUI.gcfg'))
handles = loadState(cd,'lastGUI.gcfg',hObject,handles);
end
% Read in workspace variables
workspaceVariables = evalin('base','who');
for k = 1:size(workspaceVariables,1)
varName = workspaceVariables{k};
temp = evalin('base',varName);
eval([varName '=' 'temp;']); %into workspace
eval([['handles.' varName] '=' 'temp;']); %put into handles structure
end
% See if the data loaded or if something went wrong.
try
handles.microRadius = floor(size(handles.radArray,1)/2);
set(handles.tagCurIm,'String', handles.firstImage); % image name
set(handles.tagProgramVersion, 'String', ['v' num2str(handles.progVersion,'%2.2f')]);
catch noLoadErr
error('Processed image data (radArray) not found. GUI opened prematurely. Please run the scripts in order as in the demonstration program.');
end
% Choose default command line output for LFITv2_GUI_SinglePanel
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% Initialize axes
axes(handles.tagHeaderIm);
imshow('header.png');
axes(handles.tagUVDiag);
colormap('gray');
imshow(fspecial('disk', handles.microRadius),[]);
axes(handles.tagRefocusGraph);
imshow('refocusRef.png');
% Update perspective plot
updatePerspPlot(hObject);
% UIWAIT makes LFITv2_GUI_SinglePanel wait for user response (see UIRESUME)
uiwait(hObject);
% --- Outputs from this function are returned to the command line.
function varargout = LFITv2_GUI_SinglePanel_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;
% Save last run
% saveState(cd,'lastGUI.gcfg',handles)
closereq
% --- Executes during object creation, after setting all properties.
function tagHeaderIm_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagHeaderIm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate tagHeaderIm
%%%%----------%%%%
%%%%---FILE---%%%%
%%%%----------%%%%
% functions related to the 'file' section of the GUI
% --- Executes on button press in tagLoadIm.
function tagLoadIm_Callback(hObject, eventdata, handles)
% hObject handle to tagLoadIm (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[newImage,newPath] = uigetfile({'*.tiff; *.tif','TIFF files (*.tiff, *.tif)'},'Select a single raw plenoptic image to begin processing...',handles.plenopticImagesPath);
if newImage == 0
% Keep last file since user did NOT select a file to import.
% warning('File not selected for import.');
else
% Tell user
stringLoading = [newImage ' now being processed. See command line output for info and estimated wait time. This window will automatically close when processing is complete.'];
loadHandle = msgbox(stringLoading,'Please wait...');
% Strip out old image data from local handles
oldVars = {'radArray'; 'sRange'; 'tRange'; 'imageName'; 'imageSpecificName'; 'imagePath';};
handles = rmfield(handles,oldVars);
% Place image name in expected format.
imageName = struct('name',newImage);
% Update variables
imageSpecificName = [handles.imageSetName '_' imageName(1).name(1:end-4)]; %end-4 removes .tif
if strcmp(handles.plenopticImagesPath,newPath) == false
handles.plenopticImagesPath = newPath; % if the user selects an image outside of the main plenoptic images directory.
% Since the user chose an image in a different directory than was defined originally, prompt for a new output folder.
directory_name = uigetdir(handles.plenopticImagesPath,'Select an output folder to hold all exported/processed images...');
if directory_name ~= 0
handles.outputPath = directory_name;
else
handles.outputPath = fullfile(handles.plenopticImagesPath,'Output'); % if user didn't select a folder, make one in the same directory as the plenoptic images
fprintf('\nNo output directory selected. Output will be in: %s \n',handles.outputPath);
end
end
imagePath = fullfile(handles.plenopticImagesPath,imageName(1).name);
% Interpolate image data
[radArray,sRange,tRange] = interpimage2(handles.cal,imagePath,handles.sensorType,handles.microPitch,handles.pixelPitch,handles.numMicroX,handles.numMicroY);
% Update local handles
handles.radArray = radArray;
handles.sRange = sRange;
handles.tRange = tRange;
handles.imageName = imageName;
handles.imageSpecificName = imageSpecificName;
handles.imagePath = imagePath;
handles.firstImage = imageName(1).name;
% Update real handles structure
guidata(hObject, handles);
% Refresh the GUI
refreshFields(hObject,handles);
% Tell the user
try close(loadHandle);
catch % user must have closed it already; good!
end
stringLoaded = [handles.firstImage ' successfully loaded and processed.'];
uiwait(msgbox(stringLoaded,'Load Complete','modal'));
end
% --- Executes on button press in tagViewDocumentation.
function tagViewDocumentation_Callback(hObject, eventdata, handles)
% hObject handle to tagViewDocumentation (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
open('LFITv2_Documentation.pdf');
% --- Executes on button press in tagLoadGUI.
function tagLoadGUI_Callback(hObject, eventdata, handles)
% hObject handle to tagLoadGUI (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile({'*.gcfg','GUI Configuration Files (*.gcfg)';}, 'Select a GUI settings file to load...');
if filename ~= 0
handles = loadState(pathname,filename,hObject,handles);
end
% --- Executes on button press in tagSaveGUI.
function tagSaveGUI_Callback(hObject, eventdata, handles)
% hObject handle to tagSaveGUI (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uiputfile( {'*.gcfg','GUI Configuration Files (*.gcfg)';}, 'Save');
if filename ~= 0
saveState(pathname,filename,handles)
end
%%%%----------------------%%%%
%%%%---GENERAL SETTINGS---%%%%
%%%%----------------------%%%%
% functions related to the 'general settings' section of the GUI
% --- Executes on selection change in tagColormapMenu.
function tagColormapMenu_Callback(hObject, eventdata, handles)
% hObject handle to tagColormapMenu (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 tagColormapMenu contents as cell array
% contents{get(hObject,'Value')} returns selected item from tagColormapMenu
handles.colormap = handles.colormapList{get(hObject,'Value')};
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function tagColormapMenu_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagColormapMenu (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
set(hObject,'String',{'Grayscale';'Jet';'HSV';'Hot';'Cool';'Spring';'Summer';'Autumn';'Winter';'Bone';'Copper';'Pink';'Lines'});
% --- Executes on selection change in tagImageType.
function tagImageType_Callback(hObject, eventdata, handles)
% hObject handle to tagImageType (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 tagImageType contents as cell array
% contents{get(hObject,'Value')} returns selected item from tagImageType
types = {'bmp','png','jpg','png16','tif16'};
handles.imFileType = types{ get(hObject,'Value') };
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function tagImageType_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagImageType (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
set(hObject,'String',{'Bitmap (*.bmp)';'PNG (*.png)';'JPEG (*.jpg)';'PNG 16-bit (*.png)';'TIFF 16-bit (*.tif)'});
% --- Executes on selection change in tagContrast.
function tagContrast_Callback(hObject, eventdata, handles)
% hObject handle to tagContrast (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 tagContrast contents as cell array
% contents{get(hObject,'Value')} returns selected item from tagContrast
types = {'none','slice','stack'};
handles.contrast = types{ get(hObject,'Value') };
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function tagContrast_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagContrast (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
set(hObject,'String',{'none','slice','stack'});
function tagMinIntensity_Callback(hObject, eventdata, handles)
% hObject handle to tagMinIntensity (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 tagMinIntensity as text
% str2double(get(hObject,'String')) returns contents of tagMinIntensity as a double
handles.minIntensity = str2double(get(hObject,'String'));
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function tagMinIntensity_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagMinIntensity (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 tagMaxIntensity_Callback(hObject, eventdata, handles)
% hObject handle to tagMaxIntensity (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 tagMaxIntensity as text
% str2double(get(hObject,'String')) returns contents of tagMaxIntensity as a double
handles.maxIntensity = str2double(get(hObject,'String'));
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function tagMaxIntensity_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagMaxIntensity (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
%%---ANIMATION SETTINGS---%%
% functions related to the 'animation settings' subsection of the GUI
% --- Executes on selection change in tagCodec.
function tagCodec_Callback(hObject, eventdata, handles)
% hObject handle to tagCodec (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 tagCodec contents as cell array
% contents{get(hObject,'Value')} returns selected item from tagCodec
types = {'uncompressed','jpeg','jpeg2000-lossless','jpeg2000','h264','gif'};
handles.vidCodec = types{ get(hObject,'Value') };
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function tagCodec_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagCodec (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
% Different versions of MATLAB support different codecs; note that not all codecs will be supported on every PC.
if verLessThan('matlab', '7.11')
set(hObject,'String',{'None (uncompressed)';'MSVC';'RLE';'Cinepak'});
else
set(hObject,'String',{'Uncompressed AVI';'Motion JPEG AVI';'Motion JPEG 2000 (lossless)';'Motion JPEG 2000 (lossy)';'MPEG-4 (H.264)';'GIF'});
end
function tagFrameRate_Callback(hObject, eventdata, handles)
% hObject handle to tagFrameRate (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 tagFrameRate as text
% str2double(get(hObject,'String')) returns contents of tagFrameRate as a double
handles.frameRate = str2double(get(hObject,'String'));
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function tagFrameRate_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagFrameRate (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 tagQuality_Callback(hObject, eventdata, handles)
% hObject handle to tagQuality (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 tagQuality as text
% str2double(get(hObject,'String')) returns contents of tagQuality as a double
handles.quality = str2double(get(hObject,'String'));
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function tagQuality_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagQuality (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
%%%%-----------------------%%%%
%%%%---PERSPECTIVE VIEWS---%%%%
%%%%-----------------------%%%%
% functions related to the 'perspective views' section of the GUI
% --- Executes during object creation, after setting all properties.
function tagUVDiag_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagUVDiag (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate tagUVDiag
% handles.perspPlot = gcbo;
%
% Update handles structure
% guidata(hObject, handles);
function updatePerspPlot(hObject)
% Updates perspective plot
handles = guidata(hObject);
oldAxes = gca;
axes(handles.tagUVDiag);
colormap('gray');
imshow(fspecial('disk', handles.microRadius),[]);
hold on;
scatter(-(handles.uVal) + handles.microRadius + 1, -(handles.vVal) + handles.microRadius + 1,'b+');
axes(oldAxes);
% --- Executes on button press in tagOpenUVDialog.
function tagOpenUVDialog_Callback(hObject, eventdata, handles)
% hObject handle to tagOpenUVDialog (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function tagU_Callback(hObject, eventdata, handles)
% hObject handle to tagU (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 tagU as text
% str2double(get(hObject,'String')) returns contents of tagU as a double
input = str2double(get(hObject,'String'));
handles.uVal = input;
% Update handles structure
guidata(hObject, handles);
% Update perspective plot (u,v)
updatePerspPlot(hObject);
% --- Executes during object creation, after setting all properties.
function tagU_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagU (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 tagV_Callback(hObject, eventdata, handles)
% hObject handle to tagV (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 tagV as text
% str2double(get(hObject,'String')) returns contents of tagV as a double
input = str2double(get(hObject,'String'));
handles.vVal = input;
% Update handles structure
guidata(hObject, handles);
% Update perspective plot (u,v)
updatePerspPlot(hObject);
% --- Executes during object creation, after setting all properties.
function tagV_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagV (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 tagSSSTP_Callback(hObject, eventdata, handles)
% hObject handle to tagSSSTP (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 tagSSSTP as text
% str2double(get(hObject,'String')) returns contents of tagSSSTP as a double
handles.SSSTP = str2double(get(hObject,'String'));
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function tagSSSTP_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagSSSTP (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 tagGenerateDispP.
function tagGenerateDispP_Callback(hObject, eventdata, handles)
% hObject handle to tagGenerateDispP (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
disp('Calculating perspective view...');
q = lfiQuery('perspective');
q.pUV = [handles.uVal handles.vVal];
q.stFactor = handles.SSSTP;
q.saveas = false;
q.display = 'fast';
q.colormap = handles.colormap;
q.contrast = handles.contrast;
q.intensity = [handles.minIntensity, handles.maxIntensity];
genperspective(q,handles.radArray,handles.sRange,handles.tRange,handles.outputPath,handles.imageSpecificName);
% --- Executes on button press in tagGenerateSaveP.
function tagGenerateSaveP_Callback(hObject, eventdata, handles)
% hObject handle to tagGenerateSaveP (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
disp('Calculating perspective view...');
q = lfiQuery('perspective');
q.pUV = [handles.uVal handles.vVal];
q.stFactor = handles.SSSTP;
q.saveas = handles.imFileType;
q.display = 'fast';
q.colormap = handles.colormap;
q.contrast = handles.contrast;
q.intensity = [handles.minIntensity, handles.maxIntensity];
genperspective(q,handles.radArray,handles.sRange,handles.tRange,handles.outputPath,handles.imageSpecificName);
% --- Executes on button press in tagExportPerspectiveVid.
function tagExportPerspectiveVid_Callback(hObject, eventdata, handles)
% hObject handle to tagExportPerspectiveVid (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if strcmpi( handles.vidCodec, 'h264' )
fileType = 'mp4';
elseif strcmpi( handles.vidCodec, 'gif' )
fileType = 'gif';
else
fileType = 'avi';
end
q = lfiQuery('perspective');
q.pUV = gentravelvector( handles.edgeBuffer, size(handles.radArray), handles.SSUVPM, handles.travelVector );
q.uvFactor = handles.SSUVPM;
q.stFactor = handles.SSSTP;
q.mask = handles.aperMask;
q.saveas = fileType;
q.quality = handles.quality;
q.codec = handles.vidCodec;
q.framerate = handles.frameRate;
q.display = 'fast';
q.contrast = handles.contrast;
q.intensity = [handles.minIntensity, handles.maxIntensity];
q.colormap = handles.colormap;
q.background = [0 0 0];
genperspective(q,handles.radArray,handles.sRange,handles.tRange,handles.outputPath,handles.imageSpecificName);
%%---PERSPECTIVE ANIMATION SETTINGS---%%
% functions related to the 'perspective animation settings' subsection of the GUI
function tagEdgeBuffer_Callback(hObject, eventdata, handles)
% hObject handle to tagEdgeBuffer (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 tagEdgeBuffer as text
% str2double(get(hObject,'String')) returns contents of tagEdgeBuffer as a double
handles.edgeBuffer = str2double(get(hObject,'String'));
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function tagEdgeBuffer_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagEdgeBuffer (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 tagSSUVPM_Callback(hObject, eventdata, handles)
% hObject handle to tagSSUVPM (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 tagSSUVPM as text
% str2double(get(hObject,'String')) returns contents of tagSSUVPM as a double
handles.SSUVPM = str2double(get(hObject,'String'));
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function tagSSUVPM_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagSSUVPM (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 selection change in tagTravelVector.
function tagTravelVector_Callback(hObject, eventdata, handles)
% hObject handle to tagTravelVector (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 tagTravelVector contents as cell array
% contents{get(hObject,'Value')} returns selected item from tagTravelVector
handles.travelVector = get(hObject,'Value');
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function tagTravelVector_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagTravelVector (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
set(hObject,'String',{'Square';'Circle';'Cross';'Path from File...'});
%%%%----------------%%%%
%%%%---REFOCUSING---%%%%
%%%%----------------%%%%
% functions related to the 'refocusing' section of the GUI
% --- Executes on button press in tagGenDispR.
function tagGenDispR_Callback(hObject, eventdata, handles)
% hObject handle to tagGenDispR (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
q = lfiQuery('focus');
q.fMethod = handles.refocusType;
q.fFilter = [handles.noiseThreshold handles.filterThreshold];
if handles.telecentric
q.fZoom = 'telecentric';
q.fGridX = linspace( handles.Xmin, handles.Xmax, handles.VoxX );
q.fGridY = linspace( handles.Ymin, handles.Ymax, handles.VoxY );
q.fPlane = handles.Zlocation;
q.fLength = handles.focLenMain;
q.fMag = handles.magnification;
else
q.fZoom = 'legacy';
q.fAlpha = handles.alpha;
end
q.uvFactor = handles.SSUVR;
q.stFactor = handles.SSSTR;
q.contrast = handles.contrast;
q.intensity = [handles.minIntensity, handles.maxIntensity];
q.mask = handles.aperMask;
q.saveas = false;
q.display = 'fast';
q.colormap = handles.colormap;
q.background = [1 1 1];
genrefocus(q,handles.radArray,handles.sRange,handles.tRange,handles.outputPath,handles.imageSpecificName);
% --- Executes on button press in tagGenSaveR.
function tagGenSaveR_Callback(hObject, eventdata, handles)
% hObject handle to tagGenSaveR (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
q = lfiQuery('focus');
q.fMethod = handles.refocusType;
q.fFilter = [handles.noiseThreshold handles.filterThreshold];
if handles.telecentric
q.fZoom = 'telecentric';
q.fGridX = linspace( handles.Xmin, handles.Xmax, handles.VoxX );
q.fGridY = linspace( handles.Ymin, handles.Ymax, handles.VoxY );
q.fPlane = handles.Zlocation;
q.fLength = handles.focLenMain;
q.fMag = handles.magnification;
else
q.fZoom = 'legacy';
q.fAlpha = handles.alpha;
end
q.uvFactor = handles.SSUVR;
q.stFactor = handles.SSSTR;
q.contrast = handles.contrast;
q.intensity = [handles.minIntensity, handles.maxIntensity];
q.mask = handles.aperMask;
q.saveas = handles.imFileType;
q.display = 'fast';
q.colormap = handles.colormap;
q.background = [1 1 1];
genrefocus(q,handles.radArray,handles.sRange,handles.tRange,handles.outputPath,handles.imageSpecificName);
% --- Executes on button press in tagExportRefocusVid.
function tagExportRefocusVid_Callback(hObject, eventdata, handles)
% hObject handle to tagExportRefocusVid (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if strcmpi( handles.vidCodec, 'h264' )
fileType = 'mp4';
elseif strcmpi( handles.vidCodec, 'gif' )
fileType = 'gif';
else
fileType = 'avi';
end
q = lfiQuery('focus');
q.fMethod = handles.refocusType;
q.fFilter = [handles.noiseThreshold handles.filterThreshold];
if handles.telecentric
q.fZoom = 'telecentric';
q.fGridX = linspace( handles.Xmin, handles.Xmax, handles.VoxX );
q.fGridY = linspace( handles.Ymin, handles.Ymax, handles.VoxY );
q.fPlane = linspace( handles.Zmin, handles.Zmax, handles.VoxZ );
q.fLength = handles.focLenMain;
q.fMag = handles.magnification;
else
q.fZoom = 'legacy';
if handles.stepSpace, alpha = logspace( log10(handles.alphaStart), log10(handles.alphaEnd), handles.steps );
else alpha = linspace( handles.alphaStart, handles.alphaEnd, handles.steps );
end
if handles.mirrorLoop, alpha = [ alpha(2:end) fliplr(alpha) ];
end
q.fAlpha = alpha;
end
q.uvFactor = handles.SSUVR;
q.stFactor = handles.SSSTR;
q.contrast = handles.contrast;
q.intensity = [handles.minIntensity, handles.maxIntensity];
q.mask = handles.aperMask;
q.saveas = fileType;
q.quality = handles.quality;
q.codec = handles.vidCodec;
q.framerate = handles.frameRate;
q.display = 'fast';
q.colormap = handles.colormap;
q.background = [0 0 0];
genrefocus(q,handles.radArray,handles.sRange,handles.tRange,handles.outputPath,handles.imageSpecificName);
% --- Executes on button press in tagExportFocalStack.
function tagExportFocalStack_Callback(hObject, eventdata, handles)
% hObject handle to tagExportFocalStack (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
q = lfiQuery('focus');
q.fMethod = handles.refocusType;
q.fFilter = [handles.noiseThreshold handles.filterThreshold];
if handles.telecentric
q.fZoom = 'telecentric';
q.fGridX = linspace( handles.Xmin, handles.Xmax, handles.VoxX );
q.fGridY = linspace( handles.Ymin, handles.Ymax, handles.VoxY );
q.fPlane = linspace( handles.Zmin, handles.Zmax, handles.VoxZ );
q.fLength = handles.focLenMain;
q.fMag = handles.magnification;
else
q.fZoom = 'legacy';
if handles.stepSpace, alpha = logspace( log10(handles.alphaStart), log10(handles.alphaEnd), handles.steps );
else alpha = linspace( handles.alphaStart, handles.alphaEnd, handles.steps );
end
q.fAlpha = alpha;
end
q.uvFactor = handles.SSUVR;
q.stFactor = handles.SSSTR;
q.contrast = handles.contrast;
q.intensity = [handles.minIntensity, handles.maxIntensity];
q.mask = handles.aperMask;
q.saveas = handles.imFileType;
q.display = 'fast';
q.colormap = handles.colormap;
q.background = [1 1 1];
genrefocus(q,handles.radArray,handles.sRange,handles.tRange,handles.outputPath,handles.imageSpecificName);
% --- Executes on button press in tagMirrorLoop.
function tagMirrorLoop_Callback(hObject, eventdata, handles)
% hObject handle to tagMirrorLoop (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 tagMirrorLoop
handles.mirrorLoop = get(hObject,'Value');
% Update handles structure
guidata(hObject, handles);
% --- Executes when selected object is changed in tagEnforceMask.
function tagEnforceMask_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to the selected object in tagEnforceMask
% eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
switch get(eventdata.NewValue,'Tag') % Get Tag of selected object.
case 'tagApertureNone'
handles.aperMask = false;
case 'tagCircAper'
handles.aperMask = 'circ';
end
% Update handles structure
guidata(hObject, handles);
% --- Executes when selected object is changed in tagSpace.
function tagSpace_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to the selected object in tagSpace
% eventdata structure with the following fields (see UIBUTTONGROUP)
% EventName: string 'SelectionChanged' (read only)
% OldValue: handle of the previously selected object or empty if none was selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
switch get(eventdata.NewValue,'Tag') % Get Tag of selected object.
case 'tagLinearSpace'
handles.stepSpace = 0;
% handles.stepSpaceFS = 0;
case 'tagLogSpace'
handles.stepSpace = 1;
% handles.stepSpaceFS = 1;
end
% Update handles structure
guidata(hObject, handles);
% --- Executes on button press in tagApertureNone.
function tagApertureNone_Callback(hObject, eventdata, handles)
% hObject handle to tagApertureNone (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 tagApertureNone
% --- Executes on button press in tagCircAper.
function tagCircAper_Callback(hObject, eventdata, handles)
% hObject handle to tagCircAper (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 tagCircAper
%%---REFOCUSING TYPE---%%
% functions related to the 'refocusing type' subsection of the GUI
% --- Executes on selection change in tagRefocusType.
function tagRefocusType_Callback(hObject, eventdata, handles)
% hObject handle to tagRefocusType (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 tagRefocusType contents as cell array
% contents{get(hObject,'Value')} returns selected item from tagRefocusType
types = {'add','mult','filt'};
handles.refocusType = types{ get(hObject,'Value') };
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function tagRefocusType_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagRefocusType (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 tagNoiseThreshold_Callback(hObject, eventdata, handles)
% hObject handle to tagNoiseThreshold (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 tagNoiseThreshold as text
% str2double(get(hObject,'String')) returns contents of tagNoiseThreshold as a double
handles.noiseThreshold = str2double(get(hObject,'String'));
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function tagNoiseThreshold_CreateFcn(hObject, eventdata, handles)
% hObject handle to tagNoiseThreshold (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 tagFilterThreshold_Callback(hObject, eventdata, handles)