-
Notifications
You must be signed in to change notification settings - Fork 0
/
ARLSpectralFittingGUI_exported.m
7204 lines (6313 loc) · 353 KB
/
ARLSpectralFittingGUI_exported.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
classdef ARLSpectralFittingGUI_exported < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
Franck_Condon_Lineshape_Analyser matlab.ui.Figure
UIAxes matlab.ui.control.UIAxes
SettingsButton matlab.ui.control.StateButton
FitParametersPanel matlab.ui.container.Panel
S_editField matlab.ui.control.NumericEditField
unitlessLabel matlab.ui.control.Label
S_slider matlab.ui.control.Slider
cmLabel_2 matlab.ui.control.Label
hw_slider matlab.ui.control.Slider
E_editField matlab.ui.control.NumericEditField
cmLabel matlab.ui.control.Label
E_slider matlab.ui.control.Slider
hw1_label matlab.ui.control.Label
S1_label matlab.ui.control.Label
E_minus_coarse matlab.ui.control.Button
E_plus_coarse matlab.ui.control.Button
E_minus_fine matlab.ui.control.Button
E_plus_fine matlab.ui.control.Button
S_minus_coarse matlab.ui.control.Button
S_plus_coarse matlab.ui.control.Button
S_minus_fine matlab.ui.control.Button
S_plus_fine matlab.ui.control.Button
hw_minus_coarse matlab.ui.control.Button
hw_plus_coarse matlab.ui.control.Button
hw_minus_fine matlab.ui.control.Button
hw_plus_fine matlab.ui.control.Button
v05_editField matlab.ui.control.NumericEditField
v05_minus_coarse matlab.ui.control.Button
v05_plus_coarse matlab.ui.control.Button
v05_minus_fine matlab.ui.control.Button
v05_plus_fine matlab.ui.control.Button
cmLabel_3 matlab.ui.control.Label
Label matlab.ui.control.Label
v05_slider matlab.ui.control.Slider
unitlessLabel_2 matlab.ui.control.Label
SLabel matlab.ui.control.Label
S2_slider matlab.ui.control.Slider
S2_editField matlab.ui.control.NumericEditField
S2_minus_coarse matlab.ui.control.Button
S2_plus_coarse matlab.ui.control.Button
S2_minus_fine matlab.ui.control.Button
S2_plus_fine matlab.ui.control.Button
cmLabel_4 matlab.ui.control.Label
Label_3 matlab.ui.control.Label
hw2_slider matlab.ui.control.Slider
hw2_editField matlab.ui.control.NumericEditField
hw2_minus_coarse matlab.ui.control.Button
hw2_plus_coarse matlab.ui.control.Button
hw2_minus_fine matlab.ui.control.Button
hw2_plus_fine matlab.ui.control.Button
Whatsthis_FixButton matlab.ui.control.StateButton
hw_editField matlab.ui.control.NumericEditField
E00CheckBox matlab.ui.control.CheckBox
SCheckBox matlab.ui.control.CheckBox
S2CheckBox matlab.ui.control.CheckBox
v05CheckBox matlab.ui.control.CheckBox
hwCheckBox matlab.ui.control.CheckBox
hw2CheckBox matlab.ui.control.CheckBox
E0Label matlab.ui.control.Label
E0_bounds_stateButton matlab.ui.control.StateButton
v05_bounds_stateButton matlab.ui.control.StateButton
S1_bounds_stateButton matlab.ui.control.StateButton
hw1_bounds_stateButton matlab.ui.control.StateButton
S2_bounds_stateButton matlab.ui.control.StateButton
hw2_bounds_stateButton matlab.ui.control.StateButton
S1CustomBoundsPanel matlab.ui.container.Panel
S1_upperbound_editBox matlab.ui.control.NumericEditField
UpperLimitLabel_3 matlab.ui.control.Label
S1_lowerbound_editBox matlab.ui.control.NumericEditField
LowerLimitLabel_3 matlab.ui.control.Label
Bothvaluesmustbewithin03Label matlab.ui.control.Label
hw1CustomBoundsPanel matlab.ui.container.Panel
hw1_upperbound_editBox matlab.ui.control.NumericEditField
UpperLimitLabel_4 matlab.ui.control.Label
hw1_lowerbound_editBox matlab.ui.control.NumericEditField
LowerLimitLabel_4 matlab.ui.control.Label
Bothvaluesmustbewithin04000cmLabel matlab.ui.control.Label
S2CustomBoundsPanel matlab.ui.container.Panel
S2_upperbound_editBox matlab.ui.control.NumericEditField
UpperLimitLabel_5 matlab.ui.control.Label
S2_lowerbound_editBox matlab.ui.control.NumericEditField
LowerLimitLabel_5 matlab.ui.control.Label
Bothvaluesmustbewithin03Label_2 matlab.ui.control.Label
hw2CustomBoundsPanel matlab.ui.container.Panel
hw2_upperbound_editBox matlab.ui.control.NumericEditField
UpperLimitLabel_6 matlab.ui.control.Label
hw2_lowerbound_editBox matlab.ui.control.NumericEditField
LowerLimitLabel_6 matlab.ui.control.Label
Bothvaluesmustbewithin04000cmLabel_2 matlab.ui.control.Label
HiddenPannel matlab.ui.container.Panel
Applicationisinsinglemode matlab.ui.control.Label
ResetAxesButton matlab.ui.control.Button
PopOutButton matlab.ui.control.Button
ResetParametersButton matlab.ui.control.Button
ExportDataButton matlab.ui.control.StateButton
CalculationsPanel matlab.ui.container.Panel
ClearButton matlab.ui.control.Button
CalculateButton matlab.ui.control.Button
Ges_TextBoxLabel matlab.ui.control.Label
ChromaticityCoordinateLabel matlab.ui.control.Label
Ges_Panel matlab.ui.container.Panel
chromaticity_Panel matlab.ui.container.Panel
chromaticity_TextBox matlab.ui.control.Label
Ges_TextBox matlab.ui.control.Label
PredictedColorLabel matlab.ui.control.Label
Color_Panel matlab.ui.container.Panel
CIEPopoutStateButton matlab.ui.control.StateButton
DisabledLabel matlab.ui.control.Label
RLabel matlab.ui.control.Label
ImportDataButton matlab.ui.control.StateButton
ImportDataOptionsPanel matlab.ui.container.Panel
ImportDataOptionsLabel matlab.ui.control.Label
ExcitationButton matlab.ui.control.Button
EmissionButton matlab.ui.control.Button
Optimizationhasbeenrunnings matlab.ui.control.Label
PlotfitFunctionButton matlab.ui.control.Button
PlottingLampLabel matlab.ui.control.Label
PlottingLamp matlab.ui.control.Lamp
OptimizeFitButton matlab.ui.control.Button
OptimizingLampLabel matlab.ui.control.Label
OptimizingLamp matlab.ui.control.Lamp
SelectedSpectrumLabel matlab.ui.control.Label
ExportDataOptionsPanel matlab.ui.container.Panel
ExportDataOptionsLabel matlab.ui.control.Label
FCLSAPanel matlab.ui.container.Panel
FigureButton matlab.ui.control.Button
ParametervaluesButton matlab.ui.control.Button
SpectrumdatapointsButton matlab.ui.control.Button
FitdatapointsButton matlab.ui.control.Button
ColorAnalysisPanel matlab.ui.container.Panel
ColorValuesButton matlab.ui.control.Button
ChromaticityDiagramButton matlab.ui.control.Button
SelectSpectrumPanel matlab.ui.container.Panel
SelectSpectrumLabel matlab.ui.control.Label
CancelOptimizationButton matlab.ui.control.Button
SelectSpectrumtoFitButton matlab.ui.control.StateButton
FixParameterPanel matlab.ui.container.Panel
FixParameterLabel matlab.ui.control.Label
InfoButton matlab.ui.control.StateButton
ClearDataButton matlab.ui.control.Button
InfoPanel matlab.ui.container.Panel
AboutUsTabGroup matlab.ui.container.TabGroup
AboutUsTab matlab.ui.container.Tab
ARLSpectralFittingv10Panel matlab.ui.container.Panel
AboutLabel matlab.ui.control.Label
WhyFCLSALabel matlab.ui.control.Label
PointsofContactLabel matlab.ui.control.Label
PointsofContactBodyLabel matlab.ui.control.Label
AcknowledgmentLabel matlab.ui.control.Label
AcknowledgmentBodyLabel matlab.ui.control.Label
Image matlab.ui.control.Image
CitedFunctionsTab matlab.ui.container.Tab
MathWorksFileExchangePanel matlab.ui.container.Panel
DanzLabel matlab.ui.control.Label
EganLabel matlab.ui.control.Label
DErricoLabel matlab.ui.control.Label
GreeneLabel matlab.ui.control.Label
OtherPanel matlab.ui.container.Panel
CIELabel matlab.ui.control.Label
BambhaLabel matlab.ui.control.Label
LiteratureReferencesTab matlab.ui.container.Tab
ZanoniLabel matlab.ui.control.Label
MurtazaLabel matlab.ui.control.Label
DossingLabel matlab.ui.control.Label
ClaudeLabel matlab.ui.control.Label
LiteratureReferencesLabel matlab.ui.control.Label
ZanoniLabel_2 matlab.ui.control.Label
ZanoniLabel_3 matlab.ui.control.Label
SampleSpectraTab matlab.ui.container.Tab
OrganicDye910diphenylanthraceneinTOLPanel matlab.ui.container.Panel
LoadEmissionData_292_organic matlab.ui.control.Button
LoadEmissionData_77_organic matlab.ui.control.Button
LoadExcitationData_292_organic matlab.ui.control.Button
IridiumDyeIrpbtacacin2MeTHFPanel matlab.ui.container.Panel
LoadEmissionData_292_Ir matlab.ui.control.Button
LoadExcitationData_292_Ir matlab.ui.control.Button
LoadEmissionData_77_Ir matlab.ui.control.Button
RutheniumDyeRubpyClin31vvEtOHMeOHPanel matlab.ui.container.Panel
LoadExcitationData_292_Ru matlab.ui.control.Button
LoadEmissionData_292_Ru matlab.ui.control.Button
LoadEmissionData_77_Ru matlab.ui.control.Button
SelectIntersectPanel matlab.ui.container.Panel
SelectPointDialogue matlab.ui.control.Label
PointSelectedButton matlab.ui.control.Button
SettingsPanel matlab.ui.container.Panel
TabGroup matlab.ui.container.TabGroup
GeneralTab matlab.ui.container.Tab
GeneralSettingsPanel matlab.ui.container.Panel
Allowmultipleimportedspectra matlab.ui.control.CheckBox
RetrieveimportfiletitleCheckBox matlab.ui.control.CheckBox
FigureSettingsLabel matlab.ui.control.Label
ShowdatapeaklabelsCheckBox matlab.ui.control.CheckBox
ShowlegendongraphCheckBox matlab.ui.control.CheckBox
Formatfiguresforpublicationbeforeex matlab.ui.control.CheckBox
IntensityNormalizationLabel matlab.ui.control.Label
NormalizespectratohighCheckBox matlab.ui.control.CheckBox
SelectpeakfornormalizationButton matlab.ui.control.Button
Requiresatleastonespectrum matlab.ui.control.Label
RenormalizeallspectraButton matlab.ui.control.Button
YAxisLimitsButtonGroup matlab.ui.container.ButtonGroup
SetYAxismaximumvalueto1Button matlab.ui.control.RadioButton
ShowalldatapeaksautoButton matlab.ui.control.RadioButton
YAxisSettingsLabel matlab.ui.control.Label
ShowTips matlab.ui.control.CheckBox
Correctforshift_checkbox matlab.ui.control.CheckBox
XAxisTab matlab.ui.container.Tab
XAxisSettingsButtonGroup matlab.ui.container.ButtonGroup
ManuallyadjustXaxisandfitlim matlab.ui.control.RadioButton
AutofitXaxisandfitlimitsButton matlab.ui.control.RadioButton
XAxisAutofitLabel matlab.ui.control.Label
Panel matlab.ui.container.Panel
Xmax_editField matlab.ui.control.NumericEditField
XmaximumSliderLabel matlab.ui.control.Label
XmaximumSlider matlab.ui.control.Slider
cmLabel_5 matlab.ui.control.Label
Xmin_editField matlab.ui.control.NumericEditField
XminimumSliderLabel matlab.ui.control.Label
XminimumSlider matlab.ui.control.Slider
cmLabel_6 matlab.ui.control.Label
Xres_editField matlab.ui.control.NumericEditField
XresolutionSliderLabel matlab.ui.control.Label
XresolutionSlider matlab.ui.control.Slider
cmLabel_7 matlab.ui.control.Label
nmLabel matlab.ui.control.Label
nmLabel_2 matlab.ui.control.Label
Wave_switch matlab.ui.control.Switch
Xaxiswithfit_checkBox matlab.ui.control.CheckBox
Autofit_transparent_panel matlab.ui.container.Panel
XAxisvaluesarebeingcontroll matlab.ui.control.Label
FitTab matlab.ui.container.Tab
FittingFunctionSettingsPanel matlab.ui.container.Panel
AutomaticallycalculateCoefficient matlab.ui.control.CheckBox
Automaticallyplotfit matlab.ui.control.CheckBox
E00ButtonGroup matlab.ui.container.ButtonGroup
FullFCSLAfitButton matlab.ui.control.RadioButton
XRuleButton matlab.ui.control.RadioButton
E0CalculationLabel matlab.ui.control.Label
Intersectionofemission matlab.ui.control.RadioButton
percentRuleDropDown matlab.ui.control.DropDown
SumLimitsLabel matlab.ui.control.Label
SumUpperLimitSpinnerLabel_7 matlab.ui.control.Label
SumUpperLimitSpinner matlab.ui.control.Spinner
SumLowerLimitSpinnerLabel matlab.ui.control.Label
SumLowerLimitSpinner matlab.ui.control.Spinner
Sum2LowerLimitSpinnerLabel matlab.ui.control.Label
Sum2LowerLimitSpinner matlab.ui.control.Spinner
Sum2UpperLimitSpinnerLabel matlab.ui.control.Label
Sum2UpperLimitSpinner matlab.ui.control.Spinner
Sum1LowerHidden matlab.ui.control.Label
Sum1UpperHidden matlab.ui.control.Label
Mode_switch matlab.ui.control.Switch
SumHiders matlab.ui.container.Panel
SumHiderLabel matlab.ui.control.Label
OptimizationTab matlab.ui.container.Tab
OptimizationSettingsPanel matlab.ui.container.ButtonGroup
SpecifymaxvalueofiterationsCheckBox matlab.ui.control.CheckBox
MaxIter_EditField matlab.ui.control.NumericEditField
TolFun_EditField matlab.ui.control.NumericEditField
SpecifytermtoleranceFunCheckBox matlab.ui.control.CheckBox
TolX_EditField matlab.ui.control.NumericEditField
SpecifytermtoleranceXCheckBox matlab.ui.control.CheckBox
RobustFitOptionsDropDownLabel matlab.ui.control.Label
RobustFitOptionsDropDown matlab.ui.control.DropDown
ShowallGoFStatisticsCheckBox matlab.ui.control.CheckBox
OptimizationMethod_Switch matlab.ui.control.Switch
Custombounds_checkBox matlab.ui.control.CheckBox
EndTriggerLabel matlab.ui.control.Label
ResetCustomBoundsButton matlab.ui.control.Button
Savecommandline_checkbox matlab.ui.control.CheckBox
DataWeightingTab matlab.ui.container.Tab
OptimizationSettingsPanel_2 matlab.ui.container.ButtonGroup
Thresholdweight_EditField matlab.ui.control.NumericEditField
WeightMultiplier13Label_2 matlab.ui.control.Label
Thresholdintensity_EditField matlab.ui.control.NumericEditField
ThresholdIntensity01Label_2 matlab.ui.control.Label
ThresholdweightingCheckBox matlab.ui.control.CheckBox
ThresholdWeightingLabel matlab.ui.control.Label
Thresholddataweighting_panel matlab.ui.container.Panel
Dataweightingisnotavailable_2 matlab.ui.control.Label
ExtremaWeight_EditField matlab.ui.control.NumericEditField
WeightMultiplier120Label matlab.ui.control.Label
WeightextremaCheckBox matlab.ui.control.CheckBox
ExtremaWeightingLabel matlab.ui.control.Label
Numberofpoints_EditField matlab.ui.control.NumericEditField
Numberofweightedpointssurroundingextrema115Label matlab.ui.control.Label
Fillsalientpoints_checkBox matlab.ui.control.CheckBox
Extremadataweighting_panel matlab.ui.container.Panel
Dataweightingisnotavailable_3 matlab.ui.control.Label
CalculationsTab matlab.ui.container.Tab
CalculationsSettingsButtonGroup matlab.ui.container.ButtonGroup
KButton_298 matlab.ui.control.RadioButton
KButton_77 matlab.ui.control.RadioButton
KButton_Other matlab.ui.control.RadioButton
AutomaticallycalculateGs matlab.ui.control.CheckBox
Temp_EditField matlab.ui.control.NumericEditField
IncludeGsandCIEondataexport matlab.ui.control.CheckBox
AutomaticallycalculateCIE matlab.ui.control.CheckBox
GsUnitsDropDownLabel matlab.ui.control.Label
GesUnitsDropDown matlab.ui.control.DropDown
multiCIECheckBox matlab.ui.control.CheckBox
Enablecolor_checkBox matlab.ui.control.CheckBox
ColorAnalysisLabel matlab.ui.control.Label
WhitePointIlluminantLabel matlab.ui.control.Label
WhitePoint_DropDown matlab.ui.control.DropDown
Experimental_temp_label matlab.ui.control.Label
FreeEnergyoftheExcitedStateLabel matlab.ui.control.Label
GoFLabel matlab.ui.control.Label
Whatsthis_GoFButton matlab.ui.control.StateButton
GoFStatisticsPanel matlab.ui.container.Panel
GoFStatisticsLabel matlab.ui.control.Label
CIESelectPanel matlab.ui.container.Panel
CIESlectedLabel matlab.ui.control.Label
DisplayDiagram_StateButton matlab.ui.control.StateButton
ExportValuesButton matlab.ui.control.Button
SelectSpectra_ScrollablePanel matlab.ui.container.Panel
E0CustomBoundsPanel matlab.ui.container.Panel
E0_upperbound_editBox matlab.ui.control.NumericEditField
UpperboundLabel matlab.ui.control.Label
E0_lowerbound_editBox matlab.ui.control.NumericEditField
LowerboundLabel matlab.ui.control.Label
Bothvaluesmustbewithin040000cmLabel matlab.ui.control.Label
v05CustomBoundsPanel matlab.ui.container.Panel
v05_upperbound_editBox matlab.ui.control.NumericEditField
UpperboundLabel_2 matlab.ui.control.Label
v05_lowerbound_editBox matlab.ui.control.NumericEditField
LowerboundLabel_2 matlab.ui.control.Label
Bothvaluesmustbewithin05000cmLabel matlab.ui.control.Label
PointSelectedPanel matlab.ui.container.Panel
PointSelectedDialogue matlab.ui.control.Label
ReselectButton matlab.ui.control.Button
ContinueButton matlab.ui.control.Button
end
% Points of contact:
% Wiliam R. Roberts ˙ wrrobert@buffalo.edu
% Ryan M. O'Donnell, Ph.D. ˙ ryan.m.odonnell12.civ@mail.mil
properties (Access = private)
% changable parameter values
E_value = 20000;
hw_value = 1400;
S_value = 1;
v05_value = 1000;
hw2_value = 700;
S2_value = 1;
% changable x-axis settings
Xmin = 11000;
Xmax = 33500;
Xres = 50;
% changable experimental temperature
T_value = 298;
% static original parameter values
E_value_original = 20000;
hw_value_original = 1400;
S_value_original = 1;
v05_value_original = 1000;
hw2_value_original = 700;
S2_value_original = 1;
% static orginal x-axis settings
Xmin_original = 11000;
Xmax_original = 33500;
Xres_original = 50;
% static original temperature
T_value_original = 298;
% used to keep track of the fit and loaded data
fitPlotted = false;
dataplotted = table(0, 0, 0, 0, 0, 'VariableNames', {'filename', 'fullFile', 'scatter', 'normalpeakheight', 'emission'});
selectedfile = {0, 0, 0, 0};
% x- and y-data used to calculate the fit function, among other
% things
xToFit_number = 0;
yToFit_number = 0;
xToFit_length = 0;
yToFit_length = 0;
% Properties used to keep track of settings
isdouble = false;
wave = "Wavenumber";
autoplot = true;
normalize = true;
multipleGraphs = false;
showpeaks = true;
pubformat = true;
showlegend = false;
fittodata = true;
autocalc = false;
autoCIE = false;
exportcalc = true;
metadata = true;
tightconstraints = true;
autodeterm = true;
Ges_units = 'cm';
E0method = 'fclsa';
multiCIE = true;
ciespectra = {};
peaks = 0;
cieCoord = "";
rgbValue1 = "";
rgbValue255 = "";
hexValue = "";
diaryfile = "";
% Changable sum upper and lower limits for the fit function
Sum1upper = 5;
Sum1lower = 0;
Sum2upper = 5;
Sum2lower = 0;
% Static original sum upper and lower limits for the fit function
Sum1upper_original = 5;
Sum1Lower_original = 0;
Sum2upper_original = 5;
Sum2lower_original = 0;
% manage popped-out figure
activefigure = 0;
% used when selecting a point on the graph
intersectingspectra = [];
select = '';
upperbound = 0;
lowerbound = 0;
percentrule = 0;
% Properties used to keep track of optimization settings
weightmultiplier = 1.2;
weightthreshold = 0.1;
optmethod = 'LS';
fixed = {};
maxIter = 40;
TolFun = 1e-6;
TolX = 1e-6;
robust = 'off';
showgof = true;
showgofstore = true;
% keeps track of the chromaticity diagram
chromchart = 0;
end
methods (Access = private)
% function used to select or load a data file to import, calls
% processdata
function loaddata(app, fileToOpen, emission, toplot, normalpeakheight, E00)
% choose a file desination of load given file
delete(findall(app.UIAxes, 'Tag', 'Highlightedpoint'));
if isequal(string(fileToOpen), string(0))
[filename,filedir] = uigetfile({'*.txt;*.csv;*.xls;*.xlsx'},'','Multiselect','on');
fullFile = strcat(filedir, filename);
else
fullFile = string(fileToOpen);
end
% handles multi-select
if isequal(string(class(fullFile)), "cell")
app.Allowmultipleimportedspectra.Value = true;
app.multipleGraphs = true;
for k = 1:length(filename)
[~, filename, filetype] = fileparts(string(fullFile(k)));
if isequal(filetype, 'txt')
yourData = dlmread(fullFile(k), ' ', 2, 0);
xAxis = yourData(1:2:end, :);
adjustedEmission = yourData(2:2:end, :);
else
yourData = readmatrix(string(fullFile(k)), 'Range', 'A:B');
try
if ~isequal(string(class(round(max(yourData(:,2))))), 'double') || isempty(round(max(yourData(:,1))))
error('');
end
catch
yourData = table2array(readtable(fullFile, 'HeaderLines', 1, 'Delimiter', ','));
newarray = zeros(size(yourData,1), 2);
for i = 1:size(yourData,1)
split = strsplit(yourData{i,1}, ',');
newarray(i,:) = [str2double(string(split(1))), str2double(string(split(2)))];
end
yourData = newarray;
end
xAxis = yourData(:,1);
adjustedEmission = yourData(:,2);
end
processdata(app, xAxis, adjustedEmission, filename, fullFile(k), emission, normalpeakheight, toplot, E00);
end
elseif ~isempty(fullFile)
[~, filename, filetype] = fileparts(string(fullFile));
if isequal(filetype, 'txt')
yourData = dlmread(fullFile, ' ', 2, 0);
xAxis = yourData(1:2:end, :);
adjustedEmission = yourData(2:2:end, :);
else
yourData = readmatrix(fullFile, 'Range', 'A:B');
try
if ~isequal(string(class(round(max(yourData(:,2))))), 'double') || isempty(round(max(yourData(:,1))))
error('')
end
catch
yourData = table2array(readtable(fullFile, 'HeaderLines', 1, 'Delimiter', ','));
disp(yourData)
newarray = zeros(size(yourData,1), 2);
for i = 1:size(yourData,1)
split = strsplit(yourData{i,1}, ',');
newarray(i,:) = [str2double(string(split(1))), str2double(string(split(2)))];
end
yourData = newarray;
end
xAxis = yourData(:,1);
adjustedEmission = yourData(:,2);
end
processdata(app, xAxis, adjustedEmission, filename, fullFile, emission, normalpeakheight, toplot, E00);
end
end
% function called by loaddata, processes (conversion to
% wavenumber/wavelength) and records data, calls plotdata if
% necessary
function processdata(app, xAxis, yAxis, filename, filewithpath, emission, normalpeakheight, toplot, E00)
if startsWith(filename, "Em:")
emission = true;
elseif startsWith(filename, "Ex:")
emission = false;
end
if ~startsWith(filename, ["Em:", "Ex:"])
if emission
filename = strcat("Em: ", filename);
else
filename = strcat("Ex: ", filename);
end
end
% record data in both wavenumber and wavelength
inWavenumber = false;
if max(xAxis) > 2000
inWavenumber = true;
end
sortedTable = sortrows(table(xAxis, yAxis));
sortedTable = sortedTable(~any(ismissing(sortedTable),2),:);
xAxisToPlot = sortedTable{:,1};
yAxisToPlot = sortedTable{:,2};
if app.Correctforshift_checkbox.Value
yAxisToPlot = yAxisToPlot - min(yAxisToPlot);
end
if app.normalize
yAxisToPlot = yAxisToPlot ./ max(yAxisToPlot);
yAxisToPlot = yAxisToPlot ./ normalpeakheight;
end
if ~inWavenumber
app.xToFit_length = xAxisToPlot;
app.yToFit_length = yAxisToPlot;
yAxisToPlot = yAxisToPlot .* (xAxisToPlot .^ 2);
xAxisToPlot = 10000000 ./ xAxisToPlot;
if app.normalize
yAxisToPlot = yAxisToPlot ./ max(yAxisToPlot);
yAxisToPlot = yAxisToPlot ./ normalpeakheight;
end
sortedTable = sortrows(table(xAxisToPlot, yAxisToPlot));
app.xToFit_number = sortedTable{:,1};
app.yToFit_number = sortedTable{:,2};
elseif inWavenumber
app.xToFit_number = xAxisToPlot;
app.yToFit_number = yAxisToPlot;
xAxisToPlot = 10000000 ./ xAxisToPlot;
yAxisToPlot = yAxisToPlot ./ (xAxisToPlot .^ 2);
if app.normalize
yAxisToPlot = yAxisToPlot ./ max(yAxisToPlot);
yAxisToPlot = yAxisToPlot ./ normalpeakheight;
end
sortedTable = sortrows(table(xAxisToPlot, yAxisToPlot));
app.xToFit_length = sortedTable{:,1};
app.yToFit_length = sortedTable{:,2};
end
app.selectedfile = {filename, filewithpath, emission, normalpeakheight};
app.SelectedSpectrumLabel.Text = ["Spectrum selected for fitting is ", filename];
if isequal(app.wave, 'Wavelength')
xAxisToPlot = app.xToFit_length;
yAxisToPlot = app.yToFit_length;
else
xAxisToPlot = app.xToFit_number;
yAxisToPlot = app.yToFit_number;
end
% adjust x-axis to fit data
if app.fittodata
x_max = max(xAxisToPlot);
app.Xmax = round(x_max);
app.Xmax_editField.Value = round(x_max);
app.XmaximumSlider.Value = x_max;
x_min = min(xAxisToPlot);
app.Xmin = round(x_min);
app.Xmin_editField.Value = round(x_min);
app.XminimumSlider.Value = x_min;
set(app.UIAxes, 'XLimMode', 'auto');
end
% resets other parameter values
app.v05_editField.Value = app.v05_value_original;
app.v05_slider.Value = app.v05_value_original;
app.v05_value = app.v05_value_original;
app.S_editField.Value = app.S_value_original;
app.S_slider.Value = app.S_value_original;
app.S_value = app.S_value_original;
app.S2_editField.Value = app.S2_value_original;
app.S2_slider.Value = app.S2_value_original;
app.S2_value = app.S2_value_original;
app.hw_editField.Value = app.hw_value_original;
app.hw_slider.Value = app.hw_value_original;
app.hw_value = app.hw_value_original;
app.hw2_editField.Value = app.hw2_value_original;
app.hw2_slider.Value = app.hw2_value_original;
app.hw2_value = app.hw2_value_original;
% peak finding
minDistance = 300;
if isequal(app.wave, "Wavelength")
minDistance = 5;
end
[pks, locs] = findpeaks(app.yToFit_number, app.xToFit_number, 'MinPeakDistance', minDistance, 'MinPeakProminence', 0.018);
app.peaks = [pks, locs];
if isequal(app.E0method, "fclsa")
Eval = round(max(locs));
app.E_slider.Value = Eval;
app.E_editField.Value = Eval;
app.E_value = Eval;
end
if length(pks) > 1 && emission
sortedlocs = flip(sort(locs));
distarray = zeros([1 (length(sortedlocs)-1)]);
for i=1:(length(sortedlocs)-1)
distarray(i) = sortedlocs(i) - sortedlocs(i+1);
end
value = round(sum(distarray) ./ length(distarray));
app.hw_value = value;
app.hw_editField.Value = value;
app.hw_slider.Value = value;
app.hw2_value = value ./ 2;
app.hw2_editField.Value = value ./ 2;
app.hw2_slider.Value = value ./ 2;
end
if toplot
plotdata(app, xAxisToPlot, yAxisToPlot, filename, filewithpath, emission, normalpeakheight, E00);
end
resetBounds(app);
% reset color analysis values
resetColor(app);
if app.autoCIE
calculateCIEsingle(app);
end
end
% function called by processdata, if applicable. Takes processed
% data and adds to UIAxes
function plotdata(app, xAxisToPlot, yAxisToPlot, filename, filewithpath, emission, normalpeakheight, E00)
% clears other spectra
if ismember(filename, string(app.dataplotted.filename))
delete(findobj(app.UIAxes, 'DisplayName', filename));
delete(findobj(app.UIAxes, 'Tag', filename));
app.dataplotted(filename, :) = [];
end
if ~app.multipleGraphs && height(app.dataplotted) > 0
delete(findobj(app.UIAxes,'Type','scatter'));
delete(findobj(app.UIAxes, 'Type', 'text'));
app.dataplotted(2:height(app.dataplotted), :) = [];
end
% plot spectrum
s = scatter(app.UIAxes, flip(xAxisToPlot), flip(yAxisToPlot),'DisplayName', filename, 'Tag', 'Showonlegend');
if app.metadata && height(app.dataplotted) <= 2
app.UIAxes.Title.String = filename;
end
if ~emission
s.Marker = 'd';
end
% display peaks, if desired
if app.showpeaks
if isequal(app.wave, "Wavelength")
minDistance = 5;
else
minDistance = 300;
end
[pks, locs] = findpeaks(yAxisToPlot, xAxisToPlot, 'MinPeakDistance', minDistance, 'MinPeakProminence', 0.018);
for pk=1:length(pks)
if isequal(app.wave, 'Wavelength')
msg = [strcat('\leftarrow', strcat(string(round(locs(pk)))," nm")); strcat(" ", strcat(string(round(10000000./locs(pk))), " cm˙š"))];
else
msg = [strcat('\leftarrow', strcat(string(round(locs(pk)))," cm˙š")); strcat(" ", strcat(string(round(10000000./locs(pk))), " nm"))];
end
text(app.UIAxes, locs(pk), pks(pk), msg, 'Color', [0.65,0.65,0.65], "FontName", "Arial", 'Tag', filename);
end
set(findobj(app.UIAxes, 'Type', 'Text'), 'Visible', 'on');
else
set(findobj(app.UIAxes, 'Type', 'Text'), 'Visible', 'off');
end
% records data to table
app.dataplotted = [app.dataplotted; {filename, filewithpath, s, normalpeakheight, emission}];
app.dataplotted.Properties.RowNames = app.dataplotted.filename;
% adjusts graph based on number of loaded spectra
if height(app.dataplotted) > 2
app.showlegend = true;
makelegend(app)
if app.metadata
app.UIAxes.Title.String = 'Relative Intensity vs. Wavenumber';
end
app.ShowlegendongraphCheckBox.Value = true;
app.ShowlegendongraphCheckBox.Enable = 'off';
elseif isequal(height(app.dataplotted), 2)
app.SelectpeakfornormalizationButton.Enable = 'on';
app.RenormalizeallspectraButton.Enable = 'on';
end
if E00
E00calcchanged(app);
end
changeCIEicon(app)
end
% function called by plotdata. Formats and, if applicable, reveals
% legend on UIAxes
function makelegend(app)
lgd = legend(app.UIAxes);
lgd.FontSize = 10;
lgd.FontName = 'Arial';
lgd.TextColor = [0.65,0.65,0.65];
lgd.EdgeColor = [0.65,0.65,0.65];
lgd.Title.String = 'Legend';
lgd.Title.FontName = 'Arial Rounded MT Bold';
lgd.NumColumnsMode = 'manual';
lgd.NumColumns = 1;
lgd.Interpreter = 'none';
if app.showlegend
lgd.Visible = 'on';
else
lgd.Visible = 'off';
end
end
% function called by select spectrum button. Loads selected data
% spectrum
function selectspectrum(app, fname)
app.SelectSpectrumPanel.Visible = 'off';
app.SelectSpectrumtoFitButton.Enable = 'off';
selectedrow = app.dataplotted(fname, :);
loaddata(app, selectedrow.fullFile, true, false, selectedrow.normalpeakheight, true);
app.SelectSpectrumtoFitButton.Enable = 'on';
end
% function called when Optimize Fit is chosen. Calls the built-in
% MATLAB fit function
function LSoptimize(app)
% loads and constrains data to x-axis
xToFit = app.xToFit_number;
yToFit = app.yToFit_number;
if ~app.fittodata
lower = app.Xmin;
upper = app.Xmax;
for i=length(xToFit):1
if ~(xToFit(i) >= lower && xToFit(i) <= upper)
xToFit(i) = [];
yToFit(i) = [];
end
end
end
% initializes start points, parameters to optimize, and bounds
delete(findall(app.UIAxes, 'Tag', 'Highlightedpoint'));
if ~app.isdouble
b = [app.E_value, app.hw_value, app.S_value, app.v05_value];
if app.Custombounds_checkBox.Value
lb = [app.E0_lowerbound_editBox.Value, app.hw1_lowerbound_editBox.Value, app.S1_lowerbound_editBox.Value, app.v05_lowerbound_editBox.Value];
ub = [app.E0_upperbound_editBox.Value, app.hw1_upperbound_editBox.Value, app.S1_upperbound_editBox.Value, app.v05_upperbound_editBox.Value];
else
lb = [0, 0, 0, 0];
ub = [40000, 4000, 3, 5000];
end
% creates function to optimize
sumone = app.Sum1lower:app.Sum1upper;
sumtwo = app.Sum2lower:app.Sum2upper;
anonlinfit = @(E, hw, S, v05, x)linfit(E, hw, S, v05, '', '', x, sumone, sumtwo);
else
b = [app.E_value, app.hw_value, app.S_value, app.v05_value, app.hw2_value, app.S2_value];
if app.Custombounds_checkBox.Value
lb = [app.E0_lowerbound_editBox.Value, app.hw1_lowerbound_editBox.Value, app.S1_lowerbound_editBox.Value, app.v05_lowerbound_editBox.Value, app.hw2_lowerbound_editBox.Value, app.S2_lowerbound_editBox.Value];
ub = [app.E0_upperbound_editBox.Value, app.hw1_upperbound_editBox.Value, app.S1_upperbound_editBox.Value, app.v05_upperbound_editBox.Value, app.hw2_upperbound_editBox.Value, app.S2_upperbound_editBox.Value];
else
lb = [0, 0, 0, 0, 0, 0];
ub = [40000, 4000, 3, 5000, 4000, 3];
end
% creates function to optimize
sumone = app.Sum1lower:app.Sum1upper;
sumtwo = app.Sum2lower:app.Sum2upper;
anonlinfit = @(E, hw, S, v05, hw2, S2, x)linfit(E, hw, S, v05, hw2, S2, x, sumone, sumtwo);
end
% fixes parameters
problem = app.fixed;
for i=1:length(problem)
probvar = problem{i};
if isequal(probvar, 'E')
lb(1) = b(1);
ub(1) = b(1);
elseif isequal(probvar, 'hw1')
lb(2) = b(2);
ub(2) = b(2);
elseif isequal(probvar, 'S1')
lb(3) = b(3);
ub(3) = b(3);
elseif isequal(probvar, 'v05')
lb(4) = b(4);
ub(4) = b(4);
elseif isequal(probvar, 'hw2')
msgbox(string(app.isdouble));
if app.isdouble
lb(5) = b(5);
ub(5) = b(5);
end
elseif isequal(probvar, 'S2')
if app.isdouble
lb(6) = b(6);
ub(6) = b(6);
end
end
end
% threshold weighting
w = ones(length(yToFit), 1);
if app.ThresholdweightingCheckBox.Value
multiplier = app.weightmultiplier;
threshold = app.weightthreshold;
for l=1:length(yToFit)
if yToFit(l)>threshold
w(l) = multiplier;
end
end
end
% extrema weighting
delete(findall(app.UIAxes, 'Tag', 'Highlightedpoint'));
if app.WeightextremaCheckBox.Value
[~, pkidx] = findpeaks(app.yToFit_number, app.xToFit_number, 'MinPeakDistance', 50, 'MinPeakProminence', 0.018);
[~, vlidx] = findpeaks(1 - app.yToFit_number, app.xToFit_number, 'MinPeakDistance', 50, 'MinPeakProminence', 0.018);
numpoints = round(app.Numberofpoints_EditField.Value ./ 2);
wght = app.ExtremaWeight_EditField.Value;
color = get(findobj(app.UIAxes, 'DisplayName', app.selectedfile{1}), 'CData');
fillpoints = app.Fillsalientpoints_checkBox.Value;
for l=1:length(pkidx)
i = find(app.xToFit_number==pkidx(l));
w(i) = wght;
if fillpoints
scatter(app.UIAxes, app.xToFit_number(i), app.yToFit_number(i), 'filled', 'MarkerFaceColor', color, 'Tag', 'Highlightedpoint', 'HandleVisibility','off');
end
for k=1:numpoints
w(i-k) = wght;
w(i+k) = wght;
if fillpoints
scatter(app.UIAxes, app.xToFit_number(i-k), app.yToFit_number(i-k), 'filled', 'MarkerFaceColor', color, 'Tag', 'Highlightedpoint', 'HandleVisibility','off');
scatter(app.UIAxes, app.xToFit_number(i+k), app.yToFit_number(i+k), 'filled', 'MarkerFaceColor', color, 'Tag', 'Highlightedpoint', 'HandleVisibility','off');
end
end
end
for l=1:length(vlidx)
i = find(app.xToFit_number==vlidx(l));
w(i) = wght;
if fillpoints
scatter(app.UIAxes, app.xToFit_number(i), app.yToFit_number(i), 'filled', 'MarkerFaceColor', color, 'Tag', 'Highlightedpoint', 'HandleVisibility','off');
end
for k=1:numpoints
w(i-k) = wght;
w(i+k) = wght;
if fillpoints
scatter(app.UIAxes, app.xToFit_number(i-k), app.yToFit_number(i-k), 'filled', 'MarkerFaceColor', color, 'Tag', 'Highlightedpoint', 'HandleVisibility','off');
scatter(app.UIAxes, app.xToFit_number(i+k), app.yToFit_number(i+k), 'filled', 'MarkerFaceColor', color, 'Tag', 'Highlightedpoint', 'HandleVisibility','off');
end
end
end
end
modelfun = fittype(anonlinfit);
[mdl, gof] = fit(xToFit, yToFit, modelfun, 'StartPoint', b, 'Weights', w, 'Lower', lb, 'Upper', ub, 'Display', 'iter', 'MaxIter', app.maxIter, 'TolFun', app.TolFun, 'TolX', app.TolX, 'Robust', app.robust);
x = coeffvalues(mdl);
app.E_value = round(x(1));
app.E_editField.Value = round(x(1));
app.E_slider.Value = round(x(1));
app.hw_value = round(x(2));
app.hw_editField.Value = round(x(2));
app.hw_slider.Value = round(x(2));
app.S_value = round(x(3), 3, 'significant');
app.S_editField.Value = round(x(3), 3, 'significant');
app.S_slider.Value = round(x(3), 3, 'significant');
app.v05_value = round(x(4));
app.v05_editField.Value = round(x(4));
app.v05_slider.Value = round(x(4));
if app.isdouble
app.hw2_value = round(x(5));
app.hw2_editField.Value = round(x(5));
app.hw2_slider.Value = round(x(5));
app.S2_value = round(x(6), 3, 'significant');
app.S2_editField.Value = round(x(6), 3, 'significant');
app.S2_slider.Value = round(x(6), 3, 'significant');
end
drawnow;
% replot, display GoF stats
plotfit(app);
drawnow;
ar2 = num2str(gof.adjrsquare, 4);
sse = num2str(gof.sse, 4);
dfe = num2str(gof.dfe, 4);
rmse = num2str(gof.rmse, 4);
app.GoFLabel.Text = ['adj. R˛ = ', ar2, newline, ' SSE = ', sse, newline, ' DFE = ', dfe, newline, ' RMSE = ', rmse];
if app.showgof
app.GoFLabel.Visible = 'on';
if app.ShowTips.Value
app.Whatsthis_GoFButton.Visible = 'on';
end
else
app.GoFLabel.Visible = 'off';
app.Whatsthis_GoFButton.Visible = 'off';
end