libtpcmodext
 All Files Functions Variables Defines
Functions
dftinput.c File Reference
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include "include/libtpcmodext.h"
Include dependency graph for dftinput.c:

Go to the source code of this file.

Functions

int dftReadinput (DFT *input, DFT *tissue, char *filename, int *filetype, double *ti1, double *ti2, char *status)
int dftReadReference (DFT *tissue, char *filename, int *filetype, int *ref_index, char *status)
int dftReadModelingData (char *tissuefile, char *inputfile1, char *inputfile2, char *inputfile3, double *fitdur, int *fitframeNr, DFT *tis, DFT *inp, FILE *loginfo, int verbose, char *status)
int dftRobustMinMaxTAC (DFT *dft, int tacindex, double *minx, double *maxx, double *miny, double *maxy, int *mini, int *maxi)

Function Documentation

int dftReadinput ( DFT *  input,
DFT *  tissue,
char *  filename,
int *  filetype,
double *  ti1,
double *  ti2,
char *  status 
)

Read DFT format input TAC data to match the time frames in the specified tissue DFT file. Instead of input filename, a reference region name can be given: then all the matching tacs (based on roi names) are moved from the roi data to the input data, with the best match as first tac. Input data is interpolated (if necessary) and also integrated to y2[]. Input time and concentration units are tried to be converted to be the same as in tissue data.

Returns:
Returns 0 if succesful, and >0 in case of an error.
Parameters:
inputInput data, previous contents are cleared
tissuePET data containing frames and possible input regions
filenameInput data filename, or region name in PET data
filetypeType of input, as found out here; 1 and 2 =tac, 3=fit, 5=region name; enter NULL, if not needed
ti1First time of input data before interpolation (in tissue time units); use this to check that required time range was measured; NULL if not needed
ti2Last time of input data before interpolation (in tissue time units); use this to check that required time range was measured; NULL if not needed
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 70 of file dftinput.c.

References dftInterpolate(), and MODEXT_TEST.

Here is the call graph for this function:

int dftReadModelingData ( char *  tissuefile,
char *  inputfile1,
char *  inputfile2,
char *  inputfile3,
double *  fitdur,
int *  fitframeNr,
DFT *  tis,
DFT *  inp,
FILE *  loginfo,
int  verbose,
char *  status 
)

Read tissue and input data for modeling. Time units are converted to min and input calibration units to units of tissue data. Input data is NOT interpolated to tissue times. If input data extends much further than fit duration, the last part is removed to save computation time in simulations. Input data is verified not to end too early, and not to start too late.

Returns:
Returns 0 when successful, otherwise a non-zero value.
Parameters:
tissuefileTissue data filename; one time sample is sufficient here
inputfile11st input data filename
inputfile22nd input data filename (or NULL if only not needed)
inputfile33rd input data filename (or NULL if only not needed)
fitdurFit duration (in minutes); shortened if longer than tissue data
fitframeNrNr of time frames (samples) in tissue data that are inside fitdur will be written here
tisPointer to initiated DFT into which tissue data will be written
inpPointer to initiated DFT into which input data (plasma and/or blood) will be written
loginfoGive file pointer (for example stdout) where log information is printed; NULL if not needed; warnings will be printed in stderr anyway.
verboseVerbose level; if zero, then only warnings are printed into stderr
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 365 of file dftinput.c.

References dftInterpolateInto(), and fittime_from_dft().

Here is the call graph for this function:

int dftReadReference ( DFT *  tissue,
char *  filename,
int *  filetype,
int *  ref_index,
char *  status 
)

Read DFT format reference region TAC data and add it into DFT already containing other tissue TACs, if reference region TAC(s) are be given in a separate file. Alternative the reference region name can be given, which will then be selected from existing tissue TACs. Reference TACs are marked in DFT with sw=2 (best name match) or sw=1; if reference region file contains several TACs then the one which contains name 'mean' or 'avg' or has shortest total name length is given value sw=2. When necessary, reference data is interpolated and units converted to match the existing tissue DFT. Reference TAC is also integrated into y2[].

Returns:
Returns the number of reference TACs, and <=0 in case of an error.
Parameters:
tissuePET data containing existing tissue TACs, possibly also reference regions
filenameReference TAC filename, or region name in previous data
filetypeType of input, as found out here; 1 and 2 =tac, 3=fit, 5=region name; enter NULL, if not needed
ref_indexIndex of the best reference region; enter NULL if not needed
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 228 of file dftinput.c.

References dftInterpolateInto(), and MODEXT_TEST.

Here is the call graph for this function:

int dftRobustMinMaxTAC ( DFT *  dft,
int  tacindex,
double *  minx,
double *  maxx,
double *  miny,
double *  maxy,
int *  mini,
int *  maxi 
)

Robust search of the min and max values of DFT TAC data. Data may contain NaN's, and indivial outliers are not taken as min or max.

Returns:
Returns 0 if successful.
Parameters:
dftPointer to the DFT TAC data to search
tacindexIndex of the only TAC which is searched for min and max; <0 if all
minxPointer to X at TAC min; set to NULL if not needed
maxxPointer to X at TAC max; set to NULL if not needed
minyPointer to min Y; set to NULL if not needed
maxyPointer to max Y; set to NULL if not needed
miniIndex of min TAC; set to NULL if not needed
maxiIndex of max TAC; set to NULL if not needed

Definition at line 631 of file dftinput.c.