6#ifndef _TPCEXTENSIONS_H_
7#define _TPCEXTENSIONS_H_
11#include "tpcclibConfig.h"
28#define MAX_UNITS_LEN 32
34#ifndef MAX_TACNAME_LEN
35#define MAX_TACNAME_LEN 31
38#ifndef MAX_PARNAME_LEN
39#define MAX_PARNAME_LEN MAX_TACNAME_LEN
45#ifndef MAX_STUDYNR_LEN
46#define MAX_STUDYNR_LEN 255
257extern int strTokenNr(
const char *s1,
const char *s2);
258extern int strTokenNCpy(
const char *s1,
const char *s2,
int i,
char *s3,
int count);
259extern int strChrCount(
const char *s1,
const char *s2);
263extern char *
strcasestr(
const char *haystack,
const char *needle);
266extern char *
strdup(
const char *s);
269extern char *
strndup(
const char *s,
size_t n);
272extern size_t strnlen(
const char *s,
size_t n);
275extern size_t strlcat(
char *dst,
const char *src,
size_t dstsize);
278extern size_t strlcpy(
char *dst,
const char *src,
size_t dstsize);
283extern int strncpyClean(
char *s1,
const char *s2,
int maxlen);
285extern char *
strTokenDup(
const char *s1,
const char *s2,
int *next);
288extern char *
strncatInt(
char *str1,
const int n,
size_t count);
289extern char *
strncatDouble(
char *str1,
const double d,
size_t count);
290extern char *
strncatIntZ(
char *str1,
const int n,
const int maxn,
size_t count);
292extern char *
strdelstr(
char *s1,
const char *s2);
302extern int atofCheck(
const char *s,
double *v);
305extern int atofList(
const char *s1,
const char *s2,
double *x,
int maxn);
314extern int fnmatch(
const char *fname,
const char *key);
315extern int fncasematch(
const char *fname,
const char *key);
322extern int tpcProcessStdOptions(
const char *s,
int *print_usage,
int *print_version,
int *verbose_level);
323extern void tpcPrintUsage(
const char *program,
char *text[], FILE *fp);
324extern int tpcHtmlUsage(
const char *program,
char *text[],
const char *path);
326extern void tpcProgramName(
const char *program,
int version,
int copyright,
char *prname,
int n);
332extern char *
unitName(
int unit_code);
348extern int unitCombination(
const int u1,
const int u2,
const int v1,
const int v2);
365extern char *
asciiFileRead(FILE *fp,
char *data,
size_t maxlen);
372extern struct tm*
gmtime_r(
const time_t* t,
struct tm* tm);
374#ifndef HAVE_LOCALTIME_R
375extern struct tm*
localtime_r(
const time_t* t,
struct tm* tm);
378extern time_t
timegm(
struct tm *tm);
380extern char*
ctime_r_int(
const time_t *t,
char *buf);
384extern int strDateValid4(
int dateint,
char *intdate,
int *year,
int *month,
int *day);
388extern int strDateRead(
const char *str,
struct tm *date);
389extern void time_to_tm(time_t totalsecs,
int offset,
struct tm *result);
390extern double tmDifference(
struct tm *tm1,
struct tm *tm0);
391extern void tmAdd(
int s,
struct tm *d);
405extern int doubleMatch(
const double v1,
const double v2,
const double lim);
406extern int doubleArrayMatch(
const double *a1,
const double *a2,
const unsigned int n,
const double lim);
407extern int doubleMatchRel(
const double v1,
const double v2,
const double lim);
409extern void doubleCopy(
double *t,
double *s,
const unsigned int n);
410extern unsigned int doubleCopyFinite(
double *t,
double *s,
const unsigned int n);
411extern unsigned int doubleNaNs(
double *a,
const unsigned int n);
412extern unsigned int doubleRange(
double *a,
const unsigned int n,
double *amin,
double *amax);
413extern double doubleSum(
double *a,
const unsigned int n);
414extern double doubleMean(
double *a,
const unsigned int n);
415extern double doubleWMean(
double *a,
double *w,
const unsigned int n);
420extern unsigned int doubleMaxIndex(
double *a,
const unsigned int n);
422extern unsigned int doubleMinIndex(
double *a,
const unsigned int n);
424extern unsigned int doubleGEIndex(
double *a,
const unsigned int n,
double lim);
425extern unsigned int doubleGTIndex(
double *a,
const unsigned int n,
double lim);
426extern double inverfc(
double x);
431extern int floatMatch(
const float v1,
const float v2,
const float lim);
432extern int floatMatchRel(
const float v1,
const float v2,
const float lim);
434extern void floatCopy(
float *t,
float *s,
const unsigned int n);
435extern unsigned int floatMaxIndex(
float *a,
const unsigned int n);
436extern float floatSum(
float *a,
const unsigned int n);
437extern float floatMean(
float *a,
const unsigned int n);
441extern unsigned int floatNonzeroes(
float *a,
const unsigned int n);
446extern int atoiCheck(
const char *s,
int *v);
447extern unsigned int factorial(
unsigned int n);
448extern unsigned long long int lfactorial(
unsigned long long int n);
471 const char *roiname,
const char *dlm,
const unsigned int si,
472 char *subpart,
const unsigned int slen
475 const char *
template,
const char *currname,
476 char *newname,
const unsigned int count
479 char *roiname,
const char *field,
480 const unsigned int in,
const unsigned int count
497extern void swap(
void *from,
void *to,
int size);
498extern void swabip(
void *buf,
int size);
499extern void swawbip(
void *buf,
int size);
500extern void swawip(
void *buf,
int size);
501extern void swap64ip(
void *buf,
unsigned long long size);
502extern void swap32ip(
void *buf,
unsigned long long size);
503extern void swap16ip(
void *buf,
unsigned long long size);
int verbose
Verbose level, used by statusPrint() etc.
FILE * fp
File pointer for writing log information during development and testing.
int forgiving
Force level, 0 for strict tests for data units etc.
char * current_func
Function where status was last time set.
int current_line
Source line nr where status was last time set.
char * last_file
Source file name where status previously set.
char * current_file
Source file name where status was last time set.
int last_line
Source line nr where status was previously set.
tpcerror error
Error code.
char * last_func
Function where status was previously set.
weights
Is data weighted, or are weight factors available with data?
@ WEIGHTING_OFF
Not weighted or weights not available (weights for all included samples are 1.0).
@ WEIGHTING_ON_FD
Weights based on decay and sample frequency or frame length (Thiele et al, 2008).
@ WEIGHTING_UNKNOWN
Not known; usually assumed that not weighted.
@ WEIGHTING_ON_GENERAL
Weighted or weights are available, but not specified.
@ WEIGHTING_ON_F
Weights based on sample frequency or frame length.
@ WEIGHTING_ON_COUNTS
Weights based on counts (Mazoyer et al, 1986).
double atofVerified(const char *s)
int strDateValid3(const char *str, char *intdate)
unsigned int doubleNonzeroes(double *a, const unsigned int n)
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
int strTokenNr(const char *s1, const char *s2)
int roinameMatch(const char *roiname, const char *test_str, TPCSTATUS *status)
void filenameRmFile(char *s)
unsigned int doubleNaNs(double *a, const unsigned int n)
int doubleGetWithUnit(const char *s, double *v, int *u)
int doubleSpanPositives(double *a, const int n)
void intlistInit(INTLIST *l)
int intlistExpandFromString(const char *s1, const char *s2, INTLIST *l, const int ifnew)
char * ctime_r_int(const time_t *t, char *buf)
Convert calendar time t into a null-terminated string of the form YYYY-MM-DD hh:mm:ss,...
char * filenameGetExtensions(const char *s)
Get all extensions of a file name.
void swap32ip(void *buf, unsigned long long size)
unsigned int doubleAbsMinIndex(double *a, const unsigned int n)
unsigned int doubleGEIndex(double *a, const unsigned int n, double lim)
void strReplaceChar(char *s, char c1, char c2)
int doubleCSpanPositives(double *a, const int n)
void statusPrint(FILE *fp, TPCSTATUS *s)
unsigned long long int lfactorial(unsigned long long int n)
float floatMean(float *a, const unsigned int n)
int unitDividendHasRadioactivity(int u)
int strDateValid(const char *str)
@ UNIT_UMOL_PER_DL_MIN
umol/(dL*min)
@ UNIT_MMOL_PER_DL_MIN
mmol/(dL*min)
@ UNIT_MIN_KBQ_PER_ML
min*kBq/mL
@ UNIT_MMOL_PER_G_MIN
mmol/(g*min)
@ UNIT_MMOL_PER_100G_MIN
mmol/(100g*min)
@ UNIT_ML_PER_ML_MIN
mL/(mL*min)
@ UNIT_UMOL_PER_ML_MIN
umol/(mL*min)
@ UNIT_MIN_BQ_PER_ML
min*Bq/mL
@ UNIT_MG_PER_DL_MIN
mg/(dL*min)
@ UNIT_PID_PER_L
Percent of injected dose / L.
@ UNIT_UNKNOWN
Unknown unit.
@ UNIT_ML_PER_100G_MIN
mL/(100g*min)
@ UNIT_KCPM
kilocounts/min
@ UNIT_MMOL_PER_ML
mmol/mL
@ UNIT_PID_PER_G
Percent of injected dose / g.
@ UNIT_NMOL_PER_ML
nmol/mL
@ UNIT_SEC_BQ_PER_ML
s*Bq/mL
@ UNIT_ML_PER_G_MIN
mL/(g*min)
@ UNIT_ML_PER_DL_MIN
mL/(dL*min)
@ UNIT_PID_PER_ML
Percent of injected dose / mL.
@ UNIT_MMOL_PER_ML_MIN
mmol/(mL*min)
@ UNIT_MBQ_PER_NMOL
MBq/nmol (specific activity)
@ UNIT_PID
Percent of injected dose.
@ UNIT_UMOL_PER_ML
umol/mL
@ UNIT_PID_PER_KG
Percent of injected dose / kg.
@ UNIT_GBQ_PER_NMOL
GBq/nmol (specific activity)
@ UNIT_ML_PER_ML_SEC
mL/(mL*sec)
@ UNIT_UMOL_PER_G_MIN
umol/(g*min)
@ UNIT_SEC_KBQ_PER_ML
s*kBq/mL
@ UNIT_PMOL_PER_ML
pmol/mL
@ UNIT_HU
Hounsfield Unit.
@ UNIT_UMOL_PER_100G_MIN
umol/(100g*min)
@ UNIT_PERCENTAGE
Percentage (%)
@ UNIT_MG_PER_100G_MIN
mg/(100g*min)
char * filenameGetExtension(const char *s)
Get the last extension of a file name.
void intlistFree(INTLIST *l)
void filenameRmPath(char *s)
int strDateTimeRead(const char *str, struct tm *date)
int strDateRead(const char *str, struct tm *date)
int doubleMatch(const double v1, const double v2, const double lim)
char * roinameSubpart(const char *roiname, const char *dlm, const unsigned int si, char *subpart, const unsigned int slen)
tpcerror
Error codes. Error code tpcerror, same as error message position in the table (table can not be acces...
@ TPCERROR_NO_REFERENCE
Reference not found.
@ TPCERROR_INVALID_SEPARATOR
Invalid field delimiter.
@ TPCERROR_DUPLICATE_DATA
File contains duplicate data.
@ TPCERROR_INVALID_XRANGE
Invalid sample time range.
@ TPCERROR_INVALID_VALUE
Invalid value.
@ TPCERROR_NO_FILE
File does not exist.
@ TPCERROR_NO_SOLUTION
No solution.
@ TPCERROR_INVALID_PARNR
Invalid number of parameters.
@ TPCERROR_NO_VALUE
Value not found.
@ TPCERROR_OVERLAPPING_DATA
Overlapping data.
@ TPCERROR_NO_DATETIME
File contains no date or time.
@ TPCERROR_BAD_FIT
Fitting not successful.
@ TPCERROR_UNKNOWN_UNIT
Unknown data unit.
@ TPCERROR_FAIL
General error.
@ TPCERROR_INVALID_FORMAT
Invalid file format.
@ TPCERROR_INVALID_HEADER
Invalid header contents.
@ TPCERROR_TOO_BIG
File is too big.
@ TPCERROR_CANNOT_OPEN
Cannot open file.
@ TPCERROR_OUT_OF_MEMORY
Cannot allocate memory.
@ TPCERROR_INVALID_X
Invalid sample time.
@ TPCERROR_NO_KEY
Key not found.
@ TPCERROR_NO_X
No sample times.
@ TPCERROR_UNSUPPORTED
Unsupported file type.
@ TPCERROR_FILE_EXISTS
File exists.
@ TPCERROR_LAST
marking the end of list
@ TPCERROR_NO_WEIGHTS
File contains no weights.
@ TPCERROR_INCOMPATIBLE_UNIT
Incompatible units.
@ TPCERROR_LARGE_GAP
Large gap in data.
@ TPCERROR_INVALID_FILENAME
Invalid file name.
@ TPCERROR_UNKNOWN_ISOTOPE
Unknown isotope.
@ TPCERROR_NO_DATA
File contains no data.
@ TPCERROR_MISSING_HEADER
Missing header.
@ TPCERROR_CANNOT_DELETE
Cannot delete.
@ TPCERROR_TOO_FEW
File contains too few samples.
@ TPCERROR_CANNOT_READ
Cannot read file.
@ TPCERROR_MISSING_DATA
File contains missing values.
@ TPCERROR_INCOMPATIBLE_DATA
Incompatible data.
@ TPCERROR_CANNOT_WRITE
Cannot write file.
int unitIdentify(const char *s)
int doubleMatchRel(const double v1, const double v2, const double lim)
char * roinameAddField(char *roiname, const char *field, const unsigned int in, const unsigned int count)
int unitIdentifyFilename(const char *s)
unsigned int floatNonzeroes(float *a, const unsigned int n)
time_t timegm(struct tm *tm)
Inverse of gmtime, converting struct tm to time_t.
double doubleWMean(double *a, double *w, const unsigned int n)
unsigned int doubleMaxIndex(double *a, const unsigned int n)
void filenameRmExtensions(char *s)
void strCleanForXML(char *s)
char * strstrNoQuotation(const char *haystack, const char *needle)
int unitIsRadioactivity(int u)
int strHaveDecimalComma(const char *s)
char * strdup(const char *s)
char * strncatIntZ(char *str1, const int n, const int maxn, size_t count)
void intlistSort(INTLIST *l)
int strCleanSpaces(char *s)
int studynrFromFilename(const char *fname, char *studynr, int force)
double strDateTimeDifference(const char *dt1, const char *dt0)
char * asciiFileRead(FILE *fp, char *data, size_t maxlen)
double unitConversionFactor(const int u1, const int u2)
char * unitName(int unit_code)
int atoiCheck(const char *s, int *v)
char * strncatDouble(char *str1, const double d, size_t count)
void tmAdd(int s, struct tm *d)
int roinameExists(char *roiname)
Verifies whether TAC name exists or not.
int strTimeValid(const char *str)
void strCleanPars(char *s)
char * strEncodeForXML(const char *s)
char * strTrimLeft(char *s, const size_t t)
void floatCopy(float *t, float *s, const unsigned int n)
void statusInit(TPCSTATUS *s)
void time_to_tm(time_t totalsecs, int offset, struct tm *result)
size_t strnlen(const char *s, size_t n)
int unitCombination(const int u1, const int u2, const int v1, const int v2)
int strncpyCleanSpaces(char *s1, const char *s2, int maxlen)
int doubleArrayMatch(const double *a1, const double *a2, const unsigned int n, const double lim)
void swap64ip(void *buf, unsigned long long size)
int unitIsCombinatorial(int u)
float floatSum(float *a, const unsigned int n)
char * strncatInt(char *str1, const int n, size_t count)
int strTokenNCpy(const char *s1, const char *s2, int i, char *s3, int count)
size_t strlcpy(char *dst, const char *src, size_t dstsize)
void tpcProgramName(const char *program, int version, int copyright, char *prname, int n)
int tpcYesNo(const char *s)
int floatGetWithUnit(const char *s, float *v, int *u)
char * errorMsg(tpcerror e)
int strncpyClean(char *s1, const char *s2, int maxlen)
int asciiCommentLine(const char *line, int *cont)
unsigned int doubleCopyFinite(double *t, double *s, const unsigned int n)
int strIsSpaceOnly(char *s)
int strChrCount(const char *s1, const char *s2)
char * strTokenDup(const char *s1, const char *s2, int *next)
int strDateValid2(const char *str, char *intdate)
char * strdelstr(char *s1, const char *s2)
int unitIsDistance(int u)
int intlistAddFromString(const char *s1, const char *s2, INTLIST *l, const int ifnew)
unsigned int doubleRange(double *a, const unsigned int n, double *amin, double *amax)
int floatMatch(const float v1, const float v2, const float lim)
int intlistAdd(INTLIST *l, const int v, const int ifnew)
int floatCSpanPositives(float *a, const int n)
int strUppercaseCount(const char *s)
int floatMatchRel(const float v1, const float v2, const float lim)
unsigned int doubleAbsMaxIndex(double *a, const unsigned int n)
void swabip(void *buf, int size)
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
int studynrStandardize(char *s)
int filenameRmExtension(char *s)
struct tm * gmtime_r(const time_t *t, struct tm *tm)
Convert time_t to GMT struct tm.
unsigned int doubleGTIndex(double *a, const unsigned int n, double lim)
int unitDividerHasVolume(int u)
int fnmatch(const char *fname, const char *key)
void swawip(void *buf, int size)
void swap16ip(void *buf, unsigned long long size)
int strDateTimeValid(const char *str, char *intdate)
char * strcasestr(const char *haystack, const char *needle)
int strDateValid4(int dateint, char *intdate, int *year, int *month, int *day)
int tpcHtmlUsage(const char *program, char *text[], const char *path)
double doubleSum(double *a, const unsigned int n)
int studynrVerify(const char *s, int zero_ok)
int atofCheck(const char *s, double *v)
unsigned int floatMaxIndex(float *a, const unsigned int n)
void doubleCopy(double *t, double *s, const unsigned int n)
tactype
TAC content types.
@ TACTYPE_REF
Reference region TAC.
@ TACTYPE_PARENT
Parent tracer in plasma.
@ TACTYPE_UNKNOWN
Content type not known.
@ TACTYPE_METABOLITE
Metabolite in plasma.
@ TACTYPE_PLASMA
Plasma TAC.
@ TACTYPE_PIXEL
Image pixel TAC.
@ TACTYPE_VOI
Image volume-of-interest TAC.
@ TACTYPE_BLOOD
Blood TAC.
size_t strlcat(char *dst, const char *src, size_t dstsize)
int atofList(const char *s1, const char *s2, double *x, int maxn)
int unitDividerMassVolumeConversion(int u)
void swap(void *from, void *to, int size)
double doubleMean(double *a, const unsigned int n)
unsigned int doubleMinIndex(double *a, const unsigned int n)
void tpcPrintBuild(const char *program, FILE *fp)
char * strndup(const char *s, size_t n)
int strDateTimeAdd(int s, char *dt)
int unitMultiply(int ua, int ub)
struct tm * localtime_r(const time_t *t, struct tm *tm)
Convert time_t to local time in struct tm.
int fncasematch(const char *fname, const char *key)
size_t asciiFileSize(FILE *fp, int *nonprintable)
double tmDifference(struct tm *tm1, struct tm *tm0)
unsigned int factorial(unsigned int n)
char * roinameEditByTemplate(const char *template, const char *currname, char *newname, const unsigned int count)
void tpcPrintUsage(const char *program, char *text[], FILE *fp)
int strHaveDecimalSeparator(const char *s)
int unitDividerHasMass(int u)
int strIsValidNumber(const char *s)
int floatSpanPositives(float *a, const int n)
void swawbip(void *buf, int size)
void statusFree(TPCSTATUS *s)