-
Notifications
You must be signed in to change notification settings - Fork 0
/
Calibration.m
950 lines (703 loc) · 33 KB
/
Calibration.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
function varargout = Calibration(varargin)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Absorbed dose in water (Calibration and calculation)
% File: Calibration.m
% Kunal Kumar,
% Copyright, 2017
% Version: 1.0
%
% Copyright Notice: Permission to use, copy, modify, and distribute this
% application and its components for educational, research, and not for
% profit purposes, without a signed licensing agreement, is hereby granted,
% provided that the above copyright notice, this paragraph and the
% following paragraph appear in all copies, modifications, and distributions.
%
% Disclaimer: This application has been developed solely for the purpose of
% research and education, use of this application for clinical dosimetry is
% strongly discouraged without a complete validation and regulatory
% approval. In no event shall the author of this application be liable to
% any party for direct, indirect, special, incidental, or consequential
% damages arising out of the use of this application.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% CALIBRATION MATLAB code for Calibration.fig
% CALIBRATION, by itself, creates a new CALIBRATION or raises the existing
% singleton*.
%
% H = CALIBRATION returns the handle to a new CALIBRATION or the handle to
% the existing singleton*.
%
% CALIBRATION('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in CALIBRATION.M with the given input arguments.
%
% CALIBRATION('Property','Value',...) creates a new CALIBRATION or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Calibration_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Calibration_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Last Modified: Dec-2017
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Calibration_OpeningFcn, ...
'gui_OutputFcn', @Calibration_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before Calibration is made visible.
function Calibration_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
addpath(genpath(pwd));
% MAIN
setappdata(0, 'hMainGui',gcf)
% MEAN M-
setappdata(gcf,'MeanMminus',[])
setappdata(gcf,'UpdateMeanMminus',@UpdateMeanMminus)
% MEAN M+
setappdata(gcf,'MeanMplus',[])
setappdata(gcf,'UpdateMeanMplus',@UpdateMeanMplus)
% TEMPERATURE
setappdata(gcf,'MeanTemp',[])
setappdata(gcf,'UpdateTemp',@UpdateTemp)
% PRESSURE
setappdata(gcf,'MeanPressure',[])
setappdata(gcf,'UpdatePressure',@UpdatePressure)
% VOLTAGE POLARITY
% ValueSet1
setappdata(gcf,'MeanValueSet1',[])
setappdata(gcf,'UpdateValueSet1',@UpdateValueSet1)
% ValueSet2
setappdata(gcf,'MeanValueSet2',[])
setappdata(gcf,'UpdateValueSet2',@UpdateValueSet2)
% ValueSet3
setappdata(gcf,'MeanValueSet3',[])
setappdata(gcf,'UpdateValueSet3',@UpdateValueSet3)
% ValueSet4
setappdata(gcf,'MeanValueSet4',[])
setappdata(gcf,'UpdateValueSet4',@UpdateValueSet4)
% BeamQual
setappdata(gcf,'BeamQualData',[])
setappdata(gcf,'UpdateBeamQual',@UpdateBeamQual)
% DetRespData
setappdata(gcf,'DetRespData',[])
setappdata(gcf,'UpdateDetRespData',@UpdateDetRespData)
% DetRespData
setappdata(gcf,'WaterAirMMEAC',[])
setappdata(gcf,'UpdateWaterAirMMEAC',@UpdateWaterAirMMEAC)
% Choose default command line output for Calibration
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Calibration wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = Calibration_OutputFcn(hObject, eventdata, handles)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --------------------Kpol CORRECTION----------------------------------- %
% --- Executes on button press in EnterM_plus.
function EnterM_plus_Callback(hObject, eventdata, handles)
% Call M- measurement dialog box
MplusMeasurement;
% Set the handles structure to be used in other functions in Main.
% Important: The handes should be passed in the OpeningFcn for
% global use.
setappdata(0,'handles_MplusMeasurement',handles)
% Update with save_callback
UpdateMeanMplus;
function UpdateMeanMplus
% Get the main Gui data and use its fields
hMainGui = getappdata(0,'hMainGui');
MeanMplus = getappdata(hMainGui,'MeanMplus');
% Use EnterM_plus_Callback handle to set the required value
handles_MplusMeasurement = getappdata(0,'handles_MplusMeasurement');
set(handles_MplusMeasurement.MeanMplus,'String',MeanMplus);
return;
% --- Executes on button press in EnterM_minus.
function EnterM_minus_Callback(hObject, eventdata, handles)
% Call M- measurement dialog box
MminusMeasurement;
% Set the handles structure to be used in other functions in Main.
% Important: The handes should be passed in the OpeningFcn for
% global use.
setappdata(0,'handles_MminusMeasurement',handles)
% Update with save_callback
UpdateMeanMminus;
function UpdateMeanMminus
% Get the main Gui data and use its fields
hMainGui = getappdata(0,'hMainGui');
MeanMminus = getappdata(hMainGui,'MeanMminus');
% Use EnterM_minus_Callback handle to set the required value
handles_MminusMeasurement = getappdata(0,'handles_MminusMeasurement');
set(handles_MminusMeasurement.MeanMminus,'String',MeanMminus);
return;
% --- Executes on button press in KpolCALC.
function KpolCALC_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
MeanMplus = getappdata(hMainGui,'MeanMminus');
MeanMminus = getappdata(hMainGui,'MeanMplus');
Kpol = (abs(MeanMplus) + abs(MeanMminus)) / (2 * abs(MeanMplus));
if isnan(Kpol)
fprintf('Make sure no field in this section is left empty\n');
setappdata(hMainGui,'ErrorText','ERROR: Make sure no field in this section is left empty.');
Error;
end
set(handles.Kpol,'String',Kpol);
setappdata(hMainGui,'Kpol',Kpol);
% --------------------- Ktp CORRECTION --------------------------------- %
% TEMPERATURE
% --- Executes on button press in Temperature.
function Temp_Callback(hObject, eventdata, handles)
% Call temp measurement dialog box
Temp;
% Set the handles structure to be used in other functions in Main.
% Important: The handes should be passed in the OpeningFcn for
% global use.
setappdata(0,'handles_Temp',handles)
% Update with save_callback
UpdateTemp;
function UpdateTemp
% Get the main Gui data and use its fields
hMainGui = getappdata(0,'hMainGui');
MeanTemp = getappdata(hMainGui,'MeanTemp');
% Use EnterM_minus_Callback handle to set the required value
handles_Temp = getappdata(0,'handles_Temp');
set(handles_Temp.MeanTemp,'String',MeanTemp);
return;
% --- Executes on button press in Pressure.
function Pressure_Callback(hObject, eventdata, handles)
Pressure;
% Set the handles structure to be used in other functions in Main.
% Important: The handes should be passed in the OpeningFcn for
% global use.
setappdata(0,'handles_Pressure',handles)
% Update with save_callback
UpdatePressure;
function UpdatePressure
% Get the main Gui data and use its fields
hMainGui = getappdata(0,'hMainGui');
MeanPressure = getappdata(hMainGui,'MeanPressure');
% Use EnterM_minus_Callback handle to set the required value
handles_Pressure = getappdata(0,'handles_Pressure');
set(handles_Pressure.MeanPressure,'String',MeanPressure);
return;
function RefTemp_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
RefTemp = get(handles.RefTemp,'String');
setappdata(hMainGui,'RefTemp',RefTemp);
function RefPressure_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
RefPressure = get(handles.RefPressure,'String');
setappdata(hMainGui,'RefPressure',RefPressure);
% --- Executes on button press in KtpCALC.
function KtpCALC_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
MeanTemp = str2double(getappdata(hMainGui,'MeanTemp'));
MeanPressure = str2double(getappdata(hMainGui,'MeanPressure'));
RefPressure = str2double(getappdata(hMainGui,'RefPressure'));
RefTemp = str2double(getappdata(hMainGui,'RefTemp'));
ElectrometerKtpEnabled = get(handles.ElectrometerKtpEnabled,'SelectedObject');
ElecKtpEnab = get(ElectrometerKtpEnabled,'String');
setappdata(hMainGui,'ElecKtpEnab',ElecKtpEnab)
if strcmp(ElecKtpEnab,'No')
Ktp = (RefPressure / MeanPressure) * (273.2 + MeanTemp) / (273.2 + RefTemp);
if isnan(Ktp)
fprintf('Make sure no field in this section is left empty\n');
setappdata(hMainGui,'ErrorText','ERROR: Make sure no field in this section is left empty.');
Error;
end
set(handles.Ktp,'String',Ktp);
setappdata(hMainGui,'Ktp',Ktp);
else if strcmp(ElecKtpEnab,'Yes')
Ktp = 1;
set(handles.Ktp,'String',Ktp);
setappdata(hMainGui,'Ktp',Ktp);
end
end
%----------------------------------------------------------------------------------------------------------
% --------------------- Ks CORRECTION --------------------------------- %
% --- Executes on button press in ValueSet1.
function ValueSet1_Callback(hObject, eventdata, handles)
ValueSet1;
% Set the handles structure to be used in other functions in Main.
% Important: The handes should be passed in the OpeningFcn for
% global use.
setappdata(0,'handles_ValueSet1',handles)
% Update with save_callback
UpdateValueSet1;
function UpdateValueSet1
% Get the main Gui data and use its fields
hMainGui = getappdata(0,'hMainGui');
MeanValueSet1 = getappdata(hMainGui,'MeanValueSet1');
% handles_ValueSet1 = getappdata(0,'handles_ValueSet1');
setappdata(hMainGui,'MeanValueSet1',MeanValueSet1);
return;
% --- Executes on button press in KsCALC.
function KsCALC_Callback(hObject, eventdata, handles)
LinRegr;
hMainGui = getappdata(0,'hMainGui');
FitFunc = getappdata(hMainGui,'KsFitFunc');
Ks = 1/FitFunc(0);
if isnan(Ks)
fprintf('Make sure no field in this section is left empty\n');
setappdata(hMainGui,'ErrorText','ERROR: Make sure no field in this section is left empty.');
Error;
end
set(handles.Ks,'String',Ks);
setappdata(hMainGui,'Ks',Ks);
% --- Executes on button press in ValueSet3.
function ValueSet3_Callback(hObject, eventdata, handles)
ValueSet3;
% Set the handles structure to be used in other functions in Main.
% Important: The handes should be passed in the OpeningFcn for
% global use.
setappdata(0,'handles_ValueSet3',handles)
% Update with save_callback
UpdateValueSet3;
function UpdateValueSet3
% Get the main Gui data and use its fields
hMainGui = getappdata(0,'hMainGui');
MeanValueSet3 = getappdata(hMainGui,'MeanValueSet3');
% handles_ValueSet3 = getappdata(0,'handles_ValueSet3');
setappdata(hMainGui,'MeanValueSet3',MeanValueSet3);
return;
% --- Executes on button press in ValueSet2.
function ValueSet2_Callback(hObject, eventdata, handles)
ValueSet2;
% Set the handles structure to be used in other functions in Main.
% Important: The handes should be passed in the OpeningFcn for
% global use.
setappdata(0,'handles_ValueSet2',handles)
% Update with save_callback
UpdateValueSet2;
function UpdateValueSet2
% % Get the main Gui data and use its fields
hMainGui = getappdata(0,'hMainGui');
MeanValueSet2 = getappdata(hMainGui,'MeanValueSet2');
%
% handles_ValueSet2 = getappdata(0,'handles_ValueSet2');
setappdata(hMainGui,'MeanValueSet2',MeanValueSet2);
return;
% --- Executes on button press in ValueSet4.
function ValueSet4_Callback(hObject, eventdata, handles)
ValueSet4;
% Set the handles structure to be used in other functions in Main.
% Important: The handes should be passed in the OpeningFcn for
% global use.
setappdata(0,'handles_ValueSet4',handles)
% Update with save_callback
UpdateValueSet4;
function UpdateValueSet4
% % Get the main Gui data and use its fields
hMainGui = getappdata(0,'hMainGui');
MeanValueSet4 = getappdata(hMainGui,'MeanValueSet4');
%
% % handles_ValueSet4 = getappdata(0,'handles_ValueSet4');
setappdata(hMainGui,'MeanValueSet4',MeanValueSet4);
return;
% --- Executes on button press in ValueGraph.
function ValueGraph_Callback(hObject, eventdata, handles)
ViewGraph;
% --- Executes on button press in Kh.
function Kh_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
KhDisp = get(handles.KhDisp,'String');
setappdata(hMainGui,'Kh',KhDisp);
% --- Executes on button press in Kelec.
function Kelec_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
KelecDisp = get(handles.KelecDisp,'String');
setappdata(hMainGui,'Kelec',KelecDisp);
function NominalVoltage_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
NominalVoltage = get(handles.NominalVoltage,'String');
setappdata(hMainGui,'NominalVoltage',NominalVoltage);
% --- Executes on button press in EnterBeamQual.
function EnterBeamQual_Callback(hObject, eventdata, handles)
BeamQual;
% Set the handles structure to be used in other functions in Main.
% Important: The handes should be passed in the OpeningFcn for
% global use.
setappdata(0,'handles_BeamQual',handles)
% Update with save_callback
UpdateBeamQual;
function UpdateBeamQual
% Get the main Gui data and use its fields
hMainGui = getappdata(0,'hMainGui');
BeamQualData = getappdata(hMainGui,'BeamQualData');
% handles_BeamQual = getappdata(0,'handles_BeamQual');
setappdata(hMainGui,'BeamQualData',BeamQualData);
return;
% --- Executes on button press in KqCALC.
function KqCALC_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
KqCALM = get(handles.KqCALCmethod,'SelectedObject');
KqCALMode = get(KqCALM,'String');
setappdata(hMainGui,'KqCALMode',KqCALMode)
if strcmp(KqCALMode,'Kilovoltage Beams')
BeamQualData = getappdata(hMainGui,'BeamQualData');
kV = str2double(getappdata(hMainGui,'kV'));
if isnan(kV)
fprintf('Make sure nominal tube potential value is set and the beam quality data field is not empty.\n');
setappdata(hMainGui,'ErrorText','ERROR: Make sure nominal tube potential value is set and the beam quality data field is not empty.');
Error;
end
BeamQualxData = BeamQualData(1:ceil(end/2));
BeamQualyData = BeamQualData((ceil(end/2)+1):end);
IntrKq = interp1(BeamQualxData,BeamQualyData,kV,'pchip','extrap');
set(handles.Kq,'String',IntrKq);
setappdata(hMainGui,'Kq',IntrKq);
else if strcmp(KqCALMode,'BraggGray Theory')
fprintf(' Bragg-Gray theory has not been implemented yet.\n');
setappdata(hMainGui,'ErrorText','ERROR: Bragg-Gray theory has not been implemented yet.');
Error;
end
end
% --- Executes on button press in pushbutton21.
function pushbutton21_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton21 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton22.
function pushbutton22_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton22 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton23.
function pushbutton23_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton23 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in KqViewGraph.
function KqViewGraph_Callback(hObject, eventdata, handles)
KqViewGraph;
function Nk_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
Nk = get(handles.Nk,'String');
setappdata(hMainGui,'Nk',Nk);
function kV_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
kV = get(handles.kV,'String');
setappdata(hMainGui,'kV',kV);
function KhDisp_Callback(hObject, eventdata, handles)
% hObject handle to KhDisp (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of KhDisp as text
% str2double(get(hObject,'String')) returns contents of KhDisp as a double
function KelecDisp_Callback(hObject, eventdata, handles)
% hObject handle to KelecDisp (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of KelecDisp as text
% str2double(get(hObject,'String')) returns contents of KelecDisp as a double
function mA_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
mA = get(handles.mA,'String');
setappdata(hMainGui,'mA',mA);
function CalibNo_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
CalibNo = get(handles.CalibNo,'String');
setappdata(hMainGui,'CalibNo',CalibNo);
function RefNo_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
RefNo = get(handles.RefNo,'String');
setappdata(hMainGui,'RefNo',RefNo);
function BeamQualHVL_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
BeamQualHVL = get(handles.BeamQualHVL,'String');
setappdata(hMainGui,'BeamQualHVL',BeamQualHVL);
% --- Executes on button press in EnterDetRespData.
function EnterDetRespData_Callback(hObject, eventdata, handles)
DetRespData;
% Set the handles structure to be used in other functions in Main.
% Important: The handes should be passed in the OpeningFcn for
% global use.
setappdata(0,'handles_DetRespData',handles)
% Update with save_callback
UpdateDetRespData;
function UpdateDetRespData
% Get the main Gui data and use its fields
hMainGui = getappdata(0,'hMainGui');
DetRespData = getappdata(hMainGui,'DetRespData');
% handles_DetRespData = getappdata(0,'handles_DetRespData');
setappdata(hMainGui,'DetRespData',DetRespData);
return;
% --- Executes on button press in DelTCALC.
function DelTCALC_Callback(hObject, eventdata, handles)
EndEffLinRegr;
hMainGui = getappdata(0,'hMainGui');
EndEffFitResult = getappdata(hMainGui,'EndEffFitResult');
EndEffCoeff = coeffvalues(EndEffFitResult);
EndEffroots = -roots(EndEffCoeff); % -ve value of the root
setappdata(hMainGui,'delT',EndEffroots);
set(handles.delT,'String',EndEffroots);
% --- Executes on button press in EndEffViewGraph.
function EndEffViewGraph_Callback(hObject, eventdata, handles)
EndEffViewGraph;
function edit10_Callback(hObject, eventdata, handles)
% hObject handle to edit10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit10 as text
% str2double(get(hObject,'String')) returns contents of edit10 as a double
% --- Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit11_Callback(hObject, eventdata, handles)
% hObject handle to edit11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit11 as text
% str2double(get(hObject,'String')) returns contents of edit11 as a double
% --- Executes during object creation, after setting all properties.
function edit11_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit12_Callback(hObject, eventdata, handles)
% hObject handle to edit12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit12 as text
% str2double(get(hObject,'String')) returns contents of edit12 as a double
% --- Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function MeasOffset_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
MeasOffset = get(handles.MeasOffset,'String');
setappdata(hMainGui,'MeasOffset',MeasOffset);
% --- Executes during object creation, after setting all properties.
function MeasOffset_CreateFcn(hObject, eventdata, handles)
% hObject handle to MeasOffset (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
str = get(hObject, 'String');
val = get(hObject,'Value');
hMainGui = getappdata(0,'hMainGui');
setappdata(hMainGui,'MselectionString',str{val});
setappdata(hMainGui,'Mselection',val);
% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function MeasuredValue_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
MeasuredValue = get(handles.MeasuredValue,'String');
setappdata(hMainGui,'MeasuredValue',MeasuredValue);
function SSD_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
SSD = get(handles.SSD,'String');
setappdata(hMainGui,'SSD',SSD);
function FieldSize_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
FieldSize = get(handles.FieldSize,'String');
setappdata(hMainGui,'FieldSize',FieldSize);
function TotalRadTime_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
TotalRadTime = get(handles.TotalRadTime,'String');
setappdata(hMainGui,'TotalRadTime',TotalRadTime);
% --- Executes during object creation, after setting all properties.
function TotalRadTime_CreateFcn(hObject, eventdata, handles)
% hObject handle to TotalRadTime (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in ResultsCALC.
function ResultsCALC_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
Kpol = getappdata(hMainGui,'Kpol');
Ktp = getappdata(hMainGui,'Ktp');
Ks = getappdata(hMainGui,'Ks');
Kh = str2double(getappdata(hMainGui,'Kh'));
Kelec = str2double(getappdata(hMainGui,'Kelec'));
MeasuredValue = str2double(getappdata(hMainGui,'MeasuredValue'));
MeasOffset = str2double(getappdata(hMainGui,'MeasOffset'));
Mselection = getappdata(hMainGui,'Mselection');
CalibNo = getappdata(hMainGui,'CalibNo');
RefNo = getappdata(hMainGui,'RefNo');
mA = str2double(getappdata(hMainGui,'mA'));
kV = str2double(getappdata(hMainGui,'kV'));
BeamQualHVL = str2double(getappdata(hMainGui,'BeamQualHVL'));
SSD = str2double(getappdata(hMainGui,'SSD'));
FieldSize = str2double(getappdata(hMainGui,'FieldSize'));
MselectionString = getappdata(hMainGui,'MselectionString');
RefTemp = str2double(getappdata(hMainGui,'RefTemp'));
RefPressure = str2double(getappdata(hMainGui,'RefPressure'));
MeanMplus = getappdata(hMainGui,'MeanMplus');
MeanMminus = getappdata(hMainGui,'MeanMminus');
MeanTemp = str2double(getappdata(hMainGui,'MeanTemp'));
MeanPressure = str2double(getappdata(hMainGui,'MeanPressure'));
NominalVoltage = str2double(getappdata(hMainGui,'NominalVoltage'));
ElecKtpEnab = getappdata(hMainGui,'ElecKtpEnab');
KqCALMode = getappdata(hMainGui,'KqCALMode');
StemCorrection = str2double(getappdata(hMainGui,'StemCorrection'));
Kq = getappdata(hMainGui,'Kq');
Nk = str2double(getappdata(hMainGui,'Nk'));
TotalRadTime = str2double(getappdata(hMainGui,'TotalRadTime'));
delT = getappdata(hMainGui,'delT');
BackScatterFactor = str2double(getappdata(hMainGui,'BackScatterFactor'));
MMEAC_WaterToAir = getappdata(hMainGui,'MMEAC_WaterToAir');
if isempty(Mselection) || isnan(Mselection)
fprintf('Please select the measurement condition first. \n');
setappdata(hMainGui,'ErrorText','ERROR: Please select the measurement condition first.');
Error;
end
switch Mselection
case 1
setappdata(hMainGui,'ErrorText','ERROR: Please select the measurement condition.');
Error;
case 2
CorrectedReading = (MeasuredValue - MeasOffset)*Kpol*Ktp*Ks*Kh*Kelec;
if isempty(CorrectedReading) || isnan(CorrectedReading)
fprintf('Please ensure that the raw measurement and the offset is entered. \n');
setappdata(hMainGui,'ErrorText','ERROR: Please ensure that the raw measurement and the offset is entered.');
Error;
elseif isempty(Kpol) || isnan(Kpol) || isempty(Ks) || isnan(Ks) || isempty(Kh) || isempty(Kelec) || isempty(Ktp) || isnan(Ktp)
fprintf('Please ensure that the correction factors are calculated correctly. \n');
setappdata(hMainGui,'ErrorText','ERROR: Please ensure that the correction factors are calculated correctly.');
Error;
end
case 3
CorrectedReading = (MeasuredValue - MeasOffset)*Kpol*Ks*Kh*Kelec;
if isempty(CorrectedReading) || isnan(CorrectedReading)
fprintf('Please ensure that the raw measurement and the offset is entered. \n');
setappdata(hMainGui,'ErrorText','ERROR: Please ensure that the raw measurement and the offset is entered.');
Error;
elseif isempty(Kpol) || isnan(Kpol) || isempty(Ks) || isnan(Ks) || isempty(Kh) || isempty(Kelec)
fprintf('Please ensure that the correction factors are calculated correctly. \n');
setappdata(hMainGui,'ErrorText','ERROR: Please ensure that the correction factors are calculated correctly.');
Error;
end
case 4
CorrectedReading = (MeasuredValue - MeasOffset);
if isempty(CorrectedReading) || isnan(CorrectedReading)
fprintf('Please ensure that the raw measurement and the offset is entered. \n');
setappdata(hMainGui,'ErrorText','ERROR: Please ensure that the raw measurement and the offset is entered.');
Error;
end
end
if isempty(Kq) || isnan(Kq)
fprintf('Please ensure that the beam quality factor is calculated first. \n');
setappdata(hMainGui,'ErrorText','ERROR: Please ensure that the beam quality factor is calculated first.');
Error;
elseif isempty(Nk) || isnan(Nk)
fprintf('Please ensure that the calibration factor (Nk) is entered. \n');
setappdata(hMainGui,'ErrorText','ERROR: Please ensure that the calibration factor (Nk) is entered.');
Error;
elseif isempty(StemCorrection) || isnan(StemCorrection)
fprintf('Please ensure that the stem correction factor is entered. \n');
setappdata(hMainGui,'ErrorText','ERROR: Please ensure that the stem correction factor is entered.');
Error;
elseif isempty(TotalRadTime) || isnan(TotalRadTime)
fprintf('Please ensure that the total radiation time is entered. \n');
setappdata(hMainGui,'ErrorText','ERROR: Please ensure that the total radiation time is entered.');
Error;
elseif isempty(delT) || isnan(delT)
fprintf('Please ensure that the end effect correction is calculated correctly. \n');
setappdata(hMainGui,'ErrorText','ERROR: Please ensure that the end effect correction is calculated correctly.');
Error;
end
set(handles.CorrectedReading,'String',CorrectedReading);
Dw = CorrectedReading*Nk*Kq*StemCorrection*BackScatterFactor*MMEAC_WaterToAir;
setappdata(hMainGui,'Dw',Dw);
set(handles.Dw,'String',Dw);
DoseRate = Dw/(TotalRadTime + delT);
setappdata(hMainGui,'DoseRate',DoseRate);
set(handles.DoseRate,'String',DoseRate);
Parameter = {'Calibration No.';'Reference No.'; 'Nominal Tube Current [mA]';'Nominal Tube Voltage [kV]';...
'Beam Quality HVL [mm Al]';'Air-Kerma Calibration Nk [Gy/C]';'SSD [cm]';...
'Field size [cm^2]';'Total Radiation Time [sec]';'Mean M+ [C]';'Mean M- [C]';'Mean Temperature [deg.C]';...
'Mean Pressure [kPa]';'Reference Temperature [deg.C]';'Reference Pressure [kPa]';
'Electrometer Nominal Voltage [+/- V]'; 'Kpol'; 'Ktp';'Electrometer Ktp Correction Enabled?';...
'Ks';'Kh';'Kelec';'Kq';'Kq Calculation Method';'End Effect time [sec]';'Stem Correction Factor';'Back scatter factor';...
'Measurement Type';'Measurement Value [C]';'Measurement Offset [C]';...
'Correct Reading M [C]';'Absorbed dose to water Dw [Gy]';'Dose Rate [Gy/sec]'};
Values = {CalibNo;RefNo;mA;kV;BeamQualHVL;Nk;SSD;FieldSize;TotalRadTime;...
MeanMplus;MeanMminus;MeanTemp;MeanPressure;RefTemp;RefPressure;...
NominalVoltage;Kpol;Ktp;ElecKtpEnab;Ks;Kh;Kelec;Kq;KqCALMode;...
delT;StemCorrection;BackScatterFactor;MselectionString;MeasuredValue;MeasOffset;CorrectedReading;...
Dw;DoseRate};
TableCD = table(Parameter,Values);
writetable(TableCD,'Calibration_Data.csv');
fclose('all');
% --- Executes on button press in pushbutton29.
function pushbutton29_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton29 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in SaveButton.
function SaveButton_Callback(hObject, eventdata, handles)
SaveFile;
% --- Executes on button press in WaterAirMMEAC.
function WaterAirMMEAC_Callback(hObject, eventdata, handles)
WaterToAirMeanMassEnergyAbsCoeff;
setappdata(0,'handles_WaterAirMMEAC',handles)
% Update with save_callback
UpdateWaterAirMMEAC;
function UpdateWaterAirMMEAC
% Get the main Gui data and use its fields
hMainGui = getappdata(0,'hMainGui');
WaterAirMMEAC = getappdata(hMainGui,'WaterAirMMEAC');
% handles_DetRespData = getappdata(0,'handles_DetRespData');
setappdata(hMainGui,'WaterAirMMEAC',WaterAirMMEAC);
return;
function StemCorrection_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
StemCorrection = get(handles.StemCorrection,'String');
setappdata(hMainGui,'StemCorrection',StemCorrection);
function BackScatterFactor_Callback(hObject, eventdata, handles)
hMainGui = getappdata(0,'hMainGui');
BackScatterFactor = get(handles.BackScatterFactor,'String');
setappdata(hMainGui,'BackScatterFactor',BackScatterFactor);