TPCCLIB
Loading...
Searching...
No Matches
dftres.c File Reference

Utilities for setting up results structure based on DFT. More...

#include "libtpccurveio.h"

Go to the source code of this file.

Functions

int res_allocate_with_dft (RES *res, DFT *dft)
 
int dftToResult (DFT *dft, RES *res, char *status)
 

Detailed Description

Utilities for setting up results structure based on DFT.

Author
Vesa Oikonen

Definition in file dftres.c.

Function Documentation

◆ dftToResult()

int dftToResult ( DFT * dft,
RES * res,
char * status )

Copy the contents (both header and data) of DFT struct into RES struct.

See also
fitToResult, res_allocate_with_dft
Returns
Returns 0 if successful, in case of an error >0, and <0 if warning is suggested.
Parameters
dftRegional data from where necessary information is read.
resPointer to initiated RES struct which will be allocated here.
statusPointer to a string (allocated for at least 64 chars) where error message or other execution status will be written; enter NULL, if not needed.

Definition at line 60 of file dftres.c.

68 {
69 int ri, fi;
70
71 // Check the input data
72 if(status!=NULL) sprintf(status, "program error");
73 if(res==NULL || dft==NULL || dft->voiNr<1 || dft->frameNr<1) return 1;
74 // Allocate memory and copy most of headers
75 if(res_allocate_with_dft(res, dft) != 0) {
76 if(status!=NULL) sprintf(status, "cannot setup results data");
77 return 2;
78 }
79 res->parNr=dft->frameNr; if(res->parNr>MAX_RESPARAMS) {
80 sprintf(status, "only %d frames can be copied to results", MAX_RESPARAMS);
82 }
83 // Set parameter titles and units
84 for(fi=0; fi<res->parNr; fi++) {
85 sprintf(res->parname[fi], "%d", fi+1);
86 strcpy(res->parunit[fi], dft->unit);
87 }
88 // Copy regional values
89 for(ri=0; ri<dft->voiNr; ri++) for(fi=0; fi<res->parNr; fi++)
90 res->voi[ri].parameter[fi]=dft->voi[ri].y[fi];
91
92 if(dft->frameNr>MAX_RESPARAMS) return -1;
93 /* Set also deprecated parameter name and unit representations, for now */
94 resFixParnames(res);
95 return 0;
96}
int res_allocate_with_dft(RES *res, DFT *dft)
Definition dftres.c:14
void resFixParnames(RES *res)
Definition result.c:107
#define MAX_RESPARAMS
Voi * voi
int voiNr
int frameNr
char unit[MAX_UNITS_LEN+1]
int parNr
char parname[MAX_RESPARAMS][MAX_RESPARNAME_LEN+1]
ResVOI * voi
char parunit[MAX_RESPARAMS][MAX_RESPARNAME_LEN+1]
double parameter[MAX_RESPARAMS]
double * y

◆ res_allocate_with_dft()

int res_allocate_with_dft ( RES * res,
DFT * dft )

Allocate memory for regional results based on information in DFT.

See also
fit_allocate_with_dft, dftToResult
Returns
Returns 0 if successful, otherwise <>0.
Parameters
resPointer to initiated RES struct which will be allocated here and filled with ROI names etc.
dftRegional data from where necessary information is read.

Definition at line 14 of file dftres.c.

19 {
20 int ri;
21
22 //printf("res_allocate_with_dft()\n"); fflush(stdout);
23 // Check the input data
24 if(res==NULL || dft==NULL || dft->voiNr<1) return 1;
25 // Allocate memory
26 if(resSetmem(res, dft->voiNr)!=0) return 2;
27 res->voiNr=dft->voiNr;
28 // Copy header information
29 strcpy(res->studynr, dft->studynr);
30 res->Vb=-1.0;
31 res->fA=-1.0;
32 res->E=-1.0;
33 res->time=time(NULL); // Set current time to results
34 res->isweight=dft->isweight;
35 /* Copy region names, etc */
36 for(ri=0; ri<dft->voiNr; ri++) {
37 strcpy(res->voi[ri].name, dft->voi[ri].name);
38 strcpy(res->voi[ri].voiname, dft->voi[ri].voiname);
39 strcpy(res->voi[ri].hemisphere, dft->voi[ri].hemisphere);
40 strcpy(res->voi[ri].place, dft->voi[ri].place);
41 }
42 /* Set data range */
44 sprintf(res->datarange, "%g - %g %s",
45 dft->x1[0], dft->x2[dft->frameNr-1], petTunit(dft->timeunit) );
46 else
47 sprintf(res->datarange, "%g - %g %s",
48 dft->x[0], dft->x[dft->frameNr-1], petTunit(dft->timeunit) );
49 res->datanr=dft->frameNr;
50
51 return 0;
52}
int resSetmem(RES *res, int voiNr)
Definition result.c:70
#define DFT_TIME_STARTEND
char * petTunit(int tunit)
Definition petunits.c:226
int timetype
int timeunit
char studynr[MAX_STUDYNR_LEN+1]
double * x1
double * x2
int isweight
double * x
double E
char studynr[MAX_STUDYNR_LEN+1]
double fA
int voiNr
int datanr
double Vb
char datarange[128]
int isweight
time_t time
char hemisphere[MAX_REGIONSUBNAME_LEN+1]
char place[MAX_REGIONSUBNAME_LEN+1]
char name[MAX_REGIONNAME_LEN+1]
char voiname[MAX_REGIONSUBNAME_LEN+1]
char voiname[MAX_REGIONSUBNAME_LEN+1]
char name[MAX_REGIONNAME_LEN+1]
char hemisphere[MAX_REGIONSUBNAME_LEN+1]
char place[MAX_REGIONSUBNAME_LEN+1]

Referenced by dftToResult().