-
Notifications
You must be signed in to change notification settings - Fork 0
/
PAM.m
executable file
·12152 lines (11564 loc) · 527 KB
/
PAM.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 Output = PAM (SubFunction)
% 2017 - FAB Lab Munich - Don C. Lamb
global UserValues FileInfo PamMeta TcspcData PathToApp
h.Pam=findobj('Tag','Pam');
if nargout > 0
Output = [];
end
if nargin>0 %%% Used to extract subfunctions from Pam
if ischar(SubFunction) && (exist(SubFunction)==2) %#ok<EXIST>
Output = str2func(SubFunction);
else
Output = [];
end
return;
end
if ~isempty(h.Pam) %%% Gives focus to Pam figure if it already exists
figure(h.Pam); return;
end
addpath(genpath(['.' filesep 'functions']));
if isempty(PathToApp)
GetAppFolder();
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Figure generation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% start splash screen
s = SplashScreen( 'Splashscreen', [PathToApp filesep 'images' filesep 'PAM' filesep 'logo.png'], ...
'ProgressBar', 'on', ...
'ProgressPosition', 5, ...
'ProgressRatio', 0 );
s.addText( 30, 50, 'PAM - PIE Analysis with MATLAB', 'FontSize', 30, 'Color', [1 1 1] );
s.addText( 30, 80, 'v1.3', 'FontSize', 20, 'Color', [1 1 1] );
s.addText( 375, 395, 'Loading...', 'FontSize', 25, 'Color', 'white' );
%%% Disables negative values for log plot warning
warning('off','MATLAB:Axes:NegativeDataInLogAxis');
warning('off','MATLAB:handle_graphics:exceptions:SceneNode');
warning('off','MATLAB:uigridcontainer:MigratingFunction');
warning('off','MATLAB:ui:javaframe:PropertyToBeRemoved');
%%% Loads user profile
Profiles=LSUserValues(0);
for i = 1:numel(Profiles)
[~, Profiles{i}, ~] = fileparts(Profiles{i});
end
%%% To save typing
Look=UserValues.Look;
%%% Generates the Pam figure
h.Pam = figure(...
'Units','normalized',...
'Tag','Pam',...
'Name','PAM: PIE Analysis with Matlab',...
'NumberTitle','off',...
'Menu','none',...
'defaultUicontrolFontName',Look.Font,...
'defaultAxesFontName',Look.Font,...
'defaultTextFontName',Look.Font,...
'Toolbar','figure',...
'UserData',[],...
'OuterPosition',[0.01 0.1 0.98 0.9],...
'CloseRequestFcn',@CloseWindow,...
'Visible','off');
%h.Pam.Visible='off';
%%% Remove unneeded items from toolbar
toolbar = findall(h.Pam,'Type','uitoolbar');
toolbar_items = findall(toolbar);
if verLessThan('matlab','9.5') %%% toolbar behavior changed in MATLAB 2018b
delete(toolbar_items([2:7 9 13:17]));
else %%% 2018b and upward
%%% just remove the tool bar since the options are now in the axis
%%% (e.g. axis zoom etc)
delete(toolbar_items);
end
%%% Sets background of axes and other things
whitebg(Look.Axes);
%%% Changes Pam background; must be called after whitebg
h.Pam.Color=Look.Back;
%%% Initializes cell containing text objects (for changes between mac/pc
h.Text={};
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Menubar %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% File menu with loading, saving and exporting functions
h.Menu.File = uimenu(...
'Parent',h.Pam,...
'Tag','File',...
'Label','File');
h.Menu.Loadtcspc = uimenu(...
'Parent', h.Menu.File,...
'Tag','LoadTcspc',...
'Label','Load TCSPC Data',...
'Callback',{@LoadTcspc,@Update_Data,@Update_Display,@Shift_Detector,@Update_Detector_Channels,h.Pam});
h.Menu.Database = uimenu(...
'Parent', h.Menu.File,...
'Tag','DatabaseMenu',...
'Label','Database...');
h.Export.Single = uimenu(...
'Parent', h.Menu.Database,...
'Tag','Export_Single',...
'Label','Add Individual Tcspc Files to Database',...
'Callback',{@Export_Database,1});
h.Export.Multi = uimenu(...
'Parent', h.Menu.Database,...
'Tag','Export_Multi',...
'Label','Add Connected Tcspc Files to Database',...
'Callback',{@Export_Database,1});
h.Menu.SaveIrf = uimenu(...
'Parent', h.Menu.File,...
'Separator','on',...
'Tag','SaveIrf_Menu',...
'Separator','on',...
'Label','Store loaded data as IRF (for all PIE Channels)',...
'Callback',@SaveLoadIrfScat);
h.Menu.SaveScatter = uimenu(...
'Parent', h.Menu.File,...
'Tag','SaveScatter_Menu',...
'Label','Store loaded data as Scatter/Background',...
'Callback',@SaveLoadIrfScat);
h.Menu.LoadSaveCalibrations = uimenu(...
'Parent', h.Menu.File,...
'Tag','DatabaseMenu',...
'Label','Load/Save Calibrations...');
h.Menu.LoadIrf = uimenu(...
'Parent', h.Menu.LoadSaveCalibrations,...
'Tag','LoadIrf_Menu',...
'Label','Load IRF',...
'Callback',@SaveLoadIrfScat);
h.Menu.LoadScatter = uimenu(...
'Parent', h.Menu.LoadSaveCalibrations,...
'Tag','LoadScatter_Menu',...
'Label','Load Scatter/Background',...
'Callback',@SaveLoadIrfScat);
h.Menu.SaveIrfFile = uimenu(...
'Parent', h.Menu.LoadSaveCalibrations,...
'Tag','SaveIrfFile_Menu',...
'Label','Save IRF to File',...
'Callback',@SaveLoadIrfScat);
h.Menu.SaveScatterFile = uimenu(...
'Parent', h.Menu.LoadSaveCalibrations,...
'Tag','SaveScatterFile_Menu',...
'Label','Save Scatter/Background to File',...
'Callback',@SaveLoadIrfScat);
h.Menu.LoadShift = uimenu(...
'Parent', h.Menu.LoadSaveCalibrations,...
'Separator','on',...
'Tag','LoadShift_Menu',...
'Label','Load Detector Shifts',...
'Callback',@SaveLoadShift);
h.Menu.SaveShiftFile = uimenu(...
'Parent', h.Menu.LoadSaveCalibrations,...
'Tag','SaveShiftFile_Menu',...
'Label','Save Detector Shifts to File',...
'Callback',@SaveLoadShift);
h.Menu.ExportFile = uimenu(...
'Parent', h.Menu.File,...
'Tag','ExportFile_Menu',...
'Separator','on',...
'Label','Export...');
h.Menu.ExportFile_PhotonHDF5 = uimenu(...
'Parent', h.Menu.ExportFile,...
'Tag','ExportFile_PhotonHDF5_Menu',...
'Label','to PhotonHDF5 file',...
'Callback',@write_photonHDF5);
h.Menu.AdvancedAnalysis = uimenu(...
'Parent',h.Pam,...
'Tag','AdvancedAnalysis',...
'Label','Advanced Analysis');
h.Menu.OpenFCSFit = uimenu(...
'Parent', h.Menu.AdvancedAnalysis,...
'Tag','OpenFCSFit',...
'Label','FCSFit',...
'Callback',@FCSFit);
h.Menu.OpenMIAFit = uimenu(...
'Parent', h.Menu.AdvancedAnalysis,...
'Tag','OpenMIAFit',...
'Label','MIAFit',...
'Callback',@MIAFit);
h.Menu.OpenTauFit = uimenu(...
'Parent', h.Menu.AdvancedAnalysis,...
'Tag','OpenTauFit',...
'Label','TauFit',...
'Callback',@TauFit);
h.Menu.OpenBurstBrowser = uimenu(...
'Parent', h.Menu.AdvancedAnalysis,...
'Separator','on',...
'Tag','OpenBurstBrowser',...
'Label','BurstBrowser',...
'Callback',@BurstBrowser);
h.Menu.OpenPDA = uimenu(...
'Parent', h.Menu.AdvancedAnalysis,...
'Tag','OpenPDA',...
'Label','PDAFit',...
'Callback',@PDAFit);
h.Menu.OpenMia = uimenu(...
'Parent', h.Menu.AdvancedAnalysis,...
'Tag','OpenMia',...
'Label','MIA',...
'Callback',@Mia);
h.Menu.PhasorMenu = uimenu(...
'Parent', h.Menu.AdvancedAnalysis,...
'Tag','PhasorMenu',...
'Label','Phasor');
h.Menu.OpenPhasor = uimenu(...
'Parent', h.Menu.PhasorMenu,...
'Tag','OpenPhasor',...
'Label','Phasor',...
'Callback',@Phasor);
h.Menu.OpenParticleDetection = uimenu(...
'Parent', h.Menu.PhasorMenu,...
'Tag','OpenParticleDetection',...
'Label','Particle Detection',...
'Callback',@ParticleDetection);
h.Menu.OpenParticleViewer = uimenu(...
'Parent', h.Menu.PhasorMenu,...
'Tag','OpenParticleViewer',...
'Label','Particle Viewer',...
'Callback',@ParticleViewer);
h.Menu.OpenPhasorTIFF = uimenu(...
'Parent', h.Menu.PhasorMenu,...
'Tag','OpenPhasorTIFF',...
'Label','Phasor for TIFF images',...
'Callback',@PhasorTIFF);
h.Menu.OpenPCF = uimenu(...
'Parent', h.Menu.AdvancedAnalysis,...
'Tag','OpenPCF',...
'Label','PCF Analysis',...
'Callback',@PCFAnalysis);
if ~isdeployed
if exist([PathToApp filesep 'tcPDA.m'],'file') ~= 0
h.Menu.OpenTCPDA = uimenu(...
'Parent', h.Menu.AdvancedAnalysis,...
'Tag','OpenTCPDA',...
'Label','tcPDA',...
'Callback',@tcPDA);
end
end
h.Menu.Extras = uimenu(...
'Parent',h.Pam,...
'Tag','Extras',...
'Label','Extras');
h.Menu.ParallelProcessing = uimenu(...
'Parent',h.Menu.Extras,...
'Tag','ParallelProcessing',...
'Label','Parallel Processing');
if UserValues.Settings.Pam.ParallelProcessing == 0
checked = 'off';
end
if UserValues.Settings.Pam.ParallelProcessing == Inf
checked = 'on';
end
h.Menu.UseParfor = uimenu(...
'Parent',h.Menu.ParallelProcessing,...
'Tag','UseParfor',...
'Label','Enable Multicore',...
'Checked', checked,...
'Callback',@Calculate_Settings);
h.Menu.NumberOfCores = uimenu(...
'Parent',h.Menu.ParallelProcessing,...
'Tag','UseParfor',...
'Label',['Number of Cores: ' num2str(UserValues.Settings.Pam.NumberOfCores)],...
'Callback',@Calculate_Settings);
h.Menu.Sim = uimenu(...
'Parent', h.Menu.Extras,...
'Tag','Sim_Menu',...
'Label','Simulate photon data',...
'Callback',@Sim);
h.Menu.Look = uimenu(...
'Parent', h.Menu.Extras,...
'Tag','Look_Menu',...
'Label','Adjust Pam Look',...
'Separator','on',...
'Callback',@LookSetup);
h.Menu.Manual = uimenu(...
'Parent', h.Menu.Extras,...
'Tag','Manual_Menu',...
'Separator','on',...
'Label','PAM Manual',...
'Callback',@Open_Doc);
h.Menu.NotePad = uimenu(...
'Parent',h.Menu.Extras,...
'Label','Notepad',...
'Separator','on',...
'Callback',@Open_Notepad);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Progressbar and file name %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Panel for progressbar
h.Progress.Panel = uibuttongroup(...
'Parent',h.Pam,...
'Tag','Progress_Panel',...
'Units','normalized',...
'BackgroundColor', Look.Back,...
'ForegroundColor', Look.Fore,...
'HighlightColor', Look.Control,...
'ShadowColor', Look.Shadow,...
'Position',[0.01 0.96 0.485 0.03]);
%%% Axes for progressbar
h.Progress.Axes = axes(...
'Parent',h.Progress.Panel,...
'Tag','Progress_Axes',...
'Units','normalized',...
'Color',Look.Control,...
'Position',[0 0 1 1]);
h.Progress.Axes.XTick=[]; h.Progress.Axes.YTick=[];
%%% Progress and filename text
h.Progress.Text=text(...
'Parent',h.Progress.Axes,...
'Tag','Progress_Text',...
'Units','normalized',...
'FontSize',12,...
'FontWeight','bold',...
'String','Nothing loaded',...
'Interpreter','none',...
'HorizontalAlignment','center',...
'BackgroundColor','none',...
'Color',Look.Fore,...
'Position',[0.5 0.5]);
%% Detector tabs %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
s.ProgressRatio = 0.25;
%%% Microtime tabs container
h.Det_Tabs = uitabgroup(...
'Parent',h.Pam,...
'Tag','Det_Tabs',...
'Units','normalized',...
'Position',[0.505 0.01 0.485 0.98]);
%% Plot and functions for microtimes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Microtime tab
h.MI.Tab= uitab(...
'Parent',h.Det_Tabs,...
'Tag','MI_Tab',...
'Title','Microtimes');
%%% Microtime tabs container
h.MI.Tabs = uitabgroup(...
'Parent',h.MI.Tab,...
'Tag','MI_Tabs',...
'Units','normalized',...
'Position',[0 0 1 1]);
%%% All microtime tab
h.MI.All_Tab= uitab(...
'Parent',h.MI.Tabs,...
'Tag','MI_All_Tab',...
'Title','All');
%%% All microtime panel
h.MI.All_Panel = uibuttongroup(...
'Parent',h.MI.All_Tab,...
'Tag','MI_All_Panel',...
'Units','normalized',...
'BackgroundColor', Look.Back,...
'ForegroundColor', Look.Fore,...
'HighlightColor', Look.Control,...
'ShadowColor', Look.Shadow,...
'Position',[0 0 1 1]);
%%% Contexmenu for all microtime axes
h.MI.Menu = uicontextmenu;
%%% Menu for Log scale plotting
h.MI.Log = uimenu(...
'Parent',h.MI.Menu,...
'Label','Plot as log scale',...
'Tag','MI_Log',...
'Checked',UserValues.Settings.Pam.PlotLog,...
'Callback',@Calculate_Settings);
%%% Contextmenu for individual microtime axes
h.MI.Menu_Individual = uicontextmenu;
%%% Menu for Log scale plotting
h.MI.Log_Ind = uimenu(...
'Parent',h.MI.Menu_Individual,...
'Label','Plot as log scale',...
'Tag','MI_Log',...
'Checked',UserValues.Settings.Pam.PlotLog,...
'Callback',@Calculate_Settings);
%%% Menu for Enabling/Disabling IRF Plotting
h.MI.IRF = uimenu(...
'Parent',h.MI.Menu_Individual,...
'Label','Plot IRF',...
'Separator','on',...
'Tag','MI_IRF',...
'Checked',UserValues.Settings.Pam.PlotIRF,...
'Callback',@Calculate_Settings);
%%% Menu for Enabling/Disabling Scatter Pattern Plotting
h.MI.ScatterPattern = uimenu(...
'Parent',h.MI.Menu_Individual,...
'Label','Plot Scatter Pattern',...
'Tag','MI_ScatterPattern',...
'Checked',UserValues.Settings.Pam.PlotScat,...
'Callback',@Calculate_Settings);
%%% All microtime axes
h.MI.All_Axes = axes(...
'Parent',h.MI.All_Panel,...
'Tag','MI_All_Axes',...
'Units','normalized',...
'NextPlot','add',...
'UIContextMenu',h.MI.Menu,...
'XColor',Look.Fore,...
'YColor',Look.Fore,...
'LineWidth', Look.AxWidth,...
'Position',[0.09 0.075 0.89 0.90],...
'TickDir','out',...
'Box','off');
h.MI.All_Axes.XLabel.String='TCSPC channel';
h.MI.All_Axes.XLabel.Color=Look.Fore;
h.MI.All_Axes.YLabel.String='Counts';
h.MI.All_Axes.YLabel.Color=Look.Fore;
h.MI.All_Axes.XLim=[1 4096];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Correlations tab
h.Cor.Tab= uitab(...
'Parent',h.Det_Tabs,...
'Tag','Cor_Tab',...
'BackgroundColor',Look.Back,...
'Title','Correlate');
%%% Correlation panel
h.Cor.Panel = uibuttongroup(...
'Parent',h.Cor.Tab,...
'Tag','Cor_Panel',...
'Units','normalized',...
'BackgroundColor', Look.Back,...
'ForegroundColor', Look.Fore,...
'HighlightColor', Look.Control,...
'ShadowColor', Look.Shadow,...
'Position',[0 0.52 1 0.48]);
%%% Contexmenu for correlation table
h.Cor.Menu = uicontextmenu;
%%% Resets the correlation table to all zeros
h.Cor.Reset_Menu = uimenu(...
'Parent',h.Cor.Menu,...
'Label','Reset table',...
'Tag','Cor_Reset_Menu',...
'Callback',@Update_Cor_Table);
%%% Sets a divider for correlation
h.Cor.Divider_Menu = uimenu(...
'Parent',h.Cor.Menu,...
'Label',['Divider: ' num2str(UserValues.Settings.Pam.Cor_Divider)],...
'Tag','Cor_Divider_Menu',...
'Separator','on',...
'Callback',@Calculate_Settings);
%%% Correlations table
h.Cor.Table = uitable(...
'Parent',h.Cor.Panel,...
'Tag','Cor_Table',...
'Units','normalized',...
'FontSize',8,...
'Position',[0.005 0.11 0.99 0.88],...
'ForegroundColor',Look.TableFore,...
'BackgroundColor',[Look.Table1;Look.Table2],...
'TooltipString',sprintf([...
'Selection for cross correlations: \n'...
'"Column"/"Row" (un)selects full column/row; \n'...
'Bottom right checkbox (un)selects diagonal \n'...
'Rightclick to open contextmenu with additional functions: \n'...
'Divider: Divider for correlation time resolution for certain excitation schemes']),...
'UIContextMenu',h.Cor.Menu,...
'CellEditCallback',@Update_Cor_Table);
%%% Correlates current loaded data
h.Cor.Button = uicontrol(...
'Parent',h.Cor.Panel,...
'Tag','Cor_Button',...
'Units','normalized',...
'FontSize',12,...
'FontWeight','bold',...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String','Correlate',...
'Callback',{@Correlate,1},...
'Position',[0.005 0.01 0.12 0.09],...
'TooltipString',sprintf('Correlates loaded data for selected PIE channel pairs;'));
%%% Correlates multiple data sets
h.Cor.Multi_Button = uicontrol(...
'Parent',h.Cor.Panel,...
'Tag','Cor_Multi_Button',...
'Units','normalized',...
'FontSize',12,...
'FontWeight','bold',...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String','Multiple',...
'Callback',{@Correlate,2},...
'Position',[0.13 0.01 0.12 0.09],...
'TooltipString',sprintf('Load multiple files and individually correlates them'));
%%% Determines data format
h.Cor.Format = uicontrol(...
'Parent',h.Cor.Panel,...
'Tag','Cor_Format',...
'Units','normalized',...
'FontSize',10,...
'FontWeight','bold',...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String',{'Matlab file (.mcor)';'Text file (.cor)'; 'both'},...
'Position',[0.26 0 0.24 0.09],...
'Style','popupmenu',...
'TooltipString',sprintf('Select fileformat for saving correlation files'));
if ismac
h.Cor.Format.ForegroundColor = [0 0 0];
h.Cor.Format.BackgroundColor = [1 1 1];
end
%%% Determines correlation type
h.Cor.Type = uicontrol(...
'Parent',h.Cor.Panel,...
'Units','normalized',...
'FontSize',10,...
'FontWeight','bold',...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String',{'Point';'Pair (Line)';'Pair (Circular)';'Microtime';'Microtime (linear)'},...
'Position',[0.5 0 0.17 0.09],...
'Style','popupmenu',...
'Callback',@Calculate_Settings,...
'TooltipString',sprintf('Choose between point and pair correlation'));
if ismac
h.Cor.Type.ForegroundColor = [0 0 0];
h.Cor.Type.BackgroundColor = [1 1 1];
end
h.Cor.AggregateCorrection = uicontrol(...
'Style','checkbox',...
'Parent',h.Cor.Panel,...
'Units','normalized',...
'FontSize',10,...
'BackgroundColor',Look.Back,...
'ForegroundColor',Look.Fore,...
'Position',[0.67 0.05 0.3 0.05],...
'Callback',@Calculate_Settings,...
'String','Remove aggregates',...
'Value',0,...
'TooltipString','Removes aggregates. Set parameters in the tab below. Only works for autocorrelation.');
h.Cor.AfterPulsingCorrection = uicontrol(...
'Style','checkbox',...
'Parent',h.Cor.Panel,...
'Units','normalized',...
'FontSize',10,...
'BackgroundColor',Look.Back,...
'ForegroundColor',Look.Fore,...
'Position',[0.67 0 0.3 0.05],...
'Callback',@Calculate_Settings,...
'String','Correct for afterpulsing',...
'Value',0,...
'TooltipString','Enables afterpulsing correction based on FLCS.');
%%% Text
h.Text{end+1} = uicontrol(...
'Parent',h.Cor.Panel,...
'Units','normalized',...
'FontSize',12,...
'Style','text',...
'BackgroundColor', Look.Back,...
'ForegroundColor', Look.Fore,...
'String','#Bins:',...
'HorizontalAlignment','left',...
'Visible','off',...
'Tag','PairCorBins',...
'Position',[0.67 0 0.09 0.09]);
%%% Sets number of bins for pair correlation
h.Cor.Pair_Bins = uicontrol(...
'Parent',h.Cor.Panel,...
'Units','normalized',...
'FontSize',12,...
'Style','edit',...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String','50',...
'Visible','off',...
'Position',[0.76 0.01 0.06 0.09],...
'TooltipString',sprintf('Select number of bins for pair correlation'));
%%% Text
h.Text{end+1} = uicontrol(...
'Parent',h.Cor.Panel,...
'Units','normalized',...
'FontSize',12,...
'Style','text',...
'BackgroundColor', Look.Back,...
'ForegroundColor', Look.Fore,...
'String','Distance:',...
'Visible','off',...
'Tag','PairCorDistance',...
'HorizontalAlignment','left',...
'Position',[0.83 0 0.10 0.09]);
%%% Sets bin distances to correlatie
h.Cor.Pair_Dist = uicontrol(...
'Parent',h.Cor.Panel,...
'Units','normalized',...
'FontSize',12,...
'Style','edit',...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String','1:50',...
'Position',[0.93 0.01 0.06 0.09],...
'Visible','off',...
'TooltipString',sprintf('Select bin distances to calculate for pair correlation'));
%%% Tabgroup for ploting Correlations
h.Cor.Correlations_Tabs = uitabgroup(...
'Parent',h.Cor.Tab,...
'Tag','Cor_Tabs',...
'Position',[0 0 1 0.52]);
h.Cor.Individual_Tab{1} = uitab(...
'Parent',h.Cor.Correlations_Tabs,...
'Tag','Cor_Ind_Tabs_1',...
'BackgroundColor',Look.Back,...
'Title','No data');
h.Cor.Individual_Axes{1} = axes(...
'Parent',h.Cor.Individual_Tab{1},...
'Tag','Cor_Individual_Axes',...
'Units','normalized',...
'NextPlot','add',...
'XColor',Look.Fore,...
'YColor',Look.Fore,...
'LineWidth', Look.AxWidth,...
'XScale','Log',...
'XLim',[3e-7,1],...
'Position',[0.08 0.11 0.9 0.85],...
'Box','on');
h.Cor.Individual_Axes{1}.XLabel.String='Lag Time [s]';
h.Cor.Individual_Axes{1}.XLabel.Color=Look.Fore;
h.Cor.Individual_Axes{1}.YLabel.String='G({\it\tau{}})';
h.Cor.Individual_Axes{1}.YLabel.Color=Look.Fore;
h.Cor.Individual_Menu = uicontextmenu;
%%% Menu for selecting all individual correlations
h.Cor.Individual_Select_All = uimenu(...
'Parent',h.Cor.Individual_Menu,...
'Label','Select All',...
'Tag','Select All',...
'Callback',{@Cor_Selection,2});
%%% Menu for unselecting all individual correlations
h.Cor.Individual_UnSelect_All = uimenu(...
'Parent',h.Cor.Individual_Menu,...
'Label','Unselect All',...
'Tag','Unselect All',...
'Callback',{@Cor_Selection,3});
%%% Menu for saving selected correlations
h.Cor.Individual_UnSelect_All = uimenu(...
'Parent',h.Cor.Individual_Menu,...
'Label','Save selected correlations',...
'Tag','Save_Selected',...
'Callback',{@Cor_Selection,4});
%%% Tab for the removal of aggregates
h.Cor.Remove_Aggregates_Tab = uitab(...
'Parent',h.Cor.Correlations_Tabs,...
'Tag','Cor_Remove_Aggregates_Tab',...
'BackgroundColor',Look.Back,...
'Title','Remove aggregates');
h.Cor.Remove_Aggregates_Axes = axes(...
'Parent',h.Cor.Remove_Aggregates_Tab,...
'Tag','Remove_Aggregates_Axes',...
'Units','normalized',...
'NextPlot','add',...
'XColor',Look.Fore,...
'YColor',Look.Fore,...
'LineWidth', Look.AxWidth,...
'Position',[0.075 0.25 0.9 0.72],...
'Box','on');
h.Cor.Remove_Aggregates_Axes.XLabel.String='Time [s]';
h.Cor.Remove_Aggregates_Axes.XLabel.Color=Look.Fore;
h.Cor.Remove_Aggregates_Axes.YLabel.String='Count rate [kHz]';
h.Cor.Remove_Aggregates_Axes.YLabel.Color=Look.Fore;
h.Cor.Remove_Aggregates_Axes_Menu = uicontextmenu;
h.Cor.Remove_Aggregates_Axes_Log = uimenu('Parent',h.Cor.Remove_Aggregates_Axes_Menu,...
'Label','Y-scale log',...
'Checked','off',...
'Callback',@Calculate_Settings);
h.Cor.Remove_Aggregates_Axes.UIContextMenu = h.Cor.Remove_Aggregates_Axes_Menu;
h.Cor.Remove_Aggregates_FCS_Axes = axes(...
'Parent',h.Cor.Remove_Aggregates_Tab,...
'Tag','Remove_Aggregates_FCS_Axes',...
'Units','normalized',...
'NextPlot','add',...
'XColor',Look.Fore,...
'YColor',Look.Fore,...
'XScale','log',...
'LineWidth', Look.AxWidth,...
'Position',[0.635 0.25 0.35 0.72],...
'Box','on',...
'Visible','off');
h.Cor.Remove_Aggregates_FCS_Axes.XLabel.String='Lag Time [s]';
h.Cor.Remove_Aggregates_FCS_Axes.XLabel.Color=Look.Fore;
h.Cor.Remove_Aggregates_FCS_Axes.YLabel.String='G(\tau) norm.';
h.Cor.Remove_Aggregates_FCS_Axes.YLabel.Color=Look.Fore;
h.Cor.Aggregate_GridContainer = uigridcontainer(...
'Parent',h.Cor.Remove_Aggregates_Tab,...
'GridSize',[2,5],...
'Units','norm',...
'Position',[0,0,1,0.125],...
'BackgroundColor',Look.Back);
h.Cor.Remove_Aggregate_Block_Text = uicontrol(...
'Style','text',...
'Parent',h.Cor.Aggregate_GridContainer,...
'FontSize',10,...
'BackgroundColor', Look.Back,...
'ForegroundColor', Look.Fore,...
'String','Macrotime block:',...
'TooltipString','Select which macrotime block to use for preview.');
h.Cor.Remove_Aggregate_Nsigma_Text = uicontrol(...
'Style','text',...
'Parent',h.Cor.Aggregate_GridContainer,...
'FontSize',10,...
'BackgroundColor', Look.Back,...
'ForegroundColor', Look.Fore,...
'String','Threshold [STDEV]:',...
'TooltipString','Set the threshold in units of the signal standard deviation.');
h.Cor.Remove_Aggregate_Timewindow_Text = uicontrol(...
'Style','text',...
'Parent',h.Cor.Aggregate_GridContainer,...
'FontSize',10,...
'BackgroundColor', Look.Back,...
'ForegroundColor', Look.Fore,...
'String','Time window [ms]:',...
'TooltipString','Set the time window in units of milliseconds.');
h.Cor.Remove_Aggregate_TimeWindowAdd_Text = uicontrol(...
'Style','text',...
'Parent',h.Cor.Aggregate_GridContainer,...
'FontSize',10,...
'BackgroundColor', Look.Back,...
'ForegroundColor', Look.Fore,...
'String','Add window:',...
'TooltipString','Add a time frame around detected bursts in units of the selected time window.');
h.Cor.Replot_Aggregate_Plot_Button = uicontrol(...
'Style','pushbutton',...
'Parent',h.Cor.Aggregate_GridContainer,...
'FontSize',10,...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String','Plot preview',...
'Callback',@Remove_Aggregates_Preview);
h.Cor.Remove_Aggregate_Block_Edit = uicontrol(...
'Style','edit',...
'Parent',h.Cor.Aggregate_GridContainer,...
'FontSize',10,...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String','1',...
'Callback',@Calculate_Settings,...
'TooltipString','Select which macrotime block to use for preview.');
h.Cor.Remove_Aggregate_Nsigma_Edit = uicontrol(...
'Style','edit',...
'Parent',h.Cor.Aggregate_GridContainer,...
'FontSize',10,...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String',num2str(UserValues.Settings.Pam.Cor_Aggregate_Threshold),...
'Callback',@Calculate_Settings,...
'TooltipString','Set the threshold in units of the signal standard deviation.');
h.Cor.Remove_Aggregate_Timewindow_Edit = uicontrol(...
'Style','edit',...
'Parent',h.Cor.Aggregate_GridContainer,...
'FontSize',10,...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String',num2str(UserValues.Settings.Pam.Cor_Aggregate_Timewindow),...
'Callback',@Calculate_Settings,...
'TooltipString','Set the time window in units of milliseconds.');
h.Cor.Remove_Aggregate_TimeWindowAdd_Edit = uicontrol(...
'Style','edit',...
'Parent',h.Cor.Aggregate_GridContainer,...
'FontSize',10,...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'TooltipString','Add a time frame around detected bursts in units of the selected time window.',...
'String',num2str(UserValues.Settings.Pam.Cor_Aggregate_TimewindowAdd),...
'Callback',@Calculate_Settings);
h.Cor.Preview_Correlation_Checkbox = uicontrol(...
'Style','checkbox',...
'Parent',h.Cor.Aggregate_GridContainer,...
'FontSize',10,...
'BackgroundColor', Look.Back,...
'ForegroundColor', Look.Fore,...
'String','FCS preview',...
'Callback',[],...
'Value',0,...
'Callback',@Calculate_Settings);
%% Burst tab
s.ProgressRatio = 0.5;
h.Burst.Tab = uitab(...
'Parent',h.Det_Tabs,...
'Tag','Burst_Tab',...
'Title','Burst Analysis');
%%% Burst panel
h.Burst.MainPanel = uibuttongroup(...
'Parent',h.Burst.Tab,...
'Tag','Burst_Panel',...
'Units','normalized',...
'BackgroundColor', Look.Back,...
'ForegroundColor', Look.Fore,...
'HighlightColor', Look.Control,...
'ShadowColor', Look.Shadow,...
'Position',[0 0 1 1]);
%%% Sub Panels for easier ordering of stuff
h.Burst.SubPanel_Settings = uibuttongroup(...
'Parent',h.Burst.MainPanel,...
'Tag','Burst_SubPanel_Settings',...
'Units','normalized',...
'BackgroundColor', Look.Back,...
'ForegroundColor', Look.Fore,...
'HighlightColor', Look.Control,...
'ShadowColor', Look.Shadow,...
'Position',[0 0.55 .3 .45]);
h.Burst.SubPanel_BurstSearch = uibuttongroup(...
'Parent',h.Burst.MainPanel,...
'Tag','Burst_SubPanel_BurstSearch',...
'Units','normalized',...
'BackgroundColor', Look.Back,...
'ForegroundColor', Look.Fore,...
'HighlightColor', Look.Control,...
'ShadowColor', Look.Shadow,...
'Position',[0.3 0.55 .45 .45]);
%%% Axes for preview of Burst Selection
h.Burst.Axes_Intensity = axes(...
'Parent',h.Burst.MainPanel,...
'Tag','Burst_Axes_Intensity',...
'Position',[0.07 0.26 0.92 0.2],...
'Units','normalized',...
'NextPlot','add',...
'XColor',Look.Fore,...
'YColor',Look.Fore,...
'LineWidth', Look.AxWidth,...
'Box','on');
h.Burst.Axes_Intensity.XLabel.String='';
h.Burst.Axes_Intensity.XLabel.Color=Look.Fore;
h.Burst.Axes_Intensity.YLabel.String='Count rate [kHz]';
h.Burst.Axes_Intensity.YLabel.Color=Look.Fore;
h.Burst.Axes_Intensity.XLim = [0 1];
h.Burst.Axes_Intensity.YLim = [0 1];
h.Burst.Axes_Intensity.XAxisLocation = 'top';
h.Plots.BurstPreview.Channel1 = plot([0 1],[0 0],'g');
h.Plots.BurstPreview.Channel2 = plot([0 1],[0 0],'r');
h.Plots.BurstPreview.Channel3 = plot([0 1],[0 0],'b');
h.Plots.BurstPreview.Intensity_Threshold_ch1 = plot([0 1],[0 0],'--g','Visible','off');
h.Plots.BurstPreview.Intensity_Threshold_ch2 = plot([0 1],[0 0],'--r','Visible','off');
h.Plots.BurstPreview.Intensity_Threshold_ch3 = plot([0 1],[0 0],'--b','Visible','off');
h.Burst.Axes_Interphot = axes(...
'Parent',h.Burst.MainPanel,...
'Tag','Burst_Axes_Interphot',...
'Position',[0.07 0.06 0.92 0.2],...
'Units','normalized',...
'NextPlot','add',...
'XColor',Look.Fore,...
'YColor',Look.Fore,...
'LineWidth', Look.AxWidth,...
'YScale','log',...
'Box','on');
h.Burst.Axes_Interphot.XLabel.String='Time [s]';
h.Burst.Axes_Interphot.XLabel.Color=Look.Fore;
h.Burst.Axes_Interphot.YLabel.String='Interphoton time [\mus]';
h.Burst.Axes_Interphot.YLabel.Color=Look.Fore;
h.Burst.Axes_Interphot.XLim = [0 1];
h.Burst.Axes_Interphot.YLim = [0 1];
h.Plots.BurstPreview.Channel1_Interphot = plot([0 1],[0 0],'g');
h.Plots.BurstPreview.Channel2_Interphot = plot([0 1],[0 0],'r');
h.Plots.BurstPreview.Channel3_Interphot = plot([0 1],[0 0],'b');
h.Plots.BurstPreview.Interphoton_Threshold_ch1 = plot([0 1],[0 0],'--g','Visible','off');
h.Plots.BurstPreview.Interphoton_Threshold_ch2 = plot([0 1],[0 0],'--r','Visible','off');
h.Plots.BurstPreview.Interphoton_Threshold_ch3 = plot([0 1],[0 0],'--b','Visible','off');
linkaxes([h.Burst.Axes_Interphot,h.Burst.Axes_Intensity],'x');
%%% Button to show a preview of the burst search
h.Burst.BurstSearchPreview_Button = uicontrol(...
'Parent',h.Burst.MainPanel,...
'Tag','BurstSearchPreview_Button',...
'Units','normalized',...
'FontSize',12,...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String','Preview',...
'Callback',@BurstSearch_Preview,...
'Position',[0.865 0.43 0.12 0.025],...
'TooltipString',sprintf('Update the preview display.'));
%%%Buttons to shift the preview by one second forwards or backwards
h.Burst.BurstSearchPreview_Forward_Button = uicontrol(...
'Parent',h.Burst.MainPanel,...
'Tag','BurstSearchPreview_Forward_Button',...
'Units','normalized',...
'FontSize',12,...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String','>',...
'Callback',@BurstSearch_Preview,...
'Position',[0.835 0.43 0.03 0.025],...
'TooltipString',sprintf(''));
h.Burst.BurstSearchPreview_Backward_Button = uicontrol(...
'Parent',h.Burst.MainPanel,...
'Tag','BurstSearchPreview_Backward_Button',...
'Units','normalized',...
'FontSize',12,...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String','<',...
'Callback',@BurstSearch_Preview,...
'Position',[0.805 0.43 0.03 0.025],...
'TooltipString',sprintf(''));
%%% Button to start Burst Analysis
h.Burst.Button = uicontrol(...
'Parent',h.Burst.SubPanel_Settings,...
'Tag','Burst_Button',...
'Units','normalized',...
'FontSize',12,...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String','Do Burst Search',...
'Callback',@Do_BurstAnalysis,...
'Position',[0.05 0.9 0.9 0.08],...
'TooltipString',sprintf('Start Burst Analysis'));
%%% Right-click menu for Burst_Button to allow loading of performed
%%% BurstSearches for posterior Lifetime (re-)fitting and NirFilter
%%% (re-)calculation
h.Burst.Button_Menu = uicontextmenu;
h.Burst.Button_Menu_LoadData = uimenu(h.Burst.Button_Menu,...
'Label','Load performed BurstSearch',...
'Callback',@Load_Performed_BurstSearch);
h.Burst.Button_Menu_LoadData = uimenu(h.Burst.Button_Menu,...
'Label','Export total measurement to PDA',...
'Callback',@Export_total_to_PDA,...
'Separator','on');
h.Burst.Button_Menu_LoadData = uimenu(h.Burst.Button_Menu,...
'Label','Estimate background count rates from burst experiment',...
'Callback',@Estimate_Background_From_Burst,...
'Separator','on');
h.Burst.Button.UIContextMenu = h.Burst.Button_Menu;
%%% Right-click menu for BurstLifetime_Button to allow loading of
%%% IRF/Scatter AFTER performed burst search using stored PIE settings
h.Burst.BurstLifetime_Button_Menu = uicontextmenu;
h.Burst.BurstLifetime_Button_Menu_StoreIRF = uimenu(h.Burst.BurstLifetime_Button_Menu,...
'Label','Store current IRF in *.bur file',...
'Callback',{@Store_IRF_Scat_inBur,0});
h.Burst.BurstLifetime_Button_Menu_StoreScatter = uimenu(h.Burst.BurstLifetime_Button_Menu,...
'Label','Store current Scatter and background measurement in *.bur file',...
'Callback',{@Store_IRF_Scat_inBur,1});
h.Burst.BurstLifetime_Button_Menu_StorePhasorReference = uimenu(h.Burst.BurstLifetime_Button_Menu,...
'Label','Store current Phasor Reference in *.bur file',...
'Callback',{@Store_IRF_Scat_inBur,2});
h.Burst.BurstLifetime_Button_Menu_StoreDonorOnlyReference = uimenu(h.Burst.BurstLifetime_Button_Menu,...
'Label','Store current Donor-only Reference in *.bur file',...
'Callback',{@Store_IRF_Scat_inBur,3});
%%% Button to start burstwise Lifetime Fitting
h.Burst.BurstLifetime_Button = uicontrol(...
'Parent',h.Burst.SubPanel_Settings,...
'Tag','BurstLifetime_Button',...
'Units','normalized',...
'FontSize',12,...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String','Burstwise Lifetime',...
'Callback',@BurstLifetime,...
'Position',[0.05 0.5 0.9 0.08],...
'TooltipString',sprintf('Perform Burstwise Lifetime Fit or set Burstwise Lifetime settings'),...
'UIContextMenu',h.Burst.BurstLifetime_Button_Menu);
%%% Button to calculate 2CDE Filter
h.Burst.NirFilter_Button = uicontrol(...
'Parent',h.Burst.SubPanel_Settings,...
'Tag','NirFilter_Button',...
'Units','normalized',...
'FontSize',12,...
'BackgroundColor', Look.Control,...
'ForegroundColor', Look.Fore,...
'String','2CDE',...
'Callback',@NirFilter,...
'Position',[0.05 0.4 0.5 0.08],...
'TooltipString',sprintf('Calculate 2CDE Filter'));
%%% Checkbox to calculate 2CDE filter
h.Burst.NirFilter_Checkbox = uicontrol(...
'Parent',h.Burst.SubPanel_Settings,...
'Tag','NirFilter_Checkbox',...
'Style', 'checkbox',...
'Units','normalized',...
'FontSize',12,...
'Value',UserValues.BurstSearch.NirFilter,...
'BackgroundColor', Look.Back,...
'ForegroundColor', Look.Fore,...
'String','Calculate 2CDE',...
'Position',[0.05 0.8 0.9 0.08],...
'TooltipString',sprintf('Calculate 2CDE Filter when doing Burst Search'),...
'Callback', @Calculate_Settings);