-
Notifications
You must be signed in to change notification settings - Fork 2
/
MultiGLAFit_ce20180313a.ipf
2789 lines (2271 loc) · 98.9 KB
/
MultiGLAFit_ce20180313a.ipf
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
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
//Todos
// - Line size adjust
// - Arbitrary constraints
// - Display 'Kn' for each parameter
// - Log file and history
// - Fine slider adjustment (depending on zoom)
//Bug fixes
// - Prevent the generation of unused fit curves.
//Function
// - Slider
// - BG subtraction
// - Peak select
// - Copy Guess values
// - Default constraint
// - use default constraint and edit
// - Peak library and import peak library from a .txt file
// - Colour changes /w hold or guess out of range
// - Save/Load guesses
// - Fit and show fit results
// - Display last fit result
// - BG adjust and record
// - Export fit results
// - Check for duplicated new data W name
// - Allow user to change data W name
// - Peak area report
//Bug fixed
// - Users can now click cancel for the load new data
//USE OFTEN
Function SLP_MGFit_UseOften()
ControlInfo /W=SLP_MultiGLAFit_01 ListBox_DataList
Variable DataRow=V_Value
ControlInfo /W=SLP_MultiGLAFit_01 ListBox_PeakParam
Variable PeakRow=V_Value
Wave /T SLP_MGFit_DataListW=root:Package_SLP:MGFit:SLP_MGFit_DataListW
Wave SLP_MGFit_DataListSelW=root:Package_SLP:MGFit:SLP_MGFit_DataListSelW
Wave /T SLP_MGFit_ConstraintDisplayW=root:Package_SLP:MGFit:SLP_MGFit_ConstraintDisplayW
Wave SLP_MGFit_ConstraintDisplaySelW=root:Package_SLP:MGFit:SLP_MGFit_ConstraintDisplaySelW
Wave /T SLP_MGFit_DefaultConstraintW=root:Package_SLP:MGFit:SLP_MGFit_DefaultConstraintW
Wave SLP_MGFit_DefaultConstraintSelW=root:Package_SLP:MGFit:SLP_MGFit_DefaultConstraintSelW
Wave /T SLP_MGFit_PeakLibraryW=root:Package_SLP:MGFit:SLP_MGFit_PeakLibraryW
Wave SLP_MGFit_PeakLibrarySelW=root:Package_SLP:MGFit:SLP_MGFit_PeakLibrarySelW
String DataName=SLP_MGFit_DataListW[DataRow][0]
String DataLocation=SLP_MGFit_DataListW[DataRow][1]
String CoefGuessDispW_FName=DataLocation+"CoefGuessDispW"
String CoefGuessDispSelW_FName=DataLocation+"CoefGuessDispSelW"
String ConstraintW_FName=DataLocation+"ConstraintW"
String HilightW_FName=DataLocation+"HilightW"
String CoefGuessM_FName=DataLocation+"CoefGuessM" //Use for fitting
String ConstraintV_FName=DataLocation+"ConstraintV" //Use for fitting
String DataW_FName=DataLocation+DataName //Raw data
String BgW_FName=DataW_FName+"_BG" //Background
String Data_nBGW_FName=DataW_FName+"_nBG" //Data after BG subtraction
String Data_GssW_FName=DataW_FName+"_Gss" //Guess curve
variable i=0
String Data_Comp_FName=DataW_FName+"_p"+num2str(i) //Individual GLA component
End
Menu "SLPA"
"Multi-GLAs Fit..",SLP_MGFit_CreatePanel()
End
Function SLP_MGFit_CreatePanel() : Panel
Dowindow /K SLP_MultiGLAFit_01
PauseUpdate; Silent 1 // building window...
NewPanel /W=(45,45,1150,670) /N=SLP_MultiGLAFit_01
SetDrawLayer UserBack
SetDrawEnv fsize= 14
DrawText 10,25,"SLP Multi GLA Peaks Fitting Panel"
DrawText 380,30,"Parameter Guess and Results"
DrawText 915,25,"Constraints and Hold"
DrawText 715,205,"Data list"
DrawText 380,280,"Peak library"
DrawText 427,508,"Peak area"
DrawText 379,570,"Area under curve"
DrawText 915,194,"Data list"
SetDrawEnv fsize= 10
DrawText 452,522,"Guess"
SetDrawEnv fsize= 10
DrawText 468,538,"Fit"
//SetVariable Setvar_N_Peaks,pos={378,13},size={170,15},title="Number of GLA peak(s)",noEdit=1
NVAR GDataRow=root:Package_SLP:MGFit:GDataRow
Variable a=30,b=60,c=90
ListBox ListBox_PeakParam,pos={380,33},size={530,215},ListWave=root:Package_SLP:MGFit:SLP_MGFit_iCoefGuessDisplayW ,SelWave=root:Package_SLP:MGFit:SLP_MGFit_iCoefGuessDisplaySelW
ListBox ListBox_PeakParam,widths={32,45,85,a,a,a,a,a,a,a,a,a,a,0,0,0},userColumnResize=1
ListBox ListBox_PeakParam,mode=2,proc=ListBoxProc_MGFit_CoefGuess,SelRow=0,colorWave=root:Package_SLP:MGFit:ListColors
ListBox ListBox_PeakConstraints,pos={915,31},size={170,110},ListWave=root:Package_SLP:MGFit:SLP_MGFit_ConstraintDisplayW, SelWave=root:Package_SLP:MGFit:SLP_MGFit_ConstraintDisplaySelW
ListBox ListBox_PeakConstraints,widths={50,a,a,32},userColumnResize=1
ListBox ListBox_PeakConstraints proc=ListBoxProc_MGFit_Constraints
ListBox ListBox_DataList,pos={915,220},size={170,250},ListWave=root:Package_SLP:MGFit:SLP_MGFit_DataListDisplayW, Selwave=root:Package_SLP:MGFit:SLP_MGFit_DataListDisplaySelW
ListBox ListBox_DataList,widths={32,50,100},SelRow=GDataRow,userColumnResize=1
ListBox ListBox_DataList,mode=2,proc=ListBoxProc_MGFit_DataSelect
ListBox ListBox_Library,pos={380,285},size={530,130},ListWave=root:Package_SLP:MGFit:SLP_MGFit_PeakLibraryW,SelWave=root:Package_SLP:MGFit:SLP_MGFit_PeakLibrarySelW
ListBox ListBox_Library,widths={32,50,100,a,a,a,a,a,a,a,a,a,a,a,a,a},userColumnResize=1
ListBox list_PeakArea,pos={485,494},size={601,64},mode=6,proc=ListBoxProc_MGFit_AreaRatio
ListBox list_PeakArea,listWave=root:Package_SLP:MGFit:SLP_MGFit_PeakAreaW
ListBox list_PeakArea,widths={b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b,b}
ListBox list_PeakArea,userColumnResize= 1
ListBox list_CurveArea,pos={483,562},size={601,54},mode=6,proc=ListBoxProc_MGFit_AreaRatio
ListBox list_CurveArea,listWave=root:Package_SLP:MGFit:SLP_MGFit_CurveAreaW
ListBox list_CurveArea,widths={c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c,c}
ListBox list_CurveArea,userColumnResize= 1
Variable SliderGroup_Xpos=10
Variable SliderGroup_Ypos=355
Variable SliderGroup_vspacing=48
Variable SliderGroup_hWidth=250
SetDrawLayer UserBack
SetDrawEnv fsize= 10; DrawText SliderGroup_Xpos,SliderGroup_Ypos,"Intensity"
SetDrawEnv fsize= 10; DrawText SliderGroup_Xpos+SliderGroup_hWidth+62,SliderGroup_Ypos+5,"Position"
SetDrawEnv fsize= 10; DrawText SliderGroup_Xpos+SliderGroup_hWidth+62,SliderGroup_Ypos+5+SliderGroup_vspacing,"FWHM"
SetDrawEnv fsize= 10; DrawText SliderGroup_Xpos+SliderGroup_hWidth+62,SliderGroup_Ypos+5+2*SliderGroup_vspacing,"Mixture"
SetDrawEnv fsize= 10; DrawText SliderGroup_Xpos+SliderGroup_hWidth+62,SliderGroup_Ypos+5+3*SliderGroup_vspacing,"Asymmetry"
Slider slider_Int,pos={SliderGroup_Xpos,SliderGroup_Ypos},size={60,170}
Slider slider_Int,limits={0,2,0.05},value= 0,ticks=10,proc=SliderProc_MGFit_CoefAdjust
Slider slider_Pos,pos={SliderGroup_Xpos+60,SliderGroup_Ypos-10},size={SliderGroup_hWidth,45}
Slider slider_Pos,limits={270,350,0.1},value= 0,ticks=10,vert= 0,proc=SliderProc_MGFit_CoefAdjust
Slider slider_Fwhm,pos={SliderGroup_Xpos+60,SliderGroup_Ypos-10+SliderGroup_vspacing},size={SliderGroup_hWidth,45}
Slider slider_Fwhm,limits={0.3,5,0.1},value= 0,ticks=10,vert= 0,proc=SliderProc_MGFit_CoefAdjust
Slider slider_Mix,pos={SliderGroup_Xpos+60,SliderGroup_Ypos-10+2*SliderGroup_vspacing},size={SliderGroup_hWidth,45}
Slider slider_Mix,limits={0.01,0.99,0.01},value= 0,ticks=10,vert= 0,proc=SliderProc_MGFit_CoefAdjust
Slider slider_As,pos={SliderGroup_Xpos+60,SliderGroup_Ypos-10+3*SliderGroup_vspacing},size={SliderGroup_hWidth,45}
Slider slider_As,limits={0.01,0.99,0.01},value= 0,ticks=10,vert= 0,proc=SliderProc_MGFit_CoefAdjust
SetVariable setvar_GssChisq,pos={11,323},size={150,15},title="Guess chi square"
SetVariable setvar_GssChisq,limits={-inf,inf,0},value= root:Package_SLP:MGFit:Gss_Chisq,noedit= 1
SetVariable setvar_GssChisq valueColor=(1,26221,39321)
SetVariable setvar_FitChisq,pos={181,323},size={150,15},title="Fit chi square"
SetVariable setvar_FitChisq,valueColor=(13102,26214,0)
SetVariable setvar_FitChisq,limits={-inf,inf,0},value= root:Package_SLP:MGFit:Fit_Chisq,noedit= 1
SetVariable setvar_LowX,pos={390,575},size={90,15},title="Low X",proc=SetVarProc_MGFit_AreaUnderCurve
SetVariable setvar_LowX,value= root:Package_SLP:MGFit:LowX
SetVariable SetVar_HighX,pos={390,600},size={90,15},title="High X",proc=SetVarProc_MGFit_AreaUnderCurve
SetVariable SetVar_HighX,value= root:Package_SLP:MGFit:HighX
SetVariable setvar_AreaRatio,pos={485,477},size={100,15},title="Area ratio"
SetVariable setvar_AreaRatio,limits={-inf,inf,0},value= root:Package_SLP:MGFit:AreaRatio,noedit= 1
PopupMenu popup_BgSel,pos={155,25},size={113,20},title="Background type",Proc=PopMenuProc_MGFit_MakeBG
PopupMenu popup_BgSel,mode=1,popvalue="None",value= #"\"None;Shirley;Erf;atan;Flat;Slope\""
Button button_Done,pos={857,466},size={50,20},title="Done",proc=ButtonProc_MGFit_Done,fsize=10
Button Button_ImportFromLib,pos={383,418},size={525,20},title="Import selected peak",fSize=10,proc=ButtonProc_MGFit_ImportFromLib
Button Button_AddLibItem,pos={383,442},size={100,20},proc=ButtonProc_MGFit_AddLibItem,title="Add to library..",fSize=10
Button Button_EditLib,pos={489,442},size={70,20},proc=ButtonProc_MGFit_EditLib,title="Edit library..",fSize=10
Button Button_RemoveLibItem,pos={564,442},size={120,20},proc=ButtonProc_MGFit_RemoveFromLib,title="Remove selected peak",fSize=10
Button Button_SaveLib,pos={689,442},size={95,20},proc=ButtonProc_MGFit_SaveLibAsTxt,title="Save library as..", fSize=10
Button Button_LoadLib,pos={789,442},size={120,20},proc=ButtonProc_MGFit_LoadLibFile,title="Load library from file..",fSize=10
Button Button_Export,pos={120,46},size={100,20},title="Export graph..",fsize=10,proc=ButtonProc_MGFit_ExportGraph
Button Button_AddData,pos={915,195},size={85,20},title="Add data wave",fsize=10,proc=ButtonProc_MGFit_LoadData
Button Button_ConstraintDefault,pos={915,145},size={51,16},title="Default",fsize=10,proc=ButtonProc_MGFit_DefConstraints
Button Button_EditConstraintDefault,pos={965,145},size={80,16},title="Edit default..",fsize=10,proc=ButtonProc_MGFit_EditConstDef
Button Button_DeleteData,pos={1005,195},size={85,20},title="Delete data..",fSize=10,proc=ButtonProc_MGFit_DeleteData
Button Button_CopyGssParam,pos={745,10},size={130,20},proc=ButtonProc_MGFit_CopyGssParam,title="Copy parameters from..",fSize=10
Button Button_Holdall,pos={1046,146},size={51,16},proc=ButtonProc_MGFit_HoldAllTogg,title="Hold all",fSize=10
Button Button_AddLibFromGss,pos={465,251},size={200,20},proc=ButtonProc_MGFit_AddLibItemGss,title="Add highlighted peak to library",fSize=10
Button button_Fit,pos={700,255},size={50,23},proc=ButtonProc_MGFit_Fit,title="FIT",fColor=(65535,21845,0)
Button Button_SaveGss,pos={555,11},size={90,20},proc=ButtonProc_MGFit_SaveGssAsTxt,title="Save guesses..",fSize=10
Button Button_LoadGss,pos={650,11},size={90,20},proc=ButtonProc_MGFit_LoadGssFile,title="Load guesses..",fSize=10
Button Button_AcceptFitCoef,pos={758,254},size={150,20},proc=ButtonProc_MGFit_AcceptFit,title="Accept new fit coefficients",fSize=10
Button Button_AdjBG,pos={10,46},size={100,20},proc=ButtonProc_MGFit_BGAdj,title="Adjust background",fSize=10
CheckBox check_DisplayOriginal,pos={10,28},size={50,15},title="Original",value= 0,proc=CheckProc_MGFit_DisplayOrgBG
CheckBox check_DisplayBg,pos={70,28},size={69,15},title="Background",value= 0,proc=CheckProc_MGFit_DisplayOrgBG
CheckBox check_DispFit,pos={282,51},size={59,15},proc=CheckProc_MGFit_DispFit,title="Show fit result"
Display/W=(12,71,366,317)/HOST=SLP_MultiGLAFit_01
RenameWindow #,G0
SetActiveSubwindow ##
Wave /T SLP_MGFit_DataListW=root:Package_SLP:MGFit:SLP_MGFit_DataListW
If (Dimsize(SLP_MGFit_DataListW,0)>0)
String DataName=SLP_MGFit_DataListW[GDataRow][0]
SLP_MGFit_DisplaySelectedData(DataName)
EndIf
End
Function SLP_MGFit_Init()
String Current_folder=getdatafolder(1)
NewDataFolder /O root:Package_SLP
NewDataFolder /O root:Package_SLP:MGFit
SetDataFolder root:Package_SLP:MGFit
variable /G N_peaks=1
Variable /G MaxN_peaks=64
variable /G GDataRow=0
variable /G GLA_int=0
variable /G GLA_pos=0
variable /G GLA_fwhm=0
variable /G GLA_mix=0
variable /G GLA_as=0
variable /G Init_int=1
variable /G Init_pos=0
variable /G Init_fwhm=1
variable /G Init_mix=0.5
variable /G Init_as=0.5
variable /G PosRange=0
variable /G Pos_pm_flg=0
variable /G Gss_Chisq
variable /G Fit_Chisq
variable /G LowX //to calculate area under curve
variable /G HighX //to calculate area under curve
variable /G AreaRatio
Make /O/T/N=(0,64) SLP_MGFit_DataListW
SetDimLabel 1,0,DataName,SLP_MGFit_DataListW
SetDimLabel 1,1,DataFolder,SLP_MGFit_DataListW
SetDimLabel 1,2,OrgData,SLP_MGFit_DataListW
SetDimLabel 1,3,N_Peaks,SLP_MGFit_DataListW
SetDimLabel 1,4,Peak_Sel,SLP_MGFit_DataListW
SetDimLabel 1,5,BG_Type,SLP_MGFit_DataListW
SetDimLabel 1,6,BG_Param0,SLP_MGFit_DataListW
SetDimLabel 1,7,BG_Param1,SLP_MGFit_DataListW
SetDimLabel 1,8,BG_Param2,SLP_MGFit_DataListW
SetDimLabel 1,9,BG_Param3,SLP_MGFit_DataListW
SetDimLabel 1,10,BG_Param4,SLP_MGFit_DataListW
SetDimLabel 1,11,BG_Param5,SLP_MGFit_DataListW
SetDimLabel 1,12,BG_Param6,SLP_MGFit_DataListW
SetDimLabel 1,13,BG_Param7,SLP_MGFit_DataListW
SetDimLabel 1,14,BG_Param8,SLP_MGFit_DataListW
SetDimLabel 1,15,GssChiSq,SLP_MGFit_DataListW
SetDimLabel 1,16,FitChiSq,SLP_MGFit_DataListW
SetDimLabel 1,17,ShowFit_Flg,SLP_MGFit_DataListW //Show fit result instead of guess
SetDimLabel 1,18,LowX,SLP_MGFit_DataListW //For area under curve calculations
SetDimLabel 1,19,HighX,SLP_MGFit_DataListW //For area under curve calculations
Make /O/T/N=(0,16) SLP_MGFit_DataListDisplayW
SetDimLabel 1,0,Select,SLP_MGFit_DataListDisplayW
SetDimLabel 1,1,DataName,SLP_MGFit_DataListDisplayW
SetDimLabel 1,2,DataNote,SLP_MGFit_DataListDisplayW
Make /O/N=(0,16) SLP_MGFit_DataListDisplaySelW
Make /O/T/N=(MaxN_peaks,16) SLP_MGFit_iCoefGuessDisplayW
SetDimLabel 1,0,Select,SLP_MGFit_iCoefGuessDisplayW
SetDimLabel 1,1,PeakName,SLP_MGFit_iCoefGuessDisplayW
SetDimLabel 1,2,PeakNote,SLP_MGFit_iCoefGuessDisplayW
SetDimLabel 1,3,Int,SLP_MGFit_iCoefGuessDisplayW
SetDimLabel 1,4,Pos,SLP_MGFit_iCoefGuessDisplayW
SetDimLabel 1,5,FWHM,SLP_MGFit_iCoefGuessDisplayW
SetDimLabel 1,6,Mix,SLP_MGFit_iCoefGuessDisplayW
SetDimLabel 1,7,As,SLP_MGFit_iCoefGuessDisplayW
SetDimLabel 1,8,RInt,SLP_MGFit_iCoefGuessDisplayW
SetDimLabel 1,9,RPos,SLP_MGFit_iCoefGuessDisplayW
SetDimLabel 1,10,RFWHM,SLP_MGFit_iCoefGuessDisplayW
SetDimLabel 1,11,RMix,SLP_MGFit_iCoefGuessDisplayW
SetDimLabel 1,12,RAs,SLP_MGFit_iCoefGuessDisplayW
SLP_MGFit_iCoefGuessDisplayW[][1]="p"+num2str(p)
SLP_MGFit_iCoefGuessDisplayW[][3]=num2str(Init_int)
SLP_MGFit_iCoefGuessDisplayW[][4]=num2str(Init_pos)
SLP_MGFit_iCoefGuessDisplayW[][5]=num2str(Init_fwhm)
SLP_MGFit_iCoefGuessDisplayW[][6]=num2str(Init_mix)
SLP_MGFit_iCoefGuessDisplayW[][7]=num2str(Init_as)
Make /O/N=(MaxN_peaks,16,2) SLP_MGFit_iCoefGuessDisplaySelW //Layer2 = cell color
SLP_MGFit_iCoefGuessDisplaySelW[][0][0]=32 //Checkbox (unchecked)
SLP_MGFit_iCoefGuessDisplaySelW[][2,7][0]=2 //Editable (peak description)
Make /O/T/N=(5,8) SLP_MGFit_ConstraintDisplayW
SetDimLabel 1,0,CoefName,SLP_MGFit_ConstraintDisplayW
SetDimLabel 1,1, MinimumVal,SLP_MGFit_ConstraintDisplayW
SetDimLabel 1,2, MaximumVal,SLP_MGFit_ConstraintDisplayW
SetDimLabel 1,3,Hold,SLP_MGFit_ConstraintDisplayW
SLP_MGFit_ConstraintDisplayW[0][0]={"Intensity","Position","FWHM","Mixture","Assymetry"}
SLP_MGFit_ConstraintDisplayW[0][1]={"0","NaN","0.3","0.01","0.01"}
SLP_MGFit_ConstraintDisplayW[0][2]={"NaN","NaN","5","0.99","0.99"}
Duplicate /O/T SLP_MGFit_ConstraintDisplayW,SLP_MGFit_DefaultConstraintW
Make /O/N=(5,8,2) SLP_MGFit_ConstraintDisplaySelW //Layer2 = cell color
SLP_MGFit_ConstraintDisplaySelW[][1,2][0]=2
SLP_MGFit_ConstraintDisplaySelW[][3][0]=32
Duplicate /O SLP_MGFit_ConstraintDisplaySelW,SLP_MGFit_DefaultConstraintSelW
Make /O/T/N=(6,32) SLP_MGFit_PeakLibraryW
SetDimLabel 1,0,Select,SLP_MGFit_PeakLibraryW
SetDimLabel 1,1,Name,SLP_MGFit_PeakLibraryW
SetDimLabel 1,2,PeakNote,SLP_MGFit_PeakLibraryW
SetDimLabel 1,3,Int,SLP_MGFit_PeakLibraryW
SetDimLabel 1,4,Pos,SLP_MGFit_PeakLibraryW
SetDimLabel 1,5,FWHM,SLP_MGFit_PeakLibraryW
SetDimLabel 1,6,Mix,SLP_MGFit_PeakLibraryW
SetDimLabel 1,7,As,SLP_MGFit_PeakLibraryW
SetDimLabel 1,9,IntMin,SLP_MGFit_PeakLibraryW
SetDimLabel 1,10,IntMax,SLP_MGFit_PeakLibraryW
SetDimLabel 1,11,PosMin,SLP_MGFit_PeakLibraryW
SetDimLabel 1,12,PosMax,SLP_MGFit_PeakLibraryW
SetDimLabel 1,13,FWHMMin,SLP_MGFit_PeakLibraryW
SetDimLabel 1,14,FWHMMax,SLP_MGFit_PeakLibraryW
SetDimLabel 1,15,MixMin,SLP_MGFit_PeakLibraryW
SetDimLabel 1,16,MixMax,SLP_MGFit_PeakLibraryW
SetDimLabel 1,17,AsMin,SLP_MGFit_PeakLibraryW
SetDimLabel 1,18,AsMax,SLP_MGFit_PeakLibraryW
SLP_MGFit_PeakLibraryW[0][1]={{"C1s Atomic"},{""},{"1"},{"283"},{"1"},{"0.5"},{"0.5"}}
SLP_MGFit_PeakLibraryW[1][1]={{"C1s C-C"},{""},{"1"},{"284"},{"1"},{"0.5"},{"0.5"}}
SLP_MGFit_PeakLibraryW[2][1]={{"C1s C-OH"},{""},{"1"},{"285"},{"1"},{"0.5"},{"0.5"}}
SLP_MGFit_PeakLibraryW[3][1]={{"C1s C=O"},{""},{"1"},{"286"},{"1"},{"0.5"},{"0.5"}}
SLP_MGFit_PeakLibraryW[4][1]={{"C1s COOH"},{""},{"1"},{"288"},{"1"},{"0.5"},{"0.5"}}
SLP_MGFit_PeakLibraryW[5][1]={{"C1s C-NH3"},{""},{"1"},{"285"},{"1"},{"0.5"},{"0.5"}}
Make /O/N=(6,32) SLP_MGFit_PeakLibrarySelW
SLP_MGFit_PeakLibrarySelW[][0]=32
SLP_MGFit_PeakLibrarySelW[][2]=2
Make/O/W/U ListColors= {{0,0,0},{65535,0,0},{25000,25000,25000},{0,0,65535},{0,65535,65535}}
MatrixTranspose ListColors
make /O/T /N=(2,16) SLP_MGFit_CurveAreaW
SLP_MGFit_CurveAreaW=""
make /O/T /N=(3,MaxN_peaks) SLP_MGFit_PeakAreaW
SLP_MGFit_PeakAreaW=""
SLP_MGFit_PeakAreaW[0][]="p"+num2str(q)
Setdatafolder $Current_folder
End
Function SetVarProc_MGFit_AreaUnderCurve(sva) : SetVariableControl
STRUCT WMSetVariableAction &sva
switch( sva.eventCode )
case 1: // mouse up
case 2: // Enter key
case 3: // Live update
Variable dval = sva.dval
String sval = sva.sval
ControlInfo /W=SLP_MultiGLAFit_01 ListBox_DataList
Variable DataRow=V_Value
Wave /T SLP_MGFit_DataListW=root:Package_SLP:MGFit:SLP_MGFit_DataListW
String DataName=SLP_MGFit_DataListW[DataRow][0]
SLP_MGFit_ReadAreaUnderCurve(DataName)
NVAR LowX=root:Package_SLP:MGFit:LowX
NVAR HighX=root:Package_SLP:MGFit:HighX
SLP_MGFit_DataListW[DataRow][18]=num2str(LowX)
SLP_MGFit_DataListW[DataRow][19]=num2str(HighX)
SLP_MGFit_DrawVLine(dVal)
break
case -1: // control being killed
break
endswitch
return 0
End
Function ButtonProc_MGFit_AddLibItemGss(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
// click code here
ControlInfo /W=SLP_MultiGLAFit_01 ListBox_DataList
Variable DataRow=V_Value
ControlInfo /W=SLP_MultiGLAFit_01 ListBox_PeakParam
Variable PeakRow=V_Value
Wave /T SLP_MGFit_DataListW=root:Package_SLP:MGFit:SLP_MGFit_DataListW
Wave /T SLP_MGFit_PeakLibraryW=root:Package_SLP:MGFit:SLP_MGFit_PeakLibraryW
Wave SLP_MGFit_PeakLibrarySelW=root:Package_SLP:MGFit:SLP_MGFit_PeakLibrarySelW
String DataName=SLP_MGFit_DataListW[DataRow][0]
String DataLocation=SLP_MGFit_DataListW[DataRow][1]
String CoefGuessDispW_FName=DataLocation+"CoefGuessDispW"
String ConstraintW_FName=DataLocation+"ConstraintW"
Wave /T CoefGuessDispW=$CoefGuessDispW_FName
Wave ConstraintW=$ConstraintW_FName
String PeakName=CoefGuessDispW[PeakRow][1]
String PeakNote=CoefGuessDispW[PeakRow][2]
variable int=str2num(CoefGuessDispW[PeakRow][3]),pos=str2num(CoefGuessDispW[PeakRow][4])
variable fwhm=str2num(CoefGuessDispW[PeakRow][5]),mix=str2num(CoefGuessDispW[PeakRow][6])
Variable as=str2num(CoefGuessDispW[PeakRow][7])
variable int_min=ConstraintW[0][0][PeakRow],pos_min=ConstraintW[1][0][PeakRow],fwhm_min=ConstraintW[2][0][PeakRow],mix_min=ConstraintW[3][0][PeakRow],as_min=ConstraintW[4][0][PeakRow]
variable int_max=ConstraintW[0][1][PeakRow],pos_max=ConstraintW[1][1][PeakRow],fwhm_max=ConstraintW[2][1][PeakRow],mix_max=ConstraintW[3][1][PeakRow],as_max=ConstraintW[4][1][PeakRow]
Redimension /N=(dimsize(SLP_MGFit_PeakLibraryW,0)+1,dimsize(SLP_MGFit_PeakLibraryW,1)) SLP_MGFit_PeakLibraryW
Redimension /N=(dimsize(SLP_MGFit_PeakLibrarySelW,0)+1,dimsize(SLP_MGFit_PeakLibrarySelW,1)) SLP_MGFit_PeakLibrarySelW
SLP_MGFit_PeakLibrarySelW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][0]=32
SLP_MGFit_PeakLibrarySelW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][2]=2
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][1]=PeakName
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][2]=PeakNote
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][3]=Num2str(int)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][4]=Num2str(pos)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][5]=Num2str(fwhm)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][6]=Num2str(mix)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][7]=Num2str(as)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][8]=Num2str(int_min)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][9]=Num2str(int_max)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][10]=Num2str(pos_min)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][11]=Num2str(pos_max)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][12]=Num2str(fwhm_min)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][13]=Num2str(fwhm_max)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][14]=Num2str(mix_min)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][15]=Num2str(mix_max)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][16]=Num2str(as_min)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][17]=Num2str(as_min)
break
case -1: // control being killed
break
endswitch
return 0
End
Function ButtonProc_MGFit_AddLibItem(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
// click code here
String PeakName,PeakNote
variable int=NaN,pos=NaN,fwhm=NaN,mix=NaN,as=NaN
variable int_min=NaN,pos_min=NaN,fwhm_min=NaN,mix_min=NaN,as_min=NaN
variable int_max=NaN,pos_max=NaN,fwhm_max=NaN,mix_max=NaN,as_max=NaN
Prompt PeakName,"Peak Name"
Prompt PeakNote,"Note"
Prompt int,"Intensity"
Prompt pos,"Position"
prompt fwhm,"FWHM"
prompt mix,"Mixture"
prompt as,"Asymmetry"
Doprompt "Enter peak parameters",PeakName,PeakNote,int,pos,fwhm,mix,as
If (V_Flag==0) //If user clicks ok
Prompt int_min,"Min intensity"
Prompt int_max,"Max intensity"
Prompt pos_min,"Min position"
Prompt pos_max,"Max position"
prompt fwhm_min,"Min FWHM"
prompt fwhm_max,"Max FWHM"
prompt mix_Min,"Min mixture"
prompt mix_Max,"Max mixture"
prompt as_min,"Min Asymmetry"
prompt as_max,"Max Asymmetry"
Doprompt "Enter peak parameters",int_min,int_max,pos_min,pos_max,fwhm_min,fwhm_max,mix_min,mix_max,as_min,as_max
If (V_Flag==0) //if user clicks ok
Wave /T SLP_MGFit_PeakLibraryW=root:Package_SLP:MGFit:SLP_MGFit_PeakLibraryW
Wave SLP_MGFit_PeakLibrarySelW=root:Package_SLP:MGFit:SLP_MGFit_PeakLibrarySelW
Redimension /N=(dimsize(SLP_MGFit_PeakLibraryW,0)+1,dimsize(SLP_MGFit_PeakLibraryW,1)) SLP_MGFit_PeakLibraryW
Redimension /N=(dimsize(SLP_MGFit_PeakLibrarySelW,0)+1,dimsize(SLP_MGFit_PeakLibrarySelW,1)) SLP_MGFit_PeakLibrarySelW
SLP_MGFit_PeakLibrarySelW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][0]=32
SLP_MGFit_PeakLibrarySelW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][2]=2
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][1]=PeakName
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][2]=PeakNote
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][3]=Num2str(int)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][4]=Num2str(pos)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][5]=Num2str(fwhm)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][6]=Num2str(mix)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][7]=Num2str(as)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][8]=Num2str(int_min)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][9]=Num2str(int_max)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][10]=Num2str(pos_min)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][11]=Num2str(pos_max)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][12]=Num2str(fwhm_min)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][13]=Num2str(fwhm_max)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][14]=Num2str(mix_min)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][15]=Num2str(mix_max)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][16]=Num2str(as_min)
SLP_MGFit_PeakLibraryW[dimsize(SLP_MGFit_PeakLibrarySelW,0)-1][17]=Num2str(as_min)
EndIf
EndIf
break
case -1: // control being killed
break
endswitch
return 0
End
Function ButtonProc_MGFit_ExportGraph(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
// click code here
ControlInfo /W=SLP_MultiGLAFit_01 ListBox_DataList
Variable DataRow=V_Value
ControlInfo /W=SLP_MultiGLAFit_01 ListBox_PeakParam
Variable PeakRow=V_Value
Wave /T SLP_MGFit_DataListW=root:Package_SLP:MGFit:SLP_MGFit_DataListW
String DataName=SLP_MGFit_DataListW[DataRow][0]
String DataLocation=SLP_MGFit_DataListW[DataRow][1]
String DataW_FName=DataLocation+DataName //Raw data
String BgW_FName=DataW_FName+"_BG" //Background
String Data_nBGW_FName=DataW_FName+"_nBG" //Data after BG subtraction
String Data_GssW_FName=DataW_FName+"_Gss" //Guess curve
Wave Data_nBGW=$Data_nBGW_FName
String TraceList=TraceNameList("SLP_MultiGLAFit_01#G0",";",1)
Variable N_curves=Itemsinlist(TraceList,";")
String NewFolderName=":"+DataName
String TraceName=""
String orgW_FName=""
String destW_Name=""
variable i=0
variable run_flg=0
String LegendStr=DataName+"\r\Zr080"
String FolderExistsWarning="Enter new folder name?"
//Check if the folder to keep waves already exists
If (!DataFolderExists(NewFolderName))
run_flg=1
Else
DoAlert 1,NewFolderName+" folder already exists. Overwrite existing waves?"
If (V_Flag==1) //Click yes
run_flg=1
Else //Click no
Do
DoAlert 1,FolderExistsWarning
If (V_Flag==1)
Prompt NewFolderName,"New folder:"
DoPrompt "Enter new folder name",NewFolderName
run_flg=1
Else
run_flg=0
EndIf
FolderExistsWarning="Still duplicated name. Enter new folder name?"
While (run_flg!=0&&DataFolderExists(NewFolderName))
Endif
EndIf
If (run_flg)
NewDataFolder /O $NewFolderName
For (i=0;i<N_curves;i+=1)
TraceName=StringFromList(i,TraceList)
orgW_FName=DataLocation+TraceName
destW_Name=NewFolderName+":"+TraceName
duplicate /O $orgW_FName,$destW_Name
EndFor
String Current_folder=getdatafolder(1)
SetDataFolder $NewFolderName
TraceName=StringFromList(0,TraceList)
Display $TraceName
ModifyGraph mode($TraceName)=7,hbFill($TraceName)=2,rgb($TraceName)=(65535,49151,49151)
For (i=1;i<N_curves;i+=1)
TraceName=StringFromList(i,TraceList)
Appendtograph $TraceName
Variable FitDisplay_Flg=str2num(SLP_MGFit_DataListW[DataRow][17])
If (FitDisplay_Flg==0) //Display Guess curves
//Modify the graph and trace colors
If (i==1)//Data Wave (BG subtracted)
Modifygraph mode($TraceName)=3, Marker($TraceName)=16, rgb($TraceName)=(43690,43690,43690)
LegendStr+="\s("+TraceName+")"+"Data w/o BG\r"
ElseIf (i==2) //Guess Wave
ModifyGraph rgb($TraceName)=(1,34817,52428), lsize($TraceName)=3
LegendStr+="\s("+TraceName+")Guess curve\r"
Elseif (i==PeakRow+3)//Selected peak
ModifyGraph rgb($TraceName)=(65535,43690,0),lsize($TraceName)=1.5
LegendStr+="\s("+TraceName+")Selected component\r"
EndIf
Elseif (FitDisplay_Flg==1) //Display fit results
If (i==1)
Modifygraph mode($TraceName)=3, Marker($TraceName)=16, rgb($TraceName)=(43690,43690,43690)
LegendStr+="\s("+TraceName+")"+"Data w/o BG\r"
Elseif (i==2)//Fit Wave
ModifyGraph rgb($TraceName)=(0,35000,0), lsize($TraceName)=3
LegendStr+="\s("+TraceName+")Fit result\r"
Elseif (i==PeakRow+3) //Selected peak
ModifyGraph rgb($TraceName)=(65535,43690,0),lsize($TraceName)=1.5
LegendStr+="\s("+TraceName+")Selected component\r"
EndIf
EndIf
EndFor
//Orginal data w (before BG) and BG waves display
Wavestats /Q Data_nBGW
Variable OrgData_yOffset=(V_Max-V_Min)*1.10 //Determine offset value from the data y-range
ControlInfo /W=SLP_MultiGLAFit_01 Check_DisplayOriginal; variable DisplayOrg_Flg=V_Value
If (DisplayOrg_Flg)
TraceName=StringFromList(ItemsInlist(TraceList,";")-2,TraceList,";")
ModifyGraph offset($TraceName)={0,OrgData_yOffset},rgb($TraceName)=(30000,30000,30000)
LegendStr+="\s("+TraceName+")Original data\r"
EndIf
ControlInfo /W=SLP_MultiGLAFit_01 Check_DisplayBG; variable DisplayBg_Flg=V_Value
If (DisplayBg_Flg)
TraceName=StringFromList(ItemsInlist(TraceList,";")-1,TraceList,";")
ModifyGraph offset($TraceName)={0,OrgData_yOffset}, lstyle($TraceName)=2,rgb($TraceName)=(30000,30000,30000)
LegendStr+="\s("+TraceName+")Background\r"
EndIf
SetDataFolder $Current_folder
Modifygraph mirror=1,minor=1,tick=2
LegendStr=removeending(LegendStr,"\r")
Legend LegendStr
EndIf
break
case -1: // control being killed
break
endswitch
return 0
End
Function ButtonProc_MGFit_AcceptFit(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
// click code here
ControlInfo /W=SLP_MultiGLAFit_01 ListBox_DataList
Variable DataRow=V_Value
DoAlert 1,"Overwrite the guess values with the fitted coefficients."
If (V_Value==1)
Wave /T SLP_MGFit_DataListW=root:Package_SLP:MGFit:SLP_MGFit_DataListW
String DataName=SLP_MGFit_DataListW[DataRow][0]
String DataLocation=SLP_MGFit_DataListW[DataRow][1]
String CoefGuessDispW_FName=DataLocation+"CoefGuessDispW"
Wave /T CoefGuessDispW=$CoefGuessDispW_FName
CoefGuessDispW[][3]=CoefGuessDispW[p][8]
CoefGuessDispW[][4]=CoefGuessDispW[p][9]
CoefGuessDispW[][5]=CoefGuessDispW[p][10]
CoefGuessDispW[][6]=CoefGuessDispW[p][11]
CoefGuessDispW[][7]=CoefGuessDispW[p][12]
SLP_MGFit_DataListW[DataRow][17]="0"
SLP_MGFit_DisplaySelectedData(DataName)
EndIf
break
case -1: // control being killed
break
endswitch
return 0
End
Function ButtonProc_MGFit_SaveGssAsTxt(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
// click code here
ControlInfo /W=SLP_MultiGLAFit_01 ListBox_DataList
Variable DataRow=V_Value
Wave /T SLP_MGFit_DataListW=root:Package_SLP:MGFit:SLP_MGFit_DataListW
String DataName=SLP_MGFit_DataListW[DataRow][0]
String DataLocation=SLP_MGFit_DataListW[DataRow][1]
String CoefGuessDispW_FName=DataLocation+"CoefGuessDispW"
Wave /T CoefGuessDispW=$CoefGuessDispW_FName
Make /O/T/N=(dimsize(CoefGuessDispW,0)+1,dimsize(CoefGuessDispW,1)) root:Package_SLP:MGFit:SLP_MGFit_GssExportW /Wave=SLP_MGFit_GssExportW
SLP_MGFit_GssExportW=""
Variable i=0
For (i=0;i<dimsize(CoefGuessDispW,0);i+=1)
SLP_MGFit_GssExportW[i+1][]=CoefGuessDispW[i][q]
EndFor
For (i=0;i<dimsize(CoefGuessDispW,1);i+=1)
SLP_MGFit_GssExportW[0][i]=GetDimLabel(CoefGuessDispW,1,i)
EndFor
String GssFileName="GuessExport"
Save/G /I /M="\n" SLP_MGFit_GssExportW as GssFileName
Killwaves SLP_MGFit_GssExportW
break
case -1: // control being killed
break
endswitch
return 0
End
Function ButtonProc_MGFit_LoadGssFile(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
// click code here
ControlInfo /W=SLP_MultiGLAFit_01 ListBox_DataList
Variable DataRow=V_Value
Wave /T SLP_MGFit_DataListW=root:Package_SLP:MGFit:SLP_MGFit_DataListW
String DataName=SLP_MGFit_DataListW[DataRow][0]
String DataLocation=SLP_MGFit_DataListW[DataRow][1]
String CoefGuessDispW_FName=DataLocation+"CoefGuessDispW"
String CoefGuessDispSelW_FName=DataLocation+"CoefGuessDispSelW"
Wave /T CoefGuessDispW=$CoefGuessDispW_FName
LoadWave /J /M /K=2 /N=GssData /U={0,0,1,0}
String NewGssWaveName=stringfromlist(0,S_Wavenames)
Wave NewGssWave=$NewGssWaveName
Duplicate /O /T NewGssWave,CoefGuessDispW
Killwaves NewGssWave
Make /O /N=(dimsize(CoefGuessDispW,0),dimsize(CoefGuessDispW,1),2) $CoefGuessDispSelW_FName /Wave=CoefGuessDispSelW
CoefGuessDispSelW=0
CoefGuessDispSelW[][0][0]=32
CoefGuessDispSelW[][2,7][0]=2
SLP_MGFit_DisplaySelectedData(DataName)
break
case -1: // control being killed
break
endswitch
return 0
End
Function ButtonProc_MGFit_LoadLibFile(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
// click code here
Wave /T SLP_MGFit_PeakLibraryW=root:Package_SLP:MGFit:SLP_MGFit_PeakLibraryW
LoadWave /J /M /K=2 /N=LibData /U={0,0,1,0}
String NewLibWaveName=stringfromlist(0,S_Wavenames)
Wave NewLibWave=$NewLibWaveName
Duplicate /O /T NewLibWave,SLP_MGFit_PeakLibraryW
Killwaves NewLibWave
Make /O /N=(dimsize(SLP_MGFit_PeakLibraryW,0),dimsize(SLP_MGFit_PeakLibraryW,1)) root:Package_SLP:MGFit:SLP_MGFit_PeakLibrarySelW /Wave=SLP_MGFit_PeakLibrarySelW
SLP_MGFit_PeakLibrarySelW=0
SLP_MGFit_PeakLibrarySelW[][0]=32
SLP_MGFit_PeakLibrarySelW[][2]=2
break
case -1: // control being killed
break
endswitch
return 0
End
Function ButtonProc_MGFit_SaveLibAsTxt(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
// click code here
Wave /T SLP_MGFit_PeakLibraryW=root:Package_SLP:MGFit:SLP_MGFit_PeakLibraryW
Make /O/T/N=(dimsize(SLP_MGFit_PeakLibraryW,0)+1,dimsize(SLP_MGFit_PeakLibraryW,1)) root:Package_SLP:MGFit:SLP_MGFit_PeakLibExportW /Wave=SLP_MGFit_PeakLibExportW
SLP_MGFit_PeakLibExportW=""
Variable i=0
For (i=0;i<dimsize(SLP_MGFit_PeakLibraryW,0);i+=1)
SLP_MGFit_PeakLibExportW[i+1][]=SLP_MGFit_PeakLibraryW[i][q]
EndFor
SLP_MGFit_PeakLibExportW[0][0]={{""},{"Peak name"},{"Note"},{"Int"},{"Pos"},{"FWHM"},{"Mix"},{"As"},{"Min Int"},{"Max Int"},{"Min Pos"},{"Max Pos"},{"Min FWHM"},{"Max FWHM"},{"Min Mix"},{"Max Mix"},{"Min As"},{"Max As"}}
String LibFileName="LibraryExport"
Save/G /I /M="\n" SLP_MGFit_PeakLibExportW as LibFileName
Killwaves SLP_MGFit_PeakLibExportW
break
case -1: // control being killed
break
endswitch
return 0
End
Function ButtonProc_MGFit_RemoveFromLib(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
// click code here
Doalert 2,"Remove selected peak(s) from library?"
If (V_Flag==1)
Wave /T SLP_MGFit_PeakLibraryW=root:Package_SLP:MGFit:SLP_MGFit_PeakLibraryW
Wave SLP_MGFit_PeakLibrarySelW=root:Package_SLP:MGFit:SLP_MGFit_PeakLibrarySelW
Variable i
For (i=dimsize(SLP_MGFit_PeakLibrarySelW,0)-1;i>=0;i-=1)
If (SLP_MGFit_PeakLibrarySelW[i][0]==48)
DeletePoints i,1,SLP_MGFit_PeakLibraryW
DeletePoints i,1,SLP_MGFit_PeakLibrarySelW
EndIf
EndFor
EndIf
break
case -1: // control being killed
break
endswitch
return 0
End
Function ButtonProc_MGFit_EditLib(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
// click code here
Wave /T SLP_MGFit_PeakLibraryW=root:Package_SLP:MGFit:SLP_MGFit_PeakLibraryW
DoWindow /K SLP_MGFit_PeakLibraryEdit_01
Edit /K=1/N=SLP_MGFit_PeakLibraryEdit_01 SLP_MGFit_PeakLibraryW
ModifyTable /W=SLP_MGFit_PeakLibraryEdit_01 horizontalIndex=2,rgb=(0,0,65535)
break
case -1: // control being killed
break
endswitch
return 0
End
Function ButtonProc_MGFit_ImportFromLib(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
// click code here
ControlInfo /W=SLP_MultiGLAFit_01 ListBox_DataList
Variable DataRow=V_Value
ControlInfo /W=SLP_MultiGLAFit_01 ListBox_PeakParam
Variable PeakRow=V_Value
Wave /T SLP_MGFit_DataListW=root:Package_SLP:MGFit:SLP_MGFit_DataListW
Wave /T SLP_MGFit_ConstraintDisplayW=root:Package_SLP:MGFit:SLP_MGFit_ConstraintDisplayW
Wave SLP_MGFit_ConstraintDisplaySelW=root:Package_SLP:MGFit:SLP_MGFit_ConstraintDisplaySelW
Wave /T SLP_MGFit_PeakLibraryW=root:Package_SLP:MGFit:SLP_MGFit_PeakLibraryW
Wave SLP_MGFit_PeakLibrarySelW=root:Package_SLP:MGFit:SLP_MGFit_PeakLibrarySelW
String DataName=SLP_MGFit_DataListW[DataRow][0]
String DataLocation=SLP_MGFit_DataListW[DataRow][1]
String CoefGuessDispW_FName=DataLocation+"CoefGuessDispW"
String ConstraintW_FName=DataLocation+"ConstraintW"
Wave /T CoefGuessDispW=$CoefGuessDispW_FName
Wave ConstraintW=$ConstraintW_FName
Variable i=0
Variable j=PeakRow
For (i=0;i<dimsize(SLP_MGFit_PeakLibraryW,0);i+=1)
If (SLP_MGFit_PeakLibrarySelW[i][0]==48)
//Note
CoefGuessDispW[j][2]=SLP_MGFit_PeakLibraryW[i][1]+"; "+SLP_MGFit_PeakLibraryW[i][2]
//Guess
CoefGuessDispW[j][3]=SLP_MGFit_PeakLibraryW[i][3] //int
CoefGuessDispW[j][4]=SLP_MGFit_PeakLibraryW[i][4] //pos
CoefGuessDispW[j][5]=SLP_MGFit_PeakLibraryW[i][5] //fwhm
CoefGuessDispW[j][6]=SLP_MGFit_PeakLibraryW[i][6] //mix
CoefGuessDispW[j][7]=SLP_MGFit_PeakLibraryW[i][7] //as
//Constraints
ConstraintW[0][0][j]=str2num(SLP_MGFit_PeakLibraryW[i][8]) //int min
ConstraintW[0][1][j]=str2num(SLP_MGFit_PeakLibraryW[i][9]) //int max
ConstraintW[1][0][j]=str2num(SLP_MGFit_PeakLibraryW[i][10]) //pos min
ConstraintW[1][1][j]=str2num(SLP_MGFit_PeakLibraryW[i][11]) //pos max
ConstraintW[2][0][j]=str2num(SLP_MGFit_PeakLibraryW[i][12]) //fwhm min
ConstraintW[2][1][j]=str2num(SLP_MGFit_PeakLibraryW[i][13]) //fwhm max
ConstraintW[3][0][j]=str2num(SLP_MGFit_PeakLibraryW[i][14]) //mix min
ConstraintW[3][1][j]=str2num(SLP_MGFit_PeakLibraryW[i][15]) //mix max
ConstraintW[4][0][j]=str2num(SLP_MGFit_PeakLibraryW[i][16]) //as min
ConstraintW[4][1][j]=str2num(SLP_MGFit_PeakLibraryW[i][17]) //as max
j+=1
Endif
EndFor
SLP_MGFit_DisplaySelectedData(DataName)
break
case -1: // control being killed
break
endswitch
return 0
End
Function ButtonProc_MGFit_EditConstDef(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
// click code here
SLP_MGFit_Panel_DefConstraints()
break
case -1: // control being killed
break
endswitch
return 0
End
Function CheckProc_MGFit_Pos_pm_flg(cba) : CheckBoxControl
STRUCT WMCheckboxAction &cba
switch( cba.eventCode )
case 2: // mouse up
Variable checked = cba.checked
Wave SLP_MGFit_DefaultConstraintSelW=root:Package_SLP:MGFit:SLP_MGFit_DefaultConstraintSelW
SLP_MGFit_DefaultConstraintSelW[1][1,2]=!checked*2
SetVariable setvar_PlusMinus disable=!checked
break
case -1: // control being killed
break
endswitch
return 0
End
Function CheckProc_MGFit_DispFit(cba) : CheckBoxControl
STRUCT WMCheckboxAction &cba
switch( cba.eventCode )
case 2: // mouse up
Variable checked = cba.checked
ControlInfo /W=SLP_MultiGLAFit_01 ListBox_DataList
Variable DataRow=V_Value
Wave /T SLP_MGFit_DataListW=root:Package_SLP:MGFit:SLP_MGFit_DataListW
SLP_MGFit_DataListW[DataRow][17]=num2str(checked)
String DataName=SLP_MGFit_DataListW[DataRow][0]
SLP_MGFit_DisplaySelectedData(DataName)
break
case -1: // control being killed
break
endswitch
return 0
End
Function ButtonProc_MGFit_ConstraintDone(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
// click code here
DoWindow /K MGFit_DefaultConstraint
break
case -1: // control being killed
break
endswitch
return 0
End
Function ButtonProc_MGFit_CopyGssParam(ba) : ButtonControl
STRUCT WMButtonAction &ba
switch( ba.eventCode )
case 2: // mouse up
// click code here
Wave /T SLP_MGFit_DataListW=root:Package_SLP:MGFit:SLP_MGFit_DataListW