-
Notifications
You must be signed in to change notification settings - Fork 0
/
BB_ABS_only.ab
244 lines (180 loc) · 6.44 KB
/
BB_ABS_only.ab
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
' Edited from BB_abs_subtract. Only converts analyte raw signal to
' absorbance.
'
' Does the PMTabsorbance interactive conversion (code inserted).
' Saves the file with the original name and appends "_abs" to the end.
'
' Caution! It will overwrite files of the same name.
'
' Clear all traces from memory before starting!!! Not mandatory, but a good idea.
'
' 21.02.2014 ECN original writing
free
dim linename (40)
dim basename (40)
dim filename(256)
dim newfile (256)
dim dir(256)
dim prompt1 (512)
dim prompt2 (512)
dim blackbody(256)
dim auditcomment(1000)
dim txtpoints (256)
dim txtrangeaverage(256)
dim txtrangersd(256)
dim type(25)
onpaint 0 'prettier drawing
'make sure that we load into slots 1 and 2
files = getsfile() 'are there any files loaded?
if files = 0 then goto 500 'if no, then go ahead
setfile 1 'if yes, go to first slot
'to the good stuff
500
'get base filenames to make file selection easier
dialogbeg "Base names for data files"
dialogask linename, 2, 32, 32, "Type the base filename for all line files: "
dialogloc 0, 10 : dialogtxt 0, 0, 0, ""
dialogask basename, 2, 32, 32, "Type the base filename for all baseline files: "
dialogloc 0, 10 : dialogtxt 0, 0, 0, ""
dialogend 5
string linename = "?*" +$linename + "*.spc"
string basename = "?*" +$basename + "*.spc"
string prompt1 = "Select line file: " + $linename
string prompt2 = "Select blackbody trace to subtract: " +$basename
1000
'load line trace as f=0, becomes slot 1
'background as f=1, becomes slot 2
'!! string index starts at 0, slot index at 1
'!! we need to use f+1 for the setfile statements
menufile $filename, $prompt1
loadspc $filename 'open file
autoscale : see
strname 3, $newfile = $filename 'get output filename base only, no extension
strname 2, dir = $filename 'gets directory of line file
string dir, setdir 'sets current directory (should be set by the open
'command but this makes it explict)
2000
'load blackbody trace into volatile memory
menufile $blackbody, $prompt2
openspc $blackbody, bbsubtract
3000
'do the blackbody subtraction
#1 = #1 - bbsubtract 'line
see
'clean up volatile memory
closespc bbsubtract
'set up output
string $type = "_bb" 'set file suffix
gosub 9000 'audit log
gosub 8000 'write files
4000
'Zoom first
setleft getffp(), getflp()
autoscale : see
4020
dialogbeg "Zoom for processing"
dialogloc 0, 10 : dialogtxt 0, 0, 0, "Zoom on the baseline region just before atomization."
dialogloc 0, 10 : dialogtxt 0, 0, 0, "Drag a box (with left mouse button) to zoom"
dialogloc 0, 10 : dialogtxt 0, 0, 0, "Hint: include the atomization spike in the box"
dialogask mc,4,4050,0,"Do_it"
dialogend 5
4050
pointer llx, lly, lx, rx, urx, ury 'lx and ry are ignored and zero,
'llx and lly are lower-left corner of box
'urx and ury are upper-right corner of box
if llx = urx OR lly = ury OR llx = 0 then goto 20000 'trap for box with no area
setright urx : setleft llx 'set x-axis left and right
autoscale : see 'set y-axis
'Absorbance conversion
'operate on both traces in sequence
gosub 4100 'start absorbance conversion
string $type = "_abs" 'set file suffix
gosub 9200 'audit log
gosub 8000 'write files
goto 60000 'GO TO END, SKIP THE SUBTRACTION!!!
'go do the absorbance calculation
4100
'this section is a stand-alone method to get the
'average of a range of trace values
pointer cx, cy, lx, rx 'cx and cy are ignored, lx and rx are
'left and right range x-values
if npts(#s(lx,rx)) <= 5 then goto 21000
rangeaverage = sum(#s(lx,rx)) / npts(#s(lx,rx))
DegFre = npts(#s(lx,rx)) -1 'degrees of freedom for std.dev.
rangersd = ((sqrt(sumd2((#s(lx,rx)),rangeaverage)/DegFre))/rangeaverage)*100
string txtpoints = "Number of points in range = " + npts(#s(lx,rx))
string txtrangeaverage = "Average of selected range = " + rangeaverage
string txtrangersd = "RSD (%) of range = " + rangersd
dialogbeg "Average value of selected range"
dialogloc 0, 10 : dialogtxt 0, 0, 0, $txtpoints
dialogloc 0, 10 : dialogtxt 0, 0, 0, $txtrangeaverage
dialogloc 0, 10 : dialogtxt 0, 0, 0, $txtrangersd
dialogask mc,4, 4500,4100,"Accept Try_again"
dialogend 5
4500
'calculate absorbance using selected baseline average
baseline = rangeaverage 'convert name from above
#s = -log(#s/baseline) 'calculates absorbance
setytype 2 'sets y-axis to absorbance
autoscale
see
return
8000
'file saving
string newfile = $newfile + $type 'append suffix onto name
string newfile, setsname 'set the slot name to the appended name
savespc 'saves #s with its slot name, takes care of spc extension automatically
return
9000
'auditing for blackbody subtraction
portout addmod, 19 'add subtraction to audit log
'add filenames to audit log
string auditcomment = "Original File = " + $filename
dblog #0,-3,$auditcomment
string auditcomment = "Term File = " + $blackbody
dblog #0,-3,$auditcomment
string auditcomment = "Operation = Subtract"
dblog #0,-3,$auditcomment
dblog #0,-3," "
return
9200
'auditing for absorbance conversion
see
portout addmod, 25 'add conversion to audit log
'add filenames to audit log
string auditcomment = "Original File = " + $newfile
dblog #0,-3,$auditcomment
string auditcomment = "Operation = convert to absorbance"
dblog #0,-3,$auditcomment
dblog #0,-3," "
return
'%% Error Handling %%
20000 'zoom box errors
dialogbeg "Zoom selection"
dialogloc 0, 10 : dialogtxt 0, 0, 0, "No area selected."
dialogloc 0, 10 : dialogtxt 0, 0, 0, "Select a box containing the area of interest"
dialogask mc,4,4020,0,"Try_again"
dialogend 5
21000 'baseline selection errors
dialogbeg "Baseline selection"
dialogloc 0, 10 : dialogtxt 0, 0, 0, "Not enough points selected."
dialogloc 0, 10 : dialogtxt 0, 0, 0, "Baseline must contain more than 5 points"
dialogask mc,4,4100,0,"Try_again"
dialogend 5
' *******************
' Exit clean up code
' *******************
60000
dialogbeg "Continue processing"
dialogloc 0, 10 : dialogtxt 0, 0, 0, "Process another set of data?"
dialogloc 0, 10 : dialogtxt 0, 0, 0, "Previous data will be removed from the screen"
dialogloc 0, 10 : dialogtxt 0, 0, 0, ""
dialogask mc,4, 61000, 62000, "Yes No"
dialogend
61000
noshow
see
goto 1000
62000
free
end