Write ABSS data into file opened for writing.
61 {
62 int verbose=0;
if(status!=NULL) verbose=status->
verbose;
63 if(verbose>0) {printf("%s()\n", __func__); fflush(stdout);}
64 if(fp==NULL) {
67 }
71 }
72
73 char buf[1024];
75
77
79
80
81 int ii;
86 statusSet(status, __func__, __FILE__, __LINE__, ret);
return(ret);
87 }
88
92 }
93 fprintf(fp, "# Patient: %s\n", buf);
94
97 if(!isnan(hl)) sprintf(buf, "%f", hl); else strcpy(buf, "");
98 } else {
101 }
102 fprintf(fp, "# Isotope half-life: %s\n", buf);
103
104 fprintf(fp, "# Start Interv 1st detector pair");
105 fprintf(fp, " 2nd detector pair AUX\n");
106 fprintf(fp, "# time time coinc singl1 singl2");
107 fprintf(fp, " coinc singl1 singl2 counts\n");
108
110 if(ii>=0) {
113 fprintf(fp, "# %s\n", buf);
114 }
115
116
117
118 double sod=0.0;
120 struct tm tmsod;
122 sod=3600.*tmsod.tm_hour+60.*tmsod.tm_min+tmsod.tm_sec;
123 }
124 int i, j;
126 fprintf(fp,
"%9.1f %9.1f %9.1f", sod+d->
x1[i], d->
x1[i], d->
x2[i]-d->
x1[i]);
127 for(j=0; j<7; j++) {
128 if(j<d->tacNr) fprintf(fp,
" %7.0f", d->
c[j].
y[i]);
129 else fprintf(fp, " %7.0f", 0.0);
130 }
132 }
134 statusSet(status, __func__, __FILE__, __LINE__, ret);
return(ret);
135 }
136
139 }
140
141
143
145
146
147 fprintf(fp, "# Scanditronics Automated Blood Measurement System\n");
148 int ii;
153 statusSet(status, __func__, __FILE__, __LINE__, ret);
return(ret);
154 }
155
156 fprintf(fp, "# Start Interv 1st detector pair");
157 fprintf(fp, " 2nd detector pair AUX\n");
158 fprintf(fp, "# time time coinc singl1 singl2");
159 fprintf(fp, " coinc singl1 singl2 counts\n");
160
162 if(ii>=0) {
165 fprintf(fp, "# %s\n", buf);
166 }
167
168
169
170 time_t t=0.0;
172
173 struct tm tmsod;
175 }
176 int i, j;
178 fprintf(fp, "%13.1f %9.1f %9.1f",
179 d->
x1[i]+(
unsigned long int)t, d->
x1[i], d->
x2[i]-d->
x1[i]);
180 for(j=0; j<7; j++) {
181 if(j<d->tacNr) fprintf(fp,
" %7.0f", d->
c[j].
y[i]);
182 else fprintf(fp, " %7.0f", 0.0);
183 }
185 }
187 statusSet(status, __func__, __FILE__, __LINE__, ret);
return(ret);
188 }
189
192 }
193
194
196
198
202 }
203
204
205 fprintf(fp, "# Allogg1\n");
206 int ii;
208
212 statusSet(status, __func__, __FILE__, __LINE__, ret);
return(ret);
213 }
214
218 statusSet(status, __func__, __FILE__, __LINE__, ret);
return(ret);
219 }
220
222 fprintf(fp, "# %s\n", buf);
223 }
224
228 statusSet(status, __func__, __FILE__, __LINE__, ret);
return(ret);
229 }
230
231
233 fprintf(fp, "\n%2.2s%2.2s%2.2s\n", buf+11, buf+14, buf+17);
234 } else {
235 fprintf(fp, "\n000000\n");
236 }
237
238
240 if(fprintf(fp, "%6.1f %5.0f %5.0f\n",
241 d->
x2[i], d->
c[0].
y[i], d->
c[1].
y[i]) < 10)
242 {
244 }
245 }
247 statusSet(status, __func__, __FILE__, __LINE__, ret);
return(ret);
248 }
249
252 }
253
254
256
260 }
261
262 int ii;
263
265
266
268 if(ii>=0 &&
270 {
273 }
274
275
276 fprintf(fp, "//Heading\n");
277
298 ii=
iftFindKey(&d->
h,
"DiscriminatorCoincidents", 0);
304
305
306 if(fprintf(fp, "//Data\n")<6) {
309 }
310 fprintf(fp, "Absolute time\t");
311 fprintf(fp, "Time after start [s]\t");
312 fprintf(fp, "Singles [cnt]\t");
313 fprintf(fp, "Coincidents [cnt]\t");
314 fprintf(fp, "Singles count rate [kBq/ml]\t");
315 fprintf(fp, "Coincidents count rate [kBq/ml]\t");
316 fprintf(fp, "Singles count rate DTC [kBq/ml]\t");
317 fprintf(fp, "Coincidents count rate DTC [kBq/ml]\t");
318 fprintf(fp, "Singles DTC&decay [kBq/ml]\t");
319 fprintf(fp, "Coincidents DTC&decay [kBq/ml]\n");
320 struct tm tmtod;
322
324 }
325 int i, j;
327 if(i>0)
tmAdd(d->
x1[i]-d->
x1[i-1], &tmtod);
328 if(strftime(buf, 32, "%Y-%m-%d %H:%M:%S", &tmtod)==0)
329 strcpy(buf, "1970-01-01 00:00:00");
330 fprintf(fp, "%s\t%.1f\t%.0f\t%.0f",
331 buf, d->
x1[i], d->
c[0].
y[i], d->
c[1].
y[i]);
332 for(j=2; j<8; j++) {
333 if(j<d->tacNr) fprintf(fp,
"\t%.12f", d->
c[j].
y[i]);
334 else fprintf(fp, "\t%f", 0.0);
335 }
337 }
339 statusSet(status, __func__, __FILE__, __LINE__, ret);
return(ret);
340 }
341
344 }
345
346
349}
int strDateTimeRead(const char *str, struct tm *date)
void tmAdd(int s, struct tm *d)
int iftSearchKey(IFT *ift, const char *s, int start_index)
int iftFindKey(IFT *ift, const char *key, int start_index)
int iftWriteItem(IFT *ift, int item, FILE *fp, TPCSTATUS *status)
double isotopeHalflife(int isotope_code)
int isotopeIdentify(const char *isotope)
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
size_t strlcpy(char *dst, const char *src, size_t dstsize)
IFT h
Optional (but often useful) header information.
int verbose
Verbose level, used by statusPrint() etc.
int tacGetHeaderScanstarttime(IFT *h, char *s, TPCSTATUS *status)
int tacGetHeaderStudynr(IFT *h, char *s, TPCSTATUS *status)
int tacGetHeaderIsotope(IFT *h, char *s, TPCSTATUS *status)
@ TPCERROR_UNSUPPORTED
Unsupported file type.
@ TPCERROR_NO_DATA
File contains no data.
@ TPCERROR_CANNOT_WRITE
Cannot write file.
@ TAC_FORMAT_ABSS_ALLOGG
ALLOGG ABSS data; reading supported.
@ TAC_FORMAT_ABSS_GEMS
GEMS ABSS data; reading supported.
@ TAC_FORMAT_ABSS_ALLOGG_OLD
ALLOGG ABSS data (old format); reading supported.
@ TAC_FORMAT_ABSS_SCANDITRONICS
Scanditronics ABSS data; reading supported.