TPCCLIB
Loading...
Searching...
No Matches
resift.c
Go to the documentation of this file.
1
5/*****************************************************************************/
6#include "libtpccurveio.h"
7/*****************************************************************************/
8
9/*****************************************************************************/
16 RES *res,
18 IFT *ift,
20 int verbose
21) {
22 int ri, pi, ret;
23 char tmp[1024], tmp2[1024], tmp3[1024];
24 struct tm st;
25
26 if(verbose>0) printf("res2ift()\n");
27
28 /* Check the input */
29 if(res==NULL || ift==NULL) {
30 if(verbose>0) fprintf(stderr, "Error: invalid input\n");
31 return(1);
32 }
33
34 /* Delete any previous content */
35 iftEmpty(ift);
36
37 /* Set header info */
38 if(strlen(res->program)>0) {
39 ret=iftPut(ift, "program", res->program, NULL, 0);
40 if(ret!=0) {
41 if(verbose>0) fprintf(stderr, "Error: cannot set IFT content\n");
42 return(3);
43 }
44 }
45 if(gmtime_r(&res->time, &st)!=NULL) {
46 strftime(tmp, 256, "%Y-%m-%d %H:%M:%S", &st);
47 iftPut(ift, "date", tmp, NULL, 0);
48 }
49 if(res->studynr[0]) iftPut(ift, "studynr", res->studynr, NULL, 0);
50 if(res->datafile[0]) iftPut(ift, "datafile", res->datafile, NULL, 0);
51 if(res->plasmafile[0]) iftPut(ift, "plasmafile", res->plasmafile, NULL, 0);
52 if(res->plasmafile2[0]) iftPut(ift, "plasmafile2", res->plasmafile2, NULL, 0);
53 if(res->bloodfile[0]) iftPut(ift, "bloodfile", res->bloodfile, NULL, 0);
54 if(res->reffile[0]) iftPut(ift, "reffile", res->reffile, NULL, 0);
55 if(res->refroi[0]) iftPut(ift, "refroi", res->refroi, NULL, 0);
56
57 if(res->datarange[0]) iftPut(ift, "datarange", res->datarange, NULL, 0);
58 if(res->datanr>0) {
59 snprintf(tmp, 1024, "%d", res->datanr); iftPut(ift, "datanr", tmp, NULL, 0);}
60 if(res->fitmethod[0]) iftPut(ift, "fitmethod", res->fitmethod, NULL, 0);
61
62 if(res->density>0) {
63 snprintf(tmp, 1024, "%g", res->density); iftPut(ift, "density", tmp, NULL, 0);}
64 if(res->lc>0) {
65 snprintf(tmp, 1024, "%g", res->lc); iftPut(ift, "lc", tmp, NULL, 0);}
66 if(res->concentration>0) {
67 snprintf(tmp, 1024, "%g", res->concentration);
68 iftPut(ift, "concentration", tmp, NULL, 0);
69 }
70 if(res->beta>0) {
71 snprintf(tmp, 1024, "%g", res->beta); iftPut(ift, "beta", tmp, NULL, 0);}
72 if(res->Vb>0) {
73 snprintf(tmp, 1024, "%g", res->Vb); iftPut(ift, "Vb", tmp, NULL, 0);}
74 if(res->fA>0) {
75 snprintf(tmp, 1024, "%g", res->fA); iftPut(ift, "fA", tmp, NULL, 0);}
76 if(res->E>0) {
77 snprintf(tmp, 1024, "%g", res->E); iftPut(ift, "E", tmp, NULL, 0);}
78 if(res->isweight>0) strcpy(tmp, "yes");
79 else if(res->isweight==0) strcpy(tmp, "no");
80 else strcpy(tmp, "unknown");
81 iftPut(ift, "weighting", tmp, NULL, 0);
82
83 /* Set each ROI and parameter value */
84 for(ri=0; ri<res->voiNr; ri++) {
85 if(res->voiNr>1) {
86 strcpy(tmp, res->voi[ri].name); rnameRmDots(tmp, NULL);
87 strcat(tmp, "_");
88 } else {
89 strcpy(tmp, "");
90 }
91 for(pi=0; pi<res->parNr; pi++) {
92 snprintf(tmp2, 1024, "%s%s", tmp, res->parname[pi]);
93 if(isnan(res->voi[ri].parameter[pi])) strcpy(tmp3, "");
94 else sprintf(tmp3, "%g", res->voi[ri].parameter[pi]);
95 if(strlen(res->parunit[pi])) {
96 strcat(tmp3, " "); strcat(tmp3, res->parunit[pi]);}
97 iftPut(ift, tmp2, tmp3, NULL, 0);
98 if(!isnan(res->voi[ri].sd[pi])) {
99 snprintf(tmp2, 1024, "%s%s_%s", tmp, res->parname[pi], "SD");
100 snprintf(tmp3, 1024, "%g", res->voi[ri].sd[pi]);
101 if(strlen(res->parunit[pi])) {
102 strcat(tmp3, " "); strcat(tmp3, res->parunit[pi]);}
103 iftPut(ift, tmp2, tmp3, NULL, 0);
104 }
105 if(!isnan(res->voi[ri].cl1[pi])) {
106 snprintf(tmp2, 1024, "%s%s_%s", tmp, res->parname[pi], "CL1");
107 snprintf(tmp3, 1024, "%g", res->voi[ri].cl1[pi]);
108 if(strlen(res->parunit[pi])) {
109 strcat(tmp3, " "); strcat(tmp3, res->parunit[pi]);}
110 iftPut(ift, tmp2, tmp3, NULL, 0);
111 }
112 if(!isnan(res->voi[ri].cl2[pi])) {
113 snprintf(tmp2, 1024, "%s%s_%s", tmp, res->parname[pi], "CL2");
114 snprintf(tmp3, 1024, "%g", res->voi[ri].cl2[pi]);
115 if(strlen(res->parunit[pi])) {
116 strcat(tmp3, " "); strcat(tmp3, res->parunit[pi]);}
117 iftPut(ift, tmp2, tmp3, NULL, 0);
118 }
119 }
120 }
121
122 return(0);
123}
124/*****************************************************************************/
125
126/*****************************************************************************/
struct tm * gmtime_r(const time_t *t, struct tm *tm)
Convert time_t to GMT struct tm.
Definition datetime.c:22
int iftPut(IFT *ift, char *key, char *value, char *cmt_type, int verbose)
Definition ift.c:82
void iftEmpty(IFT *ift)
Definition ift.c:60
Header file for libtpccurveio.
int rnameRmDots(char *rname1, char *rname2)
Definition rname.c:99
int res2ift(RES *res, IFT *ift, int verbose)
Definition resift.c:14
double E
double density
char plasmafile2[FILENAME_MAX]
char studynr[MAX_STUDYNR_LEN+1]
double concentration
int parNr
char parname[MAX_RESPARAMS][MAX_RESPARNAME_LEN+1]
double fA
int voiNr
int datanr
double beta
ResVOI * voi
double Vb
char program[1024]
char plasmafile[FILENAME_MAX]
char datarange[128]
int isweight
double lc
char datafile[FILENAME_MAX]
char reffile[FILENAME_MAX]
char fitmethod[128]
char refroi[64]
char parunit[MAX_RESPARAMS][MAX_RESPARNAME_LEN+1]
char bloodfile[FILENAME_MAX]
time_t time
double parameter[MAX_RESPARAMS]
double cl2[MAX_RESPARAMS]
double cl1[MAX_RESPARAMS]
char name[MAX_REGIONNAME_LEN+1]
double sd[MAX_RESPARAMS]