TPCCLIB
|
Header file for library libtpcextensions. More...
#include "tpcclibConfig.h"
#include <errno.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <time.h>
Go to the source code of this file.
Data Structures | |
struct | TPCSTATUS |
struct | INTLIST |
Macros | |
#define | MAX_UNITS_LEN 32 |
Define max units string length. | |
#define | MAX_TACNAME_LEN 31 |
Max length of TAC ID name (not including trailing zero) | |
#define | MAX_PARNAME_LEN MAX_TACNAME_LEN |
Max string length for PAR name. | |
#define | MAX_STUDYNR_LEN 255 |
Define max study number length. | |
Functions | |
int | strTokenNr (const char *s1, const char *s2) |
int | strTokenNCpy (const char *s1, const char *s2, int i, char *s3, int count) |
int | strChrCount (const char *s1, const char *s2) |
int | strUppercaseCount (const char *s) |
void | strReplaceChar (char *s, char c1, char c2) |
char * | strcasestr (const char *haystack, const char *needle) |
char * | strdup (const char *s) |
char * | strndup (const char *s, size_t n) |
size_t | strnlen (const char *s, size_t n) |
size_t | strlcat (char *dst, const char *src, size_t dstsize) |
size_t | strlcpy (char *dst, const char *src, size_t dstsize) |
char * | strstrNoQuotation (const char *haystack, const char *needle) |
int | strncpyCleanSpaces (char *s1, const char *s2, int maxlen) |
int | strCleanSpaces (char *s) |
int | strncpyClean (char *s1, const char *s2, int maxlen) |
int | strClean (char *s) |
char * | strTokenDup (const char *s1, const char *s2, int *next) |
int | strInPars (char *s) |
void | strCleanPars (char *s) |
char * | strncatInt (char *str1, const int n, size_t count) |
char * | strncatDouble (char *str1, const double d, size_t count) |
char * | strncatIntZ (char *str1, const int n, const int maxn, size_t count) |
int | strIsSpaceOnly (char *s) |
char * | strdelstr (char *s1, const char *s2) |
char * | strTrimLeft (char *s, const size_t t) |
char * | strEncodeForXML (const char *s) |
void | strCleanForXML (char *s) |
int | strIsValidNumber (const char *s) |
double | atofVerified (const char *s) |
int | atofCheck (const char *s, double *v) |
int | strHaveDecimalComma (const char *s) |
int | strHaveDecimalSeparator (const char *s) |
int | atofList (const char *s1, const char *s2, double *x, int maxn) |
void | filenameRmPath (char *s) |
void | filenameRmFile (char *s) |
int | filenameRmExtension (char *s) |
void | filenameRmExtensions (char *s) |
int | fnmatch (const char *fname, const char *key) |
int | fncasematch (const char *fname, const char *key) |
char * | filenameGetExtension (const char *s) |
Get the last extension of a file name. | |
char * | filenameGetExtensions (const char *s) |
Get all extensions of a file name. | |
int | tpcProcessStdOptions (const char *s, int *print_usage, int *print_version, int *verbose_level) |
void | tpcPrintUsage (const char *program, char *text[], FILE *fp) |
int | tpcHtmlUsage (const char *program, char *text[], const char *path) |
void | tpcPrintBuild (const char *program, FILE *fp) |
void | tpcProgramName (const char *program, int version, int copyright, char *prname, int n) |
int | tpcYesNo (const char *s) |
char * | unitName (int unit_code) |
int | unitIdentify (const char *s) |
int | unitIdentifyFilename (const char *s) |
int | unitIsDistance (int u) |
int | unitIsTime (int u) |
int | unitIsVolume (int u) |
int | unitIsMass (int u) |
int | unitIsMole (int u) |
int | unitIsRadioactivity (int u) |
int | unitIsRAConc (int u) |
int | unitIsCombinatorial (int u) |
double | unitConversionFactor (const int u1, const int u2) |
int | unitInverse (int u) |
int | unitDividerHasVolume (int u) |
int | unitDividerHasMass (int u) |
int | unitDividendHasRadioactivity (int u) |
int | unitCombination (const int u1, const int u2, const int v1, const int v2) |
int | unitDividerMassVolumeConversion (int u) |
int | unitMultiply (int ua, int ub) |
void | statusPrint (FILE *fp, TPCSTATUS *s) |
void | statusInit (TPCSTATUS *s) |
void | statusFree (TPCSTATUS *s) |
void | statusSet (TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error) |
char * | errorMsg (tpcerror e) |
size_t | asciiFileSize (FILE *fp, int *nonprintable) |
char * | asciiFileRead (FILE *fp, char *data, size_t maxlen) |
int | asciiCommentLine (const char *line, int *cont) |
struct tm * | gmtime_r (const time_t *t, struct tm *tm) |
Convert time_t to GMT struct tm. | |
struct tm * | localtime_r (const time_t *t, struct tm *tm) |
Convert time_t to local time in struct tm. | |
time_t | timegm (struct tm *tm) |
Inverse of gmtime, converting struct tm to time_t. | |
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, with length of 19 characters and the null. | |
int | strDateValid (const char *str) |
int | strDateValid2 (const char *str, char *intdate) |
int | strDateValid3 (const char *str, char *intdate) |
int | strDateValid4 (int dateint, char *intdate, int *year, int *month, int *day) |
int | strTimeValid (const char *str) |
int | strDateTimeValid (const char *str, char *intdate) |
int | strDateTimeRead (const char *str, struct tm *date) |
int | strDateRead (const char *str, struct tm *date) |
void | time_to_tm (time_t totalsecs, int offset, struct tm *result) |
double | tmDifference (struct tm *tm1, struct tm *tm0) |
void | tmAdd (int s, struct tm *d) |
double | strDateTimeDifference (const char *dt1, const char *dt0) |
int | strDateTimeAdd (int s, char *dt) |
int | studynrVerify (const char *s, int zero_ok) |
int | studynrStandardize (char *s) |
int | studynrFromFilename (const char *fname, char *studynr, int force) |
int | doubleMatch (const double v1, const double v2, const double lim) |
int | doubleArrayMatch (const double *a1, const double *a2, const unsigned int n, const double lim) |
int | doubleMatchRel (const double v1, const double v2, const double lim) |
double | doubleMachEps () |
void | doubleCopy (double *t, double *s, const unsigned int n) |
unsigned int | doubleCopyFinite (double *t, double *s, const unsigned int n) |
unsigned int | doubleNaNs (double *a, const unsigned int n) |
unsigned int | doubleRange (double *a, const unsigned int n, double *amin, double *amax) |
double | doubleSum (double *a, const unsigned int n) |
double | doubleMean (double *a, const unsigned int n) |
double | doubleWMean (double *a, double *w, const unsigned int n) |
int | doubleGetWithUnit (const char *s, double *v, int *u) |
int | doubleSpanPositives (double *a, const int n) |
int | doubleCSpanPositives (double *a, const int n) |
unsigned int | doubleNonzeroes (double *a, const unsigned int n) |
unsigned int | doubleMaxIndex (double *a, const unsigned int n) |
unsigned int | doubleAbsMaxIndex (double *a, const unsigned int n) |
unsigned int | doubleMinIndex (double *a, const unsigned int n) |
unsigned int | doubleAbsMinIndex (double *a, const unsigned int n) |
unsigned int | doubleGEIndex (double *a, const unsigned int n, double lim) |
unsigned int | doubleGTIndex (double *a, const unsigned int n, double lim) |
double | inverfc (double x) |
int | floatMatch (const float v1, const float v2, const float lim) |
int | floatMatchRel (const float v1, const float v2, const float lim) |
float | floatMachEps () |
void | floatCopy (float *t, float *s, const unsigned int n) |
unsigned int | floatMaxIndex (float *a, const unsigned int n) |
float | floatSum (float *a, const unsigned int n) |
float | floatMean (float *a, const unsigned int n) |
int | floatGetWithUnit (const char *s, float *v, int *u) |
int | floatSpanPositives (float *a, const int n) |
int | floatCSpanPositives (float *a, const int n) |
unsigned int | floatNonzeroes (float *a, const unsigned int n) |
int | atoiCheck (const char *s, int *v) |
unsigned int | factorial (unsigned int n) |
unsigned long long int | lfactorial (unsigned long long int n) |
void | intlistInit (INTLIST *l) |
void | intlistFree (INTLIST *l) |
int | intlistAdd (INTLIST *l, const int v, const int ifnew) |
void | intlistSort (INTLIST *l) |
int | intlistAddFromString (const char *s1, const char *s2, INTLIST *l, const int ifnew) |
int | intlistExpandFromString (const char *s1, const char *s2, INTLIST *l, const int ifnew) |
char * | roinameSubpart (const char *roiname, const char *dlm, const unsigned int si, char *subpart, const unsigned int slen) |
char * | roinameEditByTemplate (const char *template, const char *currname, char *newname, const unsigned int count) |
char * | roinameAddField (char *roiname, const char *field, const unsigned int in, const unsigned int count) |
int | roinameExists (char *roiname) |
Verifies whether TAC name exists or not. | |
int | roinameMatch (const char *roiname, const char *test_str, TPCSTATUS *status) |
int | endianness () |
int | endianLittle () |
void | swap (void *from, void *to, int size) |
void | swabip (void *buf, int size) |
void | swawbip (void *buf, int size) |
void | swawip (void *buf, int size) |
void | swap64ip (void *buf, unsigned long long size) |
void | swap32ip (void *buf, unsigned long long size) |
void | swap16ip (void *buf, unsigned long long size) |
Header file for library libtpcextensions.
Definition in file tpcextensions.h.
#define MAX_PARNAME_LEN MAX_TACNAME_LEN |
Max string length for PAR name.
Max length of parameter names and units
Definition at line 39 of file tpcextensions.h.
Referenced by parEnsureNames(), parFromIFT(), parReadCSV(), parReadLimits(), parReadRES(), parWriteCSV(), and parWriteLimits().
#define MAX_STUDYNR_LEN 255 |
Define max study number length.
Max string length for PET study number
Definition at line 46 of file tpcextensions.h.
Referenced by imgCopyHeader(), imgInit(), imgReadDICOM(), tacGetHeaderStudynr(), tacRead(), tacReadSIF(), and tacWriteSIF().
#define MAX_TACNAME_LEN 31 |
Max length of TAC ID name (not including trailing zero)
Max string length for TAC name
Definition at line 35 of file tpcextensions.h.
Referenced by parEnsureNames(), parFromIFT(), parReadCSV(), parReadFIT(), parReadRES(), tacEnsureNames(), tacRead4DM(), tacReadCarimasTxt(), tacReadCSV(), tacReadDFT(), tacReadInveonCSV(), tacReadMat(), tacReadPMOD(), tacReadQView(), and tacReadSimple().
#define MAX_UNITS_LEN 32 |
Define max units string length.
Max string length for PET units
Definition at line 28 of file tpcextensions.h.
Referenced by parWriteCSV().
anonymous enum |
Definition at line 488 of file tpcextensions.h.
enum tactype |
TAC content types.
Enumerator | |
---|---|
TACTYPE_UNKNOWN | Content type not known. |
TACTYPE_PLASMA | Plasma TAC. |
TACTYPE_BLOOD | Blood TAC. |
TACTYPE_PARENT | Parent tracer in plasma. |
TACTYPE_METABOLITE | Metabolite in plasma. |
TACTYPE_VOI | Image volume-of-interest TAC. |
TACTYPE_REF | Reference region TAC. |
TACTYPE_PIXEL | Image pixel TAC. |
Definition at line 66 of file tpcextensions.h.
enum tpcerror |
Error codes. Error code tpcerror, same as error message position in the table (table can not be accessed directly outside the c file).
Definition at line 189 of file tpcextensions.h.
enum unit |
unit code, same as unit position in the table (table can not be accessed directly outside the c file).
Definition at line 84 of file tpcextensions.h.
enum weights |
Is data weighted, or are weight factors available with data?
Definition at line 52 of file tpcextensions.h.
|
extern |
Check if ASCII text line starts with comment character '#'.
Comment character is searched from the first non-space character (space characters here include spaces and tabs).
line | Pointer to string containing one line of ASCII text file. |
cont | Optional pointer which is set to the index of line where the first non-space character after the comment character starts. If line does not start with comment character, then this will point to the first non-space character of the line. Enter NULL if not needed. |
Definition at line 149 of file readasciifile.c.
Referenced by iftPutFromString(), iftPutFromStringWithSpaceSeparator(), and tacFormatDetermine().
|
extern |
Read at most maxlen-1 characters from given file pointer to ASCII text file.
fp | File pointer; rewind() is NOT called here to allow reading data in chunks. |
data | Pointer to character array in which the data is written; NULL, if memory is to allocated here (in that case remember to free it after use). Terminal zero is added. |
maxlen | Nr of characters to read, and the size of data array (including terminal zero). |
Definition at line 117 of file readasciifile.c.
Referenced by csvRead(), iftRead(), and tacFormatDetermine().
|
extern |
Get the size of ASCII text file, or size of initial ASCII part of file containing binary data after the text part (in certain image formats).
One NUL character is not counted as binary data, but two already is; this, because equipment failures sometimes lead to data ending with NUL.
fp | File pointer; rewind() is called before returning. |
nonprintable | Value will be set to 1 if reading was stopped at a non-printable character meaning that file may contain a binary part, or to 0 if file contains only printable characters and size of all contents was counted. Enter NULL, if not needed. |
Definition at line 26 of file readasciifile.c.
Referenced by csvRead(), iftRead(), tacFormatDetermine(), and tacRead().
|
extern |
Verifies that argument string at least seems like a valid number.
Both decimal point and comma are accepted. Optional result double value is set to NaN if string was not valid value.
s | String which is converted to a double; string must not contain any space characters. |
v | Pointer to the double float; enter NULL, if not needed. |
Definition at line 94 of file decpoint.c.
Referenced by doubleGetWithUnit(), floatGetWithUnit(), iftGetDoubleValue(), tacReadCarimasTxt(), and tacReadInveonCSV().
|
extern |
Read a list of double values from given string with given delimiters.
s1 | Pointer to string from which double values are read. |
s2 | String containing character delimiters |
x | Pointer to a pre-allocated array of doubles. |
maxn | Size of double list; obligatory. If string contains more values, only maxn values will be read. |
Definition at line 150 of file decpoint.c.
|
extern |
Version of atof() which verifies that argument string at least seems like a valid number.
Both decimal point and comma are accepted. Result value is set to NaN if string was not valid value.
s | String which is converted to a double; string must not contain any space characters. |
Definition at line 75 of file decpoint.c.
Referenced by atofList(), dcmImgIsotope(), iftGetDoubleWithUnit(), parReadCSV(), parReadFIT(), parReadRES(), tacRead4DM(), tacReadCSV(), tacReadDFT(), tacReadHRPLUSHC(), tacReadHRRTHC(), tacReadMat(), tacReadPMOD(), tacReadQView(), tacReadSIF(), and tacReadSimple().
|
extern |
Verifies that argument string at least seems like a valid integer. '\0' must follow the integer part in the string. Optional result integer value is set to 0 if string was not valid value.
s | String which is converted to an integer; string must not contain any space characters. |
v | Pointer to the integer; enter NULL, if not needed. |
Definition at line 25 of file intutil.c.
Referenced by intlistAddFromString(), and tacReadQView().
|
extern |
Convert calendar time t into a null-terminated string of the form YYYY-MM-DD hh:mm:ss, with length of 19 characters and the null.
This is a replacement of the thread-safe ctime_r function which converts to date and time in English format.
t | Pointer to calendar time ; do not give pointer to int here, like &e7mhdr.scan_start_time |
buf | Pointer to string where the date and time will be written. It must be pre-allocated for at least 20 characters. |
Definition at line 119 of file datetime.c.
Referenced by parWriteRES().
|
extern |
Find the maximum absolute value in given double array.
a | Pointer to double array. |
n | Length of array. |
Definition at line 377 of file doubleutil.c.
|
extern |
Find the minimum absolute value in given double array.
a | Pointer to double array. |
n | Length of array. |
Definition at line 416 of file doubleutil.c.
Referenced by spectralBFExtract().
|
extern |
Verifies that given two double arrays have the same values inside given limits. Values are considered to match also if both are NaNs.
a1 | First array. |
a2 | Second array. |
n | Length of arrays. |
lim | Limit for absolute difference (if <0 then test will fail every time). |
Definition at line 51 of file doubleutil.c.
|
extern |
Copy double values from the 2nd array to the first.
t | Target array. |
s | Source array. |
n | Length of arrays. |
Definition at line 117 of file doubleutil.c.
Referenced by nloptIATGO(), nloptMPSO(), and nloptSimplexARRS().
|
extern |
Copy finite double values from the 2nd array to the first.
t | Target array. |
s | Source array. |
n | Length of arrays. |
Definition at line 136 of file doubleutil.c.
|
extern |
Returns the length of array consisting of non-positive (<=0 and NaN) values.
a | Pointer to the array. |
n | Length of the array. |
Definition at line 320 of file doubleutil.c.
Referenced by spectralBFExtract(), and spectralBFNr().
|
extern |
Get the index of first array value greater or equal than given limit.
a | Pointer to an array of values. |
n | The number of samples (length of a[]). |
lim | The limit value. |
Definition at line 435 of file doubleutil.c.
|
extern |
Reads numerical value and its unit from argument string.
Both decimal point and comma are accepted. Optional result double value is set to NaN if string was not valid value. Optional unit is set to UNIT_UNKNOWN, if not valid or not found.
s | String from where double and unit is read; string must not contain any extra space characters. |
v | Pointer to the double float; enter NULL, if not needed. |
u | Pointer to int for unit code; enter NULL, if not needed. |
Definition at line 272 of file doubleutil.c.
Referenced by iftCheckKeyValue(), and iftCheckKeyValues().
|
extern |
Get the index of first array value greater than given limit.
a | Pointer to an array of values. |
n | The number of samples (length of a[]). |
lim | The limit value. |
Definition at line 452 of file doubleutil.c.
|
extern |
Estimates the machine epsilon, the upper bound on the relative error due to rounding in floating point arithmetic, within one order of magnitude of the true machine epsilon.
Standard C library should also have DBL_EPSILON in float.h.
Definition at line 105 of file doubleutil.c.
Referenced by householder_transform(), nlopt1D(), nloptFixedNr(), nloptLimitFixedNr(), and nloptPowellBrent().
|
extern |
Verifies that given two doubles have the same value inside given limits. Values are considered to match also if both are NaNs.
v1 | First value. |
v2 | Second value. |
lim | Limit for absolute difference (if <0 then test will fail every time). |
Definition at line 27 of file doubleutil.c.
Referenced by doubleArrayMatch(), parCompareParameters(), parCompareWSS(), parIsFitRange(), tacCheckX1X2X(), tacCompareConc(), tacCompareTimes(), tacCompareWeights(), and tacReadQView().
|
extern |
Verifies that given two doubles have the same value inside given relative limit |2*(v1-v2)/(v1+v2)|.
Values are considered to match also if both are NaNs, but not if mean is zero (unless both are exactly zero).
v1 | First value. |
v2 | Second value. |
lim | Limit for relative difference (if <0 then test will fail every time). |
Definition at line 77 of file doubleutil.c.
Referenced by parCompareParameters(), parCompareWSS(), tacCompareConc(), tacCompareTimes(), and tacCompareWeights().
|
extern |
Find the maximum value in given double array.
a | Pointer to double array. |
n | Length of array. |
Definition at line 357 of file doubleutil.c.
|
extern |
Calculate the mean of values in given double array.
a | Pointer to double array. |
n | Length of array. |
Definition at line 224 of file doubleutil.c.
|
extern |
Find the minimum value in given double array.
a | Pointer to double array. |
n | Length of array. |
Definition at line 396 of file doubleutil.c.
|
extern |
Check the number of NaNs in a double array.
a | Pointer to double array. |
n | Length of array. |
Definition at line 156 of file doubleutil.c.
|
extern |
Find the number of non-zero values in given double array. Negative values are counted, but NaNs are not.
a | Pointer to double array. |
n | Length of array. |
Definition at line 339 of file doubleutil.c.
|
extern |
Get the range of finite values in a double array.
a | Pointer to double array. |
n | Length of array. |
amin | Pointer to the double float where minimum value is stored; enter NULL, if not needed. |
amax | Pointer to the double float where maximum value is stored; enter NULL, if not needed. |
Definition at line 174 of file doubleutil.c.
|
extern |
Returns the length of array consisting of only positive (>0 and not NaN) values.
a | Pointer to the array. |
n | Length of the array. |
Definition at line 302 of file doubleutil.c.
Referenced by spectralBFExtract(), and spectralBFNr().
|
extern |
Calculate the sum of values in given double array.
a | Pointer to double array. |
n | Length of array. |
Definition at line 206 of file doubleutil.c.
Referenced by spectralBFExtract().
|
extern |
Calculate the weighted mean of values in given double array.
a | Pointer to double array to calculated weighted mean from. |
w | Pointer to double array containing the weights. Negative or NaN weight is interpreted as zero weight. |
n | Length of arrays. |
Definition at line 244 of file doubleutil.c.
Referenced by spectralBFExtract().
|
extern |
Check whether current platform uses little endian byte order.
Definition at line 53 of file endian.c.
Referenced by anaReadHeader(), dcmFileWrite(), dcmitemGetInt(), dcmitemGetReal(), dcmReadFileTag(), dcmReadFileVL(), dcmReadFileVRVL(), dcmValueString(), dcmWriteFileTag(), dcmWriteFileVRVL(), ecatMListRead(), ecatReadMainheader(), ecatWriteMainheader(), imgReadNifti(), imgSetNiftiHeader(), niftiReadHeader(), and niftiWriteHeader().
|
extern |
Detect endianness at run-time. From https://sourceforge.net/p/predef/wiki/Endianness/
Definition at line 26 of file endian.c.
Referenced by endianLittle().
|
extern |
Return pointer to error message specified with the error code.
e | Error code |
Definition at line 68 of file statusmsg.c.
Referenced by imgRead(), and nloptIATGO().
|
extern |
Calculate factorial of given number.
n | Integer n, from which the factorial is calculated. |
Definition at line 46 of file intutil.c.
Referenced by factorial().
|
extern |
Get the last extension of a file name.
Extension(s) in pathname are not searched for. Note that pointer points to the original string.
s | Pointer to string; string is not edited here. |
Definition at line 178 of file filename.c.
Referenced by abssIdFromFName(), imgWriteNifti(), micropetExists(), niftiBasename(), and tacRead().
|
extern |
Get all extensions of a file name.
Extension(s) in pathname are not searched for. Note that pointer points to the original string.
s | Pointer to string; string is not edited here. |
Definition at line 203 of file filename.c.
Referenced by imgFormatFromFName(), and parFormatFromExtension().
|
extern |
Remove the last extension from file name.
s | Pointer to string. |
Definition at line 71 of file filename.c.
Referenced by filenameRmExtensions(), micropetExists(), tpcHtmlUsage(), tpcPrintBuild(), tpcPrintUsage(), and tpcProgramName().
|
extern |
Remove all extensions from file name.
s | Pointer to string. |
Definition at line 89 of file filename.c.
Referenced by studynrFromFilename().
|
extern |
Remove file name from file name string including path, leaving only path without trailing '/'. If there is no path, then result is ".". For root path the result string is empty. See also POSIX function dirname() in libgen.h.
s | Pointer to string. |
Definition at line 44 of file filename.c.
Referenced by dcmFileList(), and imgWriteNifti().
|
extern |
Remove path from file name. See also POSIX function basename() in libgen.h.
s | Pointer to string. |
Definition at line 20 of file filename.c.
Referenced by imgWriteNifti(), niftiCreateFNames(), studynrFromFilename(), tpcHtmlUsage(), tpcPrintBuild(), tpcPrintUsage(), and tpcProgramName().
|
extern |
Copy double values from the 2nd array to the first.
t | Target array. |
s | Source array. |
n | Length of arrays. |
Definition at line 94 of file floatutil.c.
|
extern |
Returns the length of array consisting of non-positive (<=0 and NaN) values.
a | Pointer to the array. |
n | Length of the array. |
Definition at line 228 of file floatutil.c.
|
extern |
Reads numerical value and its unit from argument string.
Both decimal point and comma are accepted. Optional result float value is set to NaN if string was not valid value. Optional unit is set to UNIT_UNKNOWN, if not valid or not found.
s | String from where float and unit is read; string must not contain any extra space characters. |
v | Pointer to the float; enter NULL, if not needed. |
u | Pointer to int for unit code; enter NULL, if not needed. |
Definition at line 174 of file floatutil.c.
|
extern |
Estimates the machine epsilon, the upper bound on the relative error due to rounding in floating point arithmetic, within one order of magnitude of the true machine epsilon.
Standard C library should also have FLT_EPSILON and DBL_EPSILON in float.h.
Definition at line 82 of file floatutil.c.
|
extern |
Verifies that given two floats have the same value inside given limits. Values are considered to match also if both are NaNs.
v1 | First value |
v2 | Second value |
lim | Limit for absolute difference (if <0 then test will fail every time) |
Definition at line 27 of file floatutil.c.
Referenced by imgCompareConc(), imgCompareTimes(), and imgReadDICOM().
|
extern |
Verifies that given two floats have the same value inside given relative limit |2*(v1-v2)/(v1+v2)|.
Values are considered to match also if both are NaNs, but not if mean is zero (unless both are exactly zero).
v1 | First value. |
v2 | Second value. |
lim | Limit for relative difference (if <0 then test will fail every time). |
Definition at line 54 of file floatutil.c.
Referenced by imgCompareConc(), and imgCompareTimes().
|
extern |
Find the maximum value in given float array.
a | Pointer to float array. |
n | Length of array. |
Definition at line 113 of file floatutil.c.
|
extern |
Calculate the mean of values in given float array.
a | Pointer to float array. |
n | Length of array. |
Definition at line 150 of file floatutil.c.
|
extern |
Find the number of non-zero values in given float array. Negative values are counted, but NaNs are not.
a | Pointer to float array. |
n | Length of array. |
Definition at line 247 of file floatutil.c.
Referenced by imgContents().
|
extern |
Returns the length of array consisting of only positive (>0 and not NaN) values.
a | Pointer to the array. |
n | Length of the array. |
Definition at line 210 of file floatutil.c.
|
extern |
Calculate the sum of values in given float array.
a | Pointer to float array. |
n | Length of array. |
Definition at line 132 of file floatutil.c.
|
extern |
Case-independent check whether string fname matches string key, which may contain wild-cards ? and *.
fname | file name that is evaluated. |
key | key string which may contain wild-cards '?' and '*'. |
Definition at line 139 of file filename.c.
Referenced by roinameMatch().
|
extern |
Check if string fname matches string key, which may contain wild cards * ? and *.
fname | file name that is evaluated. |
key | key string which may contain wild cards '?' and '*'. |
Definition at line 104 of file filename.c.
Referenced by fncasematch(), and fnmatch().
|
extern |
Convert time_t to GMT struct tm.
This version of gmtime_r function is here for systems (at least Windows) where it is not defined. Uses gmtime, which is threadsafe in Windows.
t | Pointer to time_t; do not give pointer to int here, like &e7mhdr.scan_start_time |
tm | Pointer to struct tm, to be filled here. |
Definition at line 31 of file datetime.c.
Referenced by ctime_r_int(), tacReadGEMS(), and timegm().
|
extern |
Add one integer to the integer array in INTLIST structure.
l | Pointer to initiated or filled INTLIST structure. |
v | Integer value to add. |
ifnew | Add integer to the list only if it is new (0=no, 1=yes). |
Definition at line 108 of file intutil.c.
Referenced by intlistAddFromString(), and intlistExpandFromString().
|
extern |
Read a list of integer values from given string with given delimiters.
s1 | Pointer to string from which the integers are read, for example "2,3,6,8". |
s2 | String containing character delimiters, for example ", ". |
l | Pointer to INTLIST structure; previous contents are preserved. |
ifnew | Add integer to the list only if it is new (0=no, 1=yes). |
Definition at line 156 of file intutil.c.
|
extern |
Read ranges and individual integer values from given string with given delimiters.
s1 | Pointer to string from which the integers are read, for example "0-8,12,32-28" or "0..8, 12, 28..34". |
s2 | String containing character delimiters, for example ", ". |
l | Pointer to INTLIST struct; previous contents are preserved. |
ifnew | Add integer to the list only if it is new (0=no, 1=yes). |
Definition at line 190 of file intutil.c.
Referenced by parSelectParameters(), and parSelectTACs().
|
extern |
Free memory allocated for INTLIST. All data is cleared.
l | Pointer to INTLIST structure |
Definition at line 92 of file intutil.c.
Referenced by parSelectParameters(), and parSelectTACs().
|
extern |
Initiate the INTLIST structure before any use.
l | Pointer to INTLIST. |
Definition at line 80 of file intutil.c.
Referenced by intlistFree(), parSelectParameters(), and parSelectTACs().
|
extern |
Sort the integer array in INTLIST structure.
l | Pointer to INTLIST structure. |
Definition at line 137 of file intutil.c.
Referenced by parSelectParameters(), and parSelectTACs().
|
extern |
Inverse complementary error function erfc^{-1}(x).
Based on the code by Acklam PJ, 2010.
x | Parameter for the inverse complementary error function. |
Definition at line 473 of file doubleutil.c.
|
extern |
Calculate factorial of given number.
n | Integer n, from which the factorial is calculated. |
Definition at line 63 of file intutil.c.
Referenced by lfactorial(), mfEvalInt(), and mfEvalY().
|
extern |
Convert time_t to local time in struct tm.
This version of localtime_r function is here for systems (at least Windows) where it is not defined. Uses localtime, which is threadsafe in Windows.
t | Pointer to time_t; do not give pointer to int here, like &e7mhdr.scan_start_time |
tm | Pointer to struct tm, to be filled here. |
Definition at line 54 of file datetime.c.
Referenced by tacReadScanditronics().
|
extern |
Add a new field into given position inside an existing ROI name. Space character and '_' are accepted as field separators.
roiname | ROI name string which will be edited. |
field | String which will be added as a new field in roiname; can be empty in order to add empty field, but NULL is not accepted. |
in | Field index [0..n] for which position new field will be added; enter a large number to add field to the end. |
count | Max length of the roiname, including space for terminal null. Function returns NULL (error) in case there is not enough space. |
Definition at line 106 of file roiname.c.
|
extern |
Make a new ROI name based on template and old ROI name.
template | Template ROI name, where '_' is used to separate sub-parts, and '@' is replaced by the corresponding sub-part from the 'currname'. |
currname | Current ROI name, from which sub-parts will be added as replacement of '@' in the template. Space character and '_' are assumed to separate the sub-parts. |
newname | Pointer to pre-allocated string of length count, into which the new ROI name will be written. |
count | Max length of new name, including terminal null. |
Definition at line 65 of file roiname.c.
|
extern |
Verifies whether TAC name exists or not.
TAC name string may contain only delimiters like '.', '_', '-', or spaces. Those cases are interpreted as no name in this function.
roiname | ROI name string; not edited. |
Definition at line 158 of file roiname.c.
Referenced by tacEnsureNames(), and tacIndividualNames().
|
extern |
Test whether ROI (TAC) name matches with a test string.
Test string can contain wild cards. If both names contain ROI name separators (' ', '_', or '-'), the corresponding sub-names are tested against each other. If test_str does not contain separators but ROI name does, then names are considered matching if test_str matches with any of sub-names.
roiname | Pointer to ROI name to be tested. |
test_str | Test string. |
status | Pointer to status data; enter NULL if not needed. |
Definition at line 183 of file roiname.c.
Referenced by parSelectTACs(), and tacSelectTACs().
|
extern |
Divide ROI name into its sub-parts, based on user-defined delimiter characters (usually underscore and/or space).
roiname | Pointer to ROI name. Not modified. |
dlm | String containing the sub-part delimiters. For example, " _". |
si | Index [0..n-1] of sub-part to search for. |
subpart | Pointer to allocated string for sub-part. |
slen | Length of the sub-part string, including terminating null. Resulting sub-part length will be at maximum slen-1. |
Definition at line 20 of file roiname.c.
Referenced by parReadFIT(), parReadRES(), parWriteFIT(), parWriteRES(), roinameAddField(), roinameEditByTemplate(), and roinameMatch().
|
extern |
After last use, free any memory allocated in the structure.
s | Pointer to status. |
Definition at line 126 of file statusmsg.c.
|
extern |
Before first use, initialize the structure contents using this function. After last use of status structure, call statusFree(), which also calls this function to re-initiate the structure contents.
s | Pointer to status. |
Definition at line 104 of file statusmsg.c.
Referenced by statusFree().
|
extern |
Print the contents of status structure.
fp | File pointer for the output. |
s | Pointer to status. |
Definition at line 82 of file statusmsg.c.
|
extern |
Set the status contents.
s | Pointer to status. |
func | Pointer to function name, usually func. |
srcfile | Pointer to source file name, usually FILE. |
srcline | Pointer to source file line number, usually LINE. |
error | Error code, 0 if status is ok. |
Definition at line 142 of file statusmsg.c.
Referenced by abssWrite(), anaExists(), bfm1TCM(), bfmSRTM(), csvPutLine(), csvPutLineWithSpaces(), csvRead(), csvReorg(), csvWrite(), dcmFileList(), dcmFileRead(), dcmFileRemove(), dcmFileWrite(), dcmMListRead(), dcmmlSortByPlane(), ecatMListRead(), ecatReadMainheader(), ecatWriteMainheader(), iftCopyItems(), iftDeleteDuplicateKeys(), iftPut(), iftPutFromString(), iftPutFromStringWithSpaceSeparator(), iftRead(), iftReplaceKey(), iftReplaceValue(), iftWrite(), iftWriteItem(), imgAllocate(), imgCompareConc(), imgCompareTimes(), imgCompareUnit(), imgFillOHeader(), imgRead(), imgReadDICOM(), imgReadNifti(), imgWrite(), imgWriteDICOM(), imgWriteNifti(), micropetExists(), micropetHeaderRead(), mtgaPlotSVG(), niftiExists(), nlopt1D(), nloptIATGO(), nloptITGO1(), nloptITGO2(), nloptMPSO(), nloptPowellBrent(), nloptSimplex(), nloptSimplexARRS(), parAllocateWithTAC(), parCombineTACs(), parCompareParameterNames(), parCompareParameters(), parCompareParameterUnits(), parCompareTacNames(), parCompareWSS(), parExamplePerfectBolus(), parExampleTTACs(), parFromIFT(), parRead(), parReadCSV(), parReadFIT(), parReadRES(), parSelectByAnother(), parSelectParameters(), parSelectTACs(), parSortByName(), parToIFT(), parWrite(), parWriteCSV(), parWriteFIT(), parWriteIFT(), parWriteRES(), parWriteXML(), roinameMatch(), sifWeight(), spectralDExp(), spectralKRange(), tacAddZeroSample(), tacAllocateWithPAR(), tacAUC(), tacCompareConc(), tacCompareNames(), tacCompareTimes(), tacCompareUnit(), tacCompareWeights(), tacCorrectFrameOverlap(), tacDecayCorrection(), tacDelay(), tacFittime(), tacFormatDetermine(), tacFramesToSteps(), tacGetHeaderInjectiontime(), tacGetHeaderIsotope(), tacGetHeaderScanstarttime(), tacGetHeaderStudynr(), tacGetHeaderTimeunit(), tacGetHeaderUnit(), tacInput2sim(), tacIntegrate(), tacInterpolate(), tacInterpolateInto(), tacInterpolateToEqualLengthFrames(), tacPlotFitSVG(), tacPlotHistogramSVG(), tacPlotLineSVG(), tacRead(), tacRead4DM(), tacReadAllogg(), tacReadCarimasTxt(), tacReadCSV(), tacReadDFT(), tacReadGEMS(), tacReadHRPLUSHC(), tacReadHRRTHC(), tacReadInveonCSV(), tacReadMat(), tacReadModelingData(), tacReadModelingInput(), tacReadOldAllogg(), tacReadPMOD(), tacReadQView(), tacReadReference(), tacReadScanditronics(), tacReadSIF(), tacReadSimple(), tacSelectTACs(), tacSetWeights(), tacSetX(), tacSortByAUC(), tacSortByConc(), tacSortByName(), tacSortByTime(), tacToPAR(), tacVb(), tacVerifyTimeOrder(), tacWByFreq(), tacWeightModerate(), tacWeightNorm(), tacWMove(), tacWrite(), tacWriteCSV(), tacWriteDFT(), tacWritePMOD(), tacWriteSheetIntoXML(), tacWriteSIF(), tacWriteSimple(), tacWriteXML(), tacXUnitConvert(), tacYUnitConvert(), tacYUnitMass2Volume(), and tacYUnitVolume2Mass().
|
extern |
Case-insensitive version of strstr().
haystack | Pointer to string in which sub-string needle is searched. |
needle | Pointer to sub-string which is searched for in source string haystack. |
Definition at line 155 of file stringext.c.
Referenced by csvSearchField(), dcmImgIsotope(), dcmMListRead(), elementIdentify(), iftSearchKey(), iftSearchValue(), imgFormatFromFName(), parFormatFromExtension(), parReadRES(), parWriteRES(), strdelstr(), tacReadInveonCSV(), tacSelectBestReference(), tacWritePMOD(), tacWriteXML(), and unitIdentifyFilename().
|
extern |
Count how many times characters specified in string s2 are found in string s1.
Search is case-sensitive.
s1 | String to search for characters; not modified. |
s2 | String containing characters which are searched for; not modified. |
Definition at line 98 of file stringext.c.
Referenced by strncpyClean().
|
extern |
Removes any initial and trailing space characters from specified string s. Removes also quotation marks ("" or '') that may be around the string s. Quotes or space characters in the middle of the string are not removed.
s | Pointer to the string. |
Definition at line 389 of file stringext.c.
Referenced by iftPutFromString(), iftPutFromStringWithSpaceSeparator(), imgReadDICOM(), tacNameSplit(), and tacRead4DM().
|
extern |
Remove from string those characters that would require encoding in XML. Replaced by character '-'.
s | Pointer to the string to be cleaned. |
Definition at line 769 of file stringext.c.
|
extern |
Remove parenthesis (s), [s], or {s} from around the string s.
Only one set of pars are removed, and only if the same pars are as the first and last character of the string.
s | Pointer to the string. |
Definition at line 476 of file stringext.c.
Referenced by iftGetDoubleWithUnit(), tacRead4DM(), tacReadCarimasTxt(), and tacReadDFT().
|
extern |
Removes any initial and trailing space characters from specified string s. Space characters in the middle of the string are not removed.
s | Pointer to the string. |
Definition at line 300 of file stringext.c.
Referenced by csvCleanSpaces(), dcmImgIsotope(), and strncpyClean().
|
extern |
Reads date from a standard string representation of date.
str | Pointer to string that contains date in one of the formats YYYY-MM-DD, DD/MM/YYYY, DD.MM.YYYY, DD/MM/YY, or DD.MM.YYYY. |
date | Pointer to allocated struct tm where the date is written; undefined if date is not valid. |
Definition at line 378 of file datetime.c.
Referenced by tacReadGEMS(), and tacReadScanditronics().
|
extern |
Add given time in seconds to the date and time.
s | Time to add in seconds; can be negative. |
dt | Pointer to date and time string, edited here. It must be allocated for at least 20 characters. |
Definition at line 537 of file datetime.c.
|
extern |
Calculate the difference in seconds between two dates and times in international date and time string format (YYYY-MM-DD hh:mm:ss).
dt1 | Pointer to date and time string. |
dt0 | Pointer to date and time string. |
Definition at line 519 of file datetime.c.
Referenced by dcmMListRead(), and imgReadDICOM().
|
extern |
Reads time and date from a standard string representation of date and time.
str | Pointer to string that contains date and time in one of the formats YYYY-MM-DD hh:mm:ss, DD.MM.YYYY hh:mm:ss, or DD/MM/YY hh:mm:ss |
date | Pointer to allocated struct tm where date and time is written. undefined if date or time is not valid. |
Definition at line 350 of file datetime.c.
Referenced by abssWrite(), strDateTimeAdd(), strDateTimeDifference(), tacReadAllogg(), tacReadGEMS(), and tacReadScanditronics().
|
extern |
Verify that specified string contains date and time in correct format (YYYY-MM-DD hh:mm:ss, DD.MM.YYYY hh:mm:ss, D.M.YYYY hh:mm:ss, DD.MM.YY hh:mm:ss, or D.M.YY hh:mm:ss). String must start with date, but any contents after time is ignored.
str | String to be verified. |
intdate | Pointer to preallocated string where date and time is written in international format (YYYY-MM-DD hh:mm:ss); enter NULL, if not needed. Undefined, if date is not valid. |
Definition at line 308 of file datetime.c.
Referenced by dcmDT2intl(), strDateTimeRead(), tacReadOldAllogg(), and tacReadSIF().
|
extern |
Verify that specified string contains date in correct international format (YYYY-MM-DD). String must start with date, but any contents after it is ignored.
str | String to be verified. |
Definition at line 155 of file datetime.c.
Referenced by dcmDA2intl(), strDateRead(), and strDateTimeValid().
|
extern |
Verify that specified string contains date in correct format (DD.MM.YYYY, D.M.YYYY, DD/MM/YYYY, or D/M/YYYY). String must start with date, but any contents after it is ignored.
str | String to be verified. |
intdate | Pointer to preallocated string where date is written in international format; enter NULL, if not needed. Undefined, if date is not valid. |
Definition at line 179 of file datetime.c.
Referenced by strDateRead(), and strDateTimeValid().
|
extern |
Verify that specified string contains date in correct format (DD.MM.YY, D.M.YY, DD/MM/YY, or D/M/YY). String must start with date, but any contents after it is ignored.
str | String to be verified. |
intdate | Pointer to allocated string where date is written in international format; enter NULL, if not needed. Undefined, if date is not valid. |
Definition at line 214 of file datetime.c.
Referenced by strDateRead(), and strDateTimeValid().
|
extern |
Verify that specified integer contains date in format YYYYMMDD.
dateint | Integer to be checked; not changed in this routine. |
intdate | Pointer to allocated string where date is written in international format; enter NULL, if not needed. Undefined, if date is not valid. |
year | Year is written in this pointer; enter NULL if not needed. |
month | Month is written in this pointer; enter NULL if not needed. |
day | Day is written in this pointer; enter NULL if not needed. |
Definition at line 250 of file datetime.c.
|
extern |
Find (case-insensitive) s2 in s1, and delete it from s1.
s1 | Pointer to string in which sub-string s2 is searched; modified. |
s2 | Pointer to sub-string which is searched for in source string s1. |
Definition at line 688 of file stringext.c.
|
extern |
Allocates memory and copies into it the string addressed by s, including the terminating character.
s | String to be duplicated. |
Definition at line 185 of file stringext.c.
Referenced by atofCheck(), atofVerified(), csvCellReplace(), csvDuplicate(), csvPutString(), dcmFileList(), dcmMListRead(), iftPut(), iftPutFromString(), iftPutFromStringWithSpaceSeparator(), iftReplaceKey(), iftReplaceValue(), parCombineTACs(), parCompareParameterNames(), parCompareTacNames(), parSelectByAnother(), pathCreate(), pathExist(), roinameSubpart(), statusSet(), strCleanSpaces(), strTokenDup(), studynrFromFilename(), tacNameSplit(), tacRead(), tacReadCarimasTxt(), tacReadCSV(), tacReadDFT(), tacReadHRRTHC(), tacReadPMOD(), tpcHtmlUsage(), tpcPrintBuild(), tpcPrintUsage(), and tpcProgramName().
|
extern |
Encode special characters for XML, including SVG.
s | Pointer to the string to be encoded. |
Definition at line 731 of file stringext.c.
Referenced by parWriteXML(), and tacWriteXML().
|
extern |
Checks whether argument string contains a decimal comma instead of dot.
s | Pointer to string. |
Definition at line 115 of file decpoint.c.
Referenced by tacReadCSV().
|
extern |
Checks whether argument string contains a decimal comma or dot, or neither.
s | Pointer to string. |
Definition at line 132 of file decpoint.c.
|
extern |
Checks whether string is inside parenthesis (s), [s], or {s}, that is, the same pars as the first and last character of the string.
s | Pointer to the string. |
Definition at line 453 of file stringext.c.
Referenced by strCleanPars(), and tacReadDFT().
|
extern |
Checks whether string contains only space characters.
Text files saved in text editor or Excel may accidentally contain empty looking lines which still may contain tabs and spaces, leading to problems when reading them for example as CSV files.
s | Pointer to the string. |
Definition at line 671 of file stringext.c.
Referenced by csvRead().
|
extern |
Verifies that given string seems like a valid representation of integer or floating point number in decimal or exponential format.
s | Pointer to the string to be verified; it must not contain any leading or trailing space characters etc, or it will never verify. |
Definition at line 33 of file decpoint.c.
Referenced by atofCheck(), and atofVerified().
|
extern |
Safer version of strncat.
At most dstsize-1 characters are appended from the source string to destination string. Destination string will be NUL terminated, unless dstsize <= strlen(dst).
dst | Destination string. |
src | Source string. |
dstsize | The actual length of buffer allocated for the destination string; for example, destination string has been allocated as char dst[dstsize]; |
Definition at line 592 of file stringext.c.
Referenced by fileBackup(), micropetExists(), parReadFIT(), parReadRES(), roinameAddField(), roinameEditByTemplate(), roinameSubpart(), and tpcProgramName().
|
extern |
Safer version of strncpy or strcpy.
At most dstsize-1 characters are copied from the source string to destination string. Destination string will be NUL terminated.
dst | Destination string. |
src | Source string. |
dstsize | The actual length of buffer allocated for the destination string; for example, destination string has been allocated as char dst[dstsize]; |
Definition at line 632 of file stringext.c.
Referenced by abssWrite(), anaExists(), dcmAddItem(), dcmFileRead(), dcmMListRead(), dcmSameImage(), ecatReadMainheader(), ecatWriteMainheader(), fileBackup(), imgCopyHeader(), imgSetNiftiHeader(), imgWriteNifti(), micropetExists(), niftiCreateFNames(), niftiExists(), parReadCSV(), parReadFIT(), parReadRES(), parWriteFIT(), roinameAddField(), strDateRead(), strDateTimeValid(), strncpyClean(), strncpyCleanSpaces(), strTokenDup(), strTokenNCpy(), studynrFromFilename(), tacGetHeaderIsotope(), tacGetHeaderStudynr(), tacNameSplit(), tacRead4DM(), tacReadCarimasTxt(), tacReadCSV(), tacReadDFT(), tacReadInveonCSV(), tacReadMat(), tacReadOldAllogg(), tacReadPMOD(), tacReadQView(), tacReadSIF(), tacReadSimple(), and tpcProgramName().
|
extern |
Concatenate not more than count characters of the string representation of double d to the string pointed to by str1. String is terminated with a null.
str1 | String to be catenated. |
d | Double value to be catenated as string into str1. |
count | No more than count characters are concatenated to str1. If str1 was allocated like char str1[MAX_LEN], then set count=MAX_LEN-strlen(str1)-1. |
Definition at line 517 of file stringext.c.
|
extern |
Concatenate not more than count characters of the string representation of integer n to the string pointed to by str1. String is terminated with a null.
str1 | String to be catenated. |
n | Integer value to be catenated as string into str1. |
count | No more than count characters are concatenated to str1. If str1 was allocated like char str1[MAX_LEN], then set count=MAX_LEN-strlen(str1)-1. |
Definition at line 495 of file stringext.c.
|
extern |
Concatenate not more than count characters of the zero-padded string representation of integer n to the string pointed to by str1. String is terminated with a null.
str1 | String to be catenated. |
n | Integer value to be catenated as string into str1. |
maxn | Integer value which is large enough that it would not need to be zero-padded. |
count | No more than count characters are concatenated to str1. If str1 was allocated like char str1[MAX_LEN], then set count=MAX_LEN-strlen(str1)-1. |
Definition at line 539 of file stringext.c.
|
extern |
Version of strncpy() which as usual copies s2 to s1, but without any quotation marks ("" or ''), space characters, or line end characters that may be around the string s2.
s1 | Pointer to pre-allocated result string with length of at least maxlen characters, including NULL character. |
s2 | Pointer to the original string. |
maxlen | Max length of s1, including the trailing zero. |
Definition at line 321 of file stringext.c.
Referenced by imgReadDICOM(), parSelectParameters(), parSelectTACs(), strClean(), and tacSelectTACs().
|
extern |
Version of strncpy() which as usual copies s2 to s1, but without any space characters or line end characters that may be around the string s2.
s1 | Pointer to pre-allocated result string with length of at least maxlen characters, including NULL character. |
s2 | Pointer to the original string. |
maxlen | Max length of s1, including the trailing zero. |
Definition at line 265 of file stringext.c.
Referenced by niftiBasename(), parReadFIT(), strCleanSpaces(), strncpyClean(), and tacRead4DM().
|
extern |
Allocates memory and copies into it first n characters from string addressed by s, and adds the terminating character.
s | String to be duplicated. |
n | Max nr of characters to copy, not including terminal zero. |
Definition at line 205 of file stringext.c.
Referenced by csvPutLine(), csvPutLineWithSpaces(), iftPutFromString(), iftPutFromStringWithSpaceSeparator(), and tpcProgramName().
|
extern |
Safer version of strlen, in case the argument s is not NUL terminated string. Computes the length of string s, but never scans beyond the n first bytes of the string.
s | Pointer to string, or character array, that may not be NULL terminated. |
n | The actual length of buffer allocated for the string; for example, string could have been allocated as char s[n]; |
Definition at line 566 of file stringext.c.
Referenced by abssIdFromFName(), anaExists(), anaReadHeader(), atoiCheck(), dcmAddItem(), dcmDA2intl(), dcmDT2intl(), dcmFileList(), dcmFileRead(), dcmFileRemove(), dcmFileWrite(), dcmSOPIdentify(), dcmSOPUIDName(), dcmTM2intl(), dcmTrUID(), elementIdentify(), fileExist(), filenameGetExtension(), filenameGetExtensions(), filenameRmExtension(), filenameRmExtensions(), filenameRmFile(), filenameRmPath(), imgFormatFromFName(), imgRead(), imgReadDICOM(), imgReadNifti(), imgWrite(), imgWriteDICOM(), imgWriteNifti(), isotopeIdentify(), micropetExists(), micropetHeaderRead(), mtgaPlotSVG(), niftiExists(), niftiReadHeader(), niftiWriteHeader(), parCombineTACs(), parSelectByAnother(), parWriteFIT(), pathCreate(), pathFileList(), pathFileNr(), roinameMatch(), roinameSubpart(), strDateRead(), strDateTimeValid(), strDateValid(), strDateValid2(), strDateValid3(), strIsValidNumber(), strlcat(), strndup(), strTimeValid(), strTokenNr(), studynrFromFilename(), tacPlotFitSVG(), tacPlotHistogramSVG(), tacPlotLineSVG(), tacReadAllogg(), tacReadGEMS(), tacReadMat(), tacReadModelingData(), tacReadModelingInput(), tacReadOldAllogg(), tacReadQView(), tacReadReference(), tacReadScanditronics(), tpcHtmlUsage(), tpcProcessStdOptions(), tpcProgramName(), tpcYesNo(), unitIdentify(), and unitIdentifyFilename().
|
extern |
Replace all characters c1 in string s with character c2.
s | Pointer to string in which the character is replaced. |
c1 | Character to be replaced. |
c2 | Character to use instead. If NULL, then only the first character is replaced. |
Definition at line 134 of file stringext.c.
Referenced by csvPutDouble(), parCombineTACs(), parCompareParameterNames(), parCompareTacNames(), parSelectByAnother(), parToIFT(), strCleanForXML(), and tacWritePMOD().
|
extern |
Version of strstr() which ignores any matches inside quotation marks "" or ''.
haystack | Pointer to string to be searched. |
needle | Pointer to string with quotation marks. |
Definition at line 225 of file stringext.c.
Referenced by csvRead(), iftPutFromString(), and iftPutFromStringWithSpaceSeparator().
|
extern |
Verify that specified string contains time in correct format (hh:mm:ss). String must start with time, but any contents after it is ignored.
str | String to be verified. |
Definition at line 284 of file datetime.c.
Referenced by dcmTM2intl(), iftPutFromString(), and strDateTimeValid().
|
extern |
Search the string s1 for the first token. The characters making up the string s2 are the delimiters that determine the tokens.
s1 | String from where tokens are searched; not modified in any way. |
s2 | String containing character delimiters. |
next | Index of s1 where the token ended; set to NULL, if not needed. |
Definition at line 413 of file stringext.c.
Referenced by csvRead(), iftRead(), tacFormatDetermine(), and tacRead4DM().
|
extern |
Copy the i'th token in the string s1 into string s3. The characters making up the string s2 are the delimiters that determine the tokens.
s1 | String from where tokens are searched; not modified in any way. |
s2 | String containing character delimiters. |
i | Token number to copy (1..nr of tokens). |
s3 | String array into where the token is copied; string will be null terminated. |
count | Length of s3, including terminal null. |
Definition at line 53 of file stringext.c.
Referenced by atofList(), doubleGetWithUnit(), floatGetWithUnit(), iftGetDoubleWithUnit(), intlistAddFromString(), intlistExpandFromString(), parFromIFT(), parReadCSV(), parReadRES(), and tacReadSIF().
|
extern |
Calculate the number of tokens in the string s1. The characters making up the string s2 are the delimiters that determine the token.
s1 | String from where tokens are calculated; not modified in any way. |
s2 | String containing character delimiters. |
Definition at line 25 of file stringext.c.
Referenced by atofList(), doubleGetWithUnit(), floatGetWithUnit(), intlistAddFromString(), intlistExpandFromString(), parFromIFT(), parReadRES(), and tacNameSplit().
|
extern |
Strip string of t characters from the left.
s | Pointer to the string to be trimmed. Overwritten. |
t | Number of characters to remove. |
Definition at line 710 of file stringext.c.
|
extern |
Count how many upper case characters are found in string.
s | String to search for upper case characters; not modified. |
Definition at line 118 of file stringext.c.
|
extern |
Extract study number (max MAX_STUDYNR_LEN chars) from given file name.
If file name string includes path, the path is ignored. This function removes initial zeroes from the numerical part, and converts upper case letters to lower case, if necessary.
fname | File name, which may include the path. |
studynr | Pointer for the resulting study number. Memory must be allocated before calling this function (at least MAX_STUDYNR_LEN+1 characters). |
force | Validity of studynr is verified (0) or not verified (1). |
Definition at line 79 of file studynr.c.
Referenced by tacRead().
|
extern |
Remove initial zeroes in the numerical part of the PET study number, and convert any capital letters to lower-case.
s | Pointer to the study number string to be edited. |
Definition at line 47 of file studynr.c.
Referenced by studynrFromFilename().
|
extern |
Check that the argument string is a valid TPC study number containing 1-5 letters (upper or lower case) followed by 1-5 digits.
s | Pointer to string to test. |
zero_ok | Number part of study number may start with zero (1) or may not (0). |
Definition at line 22 of file studynr.c.
Referenced by studynrFromFilename().
|
extern |
In-place swab, replaces the non-ANSI function swab(), which may not work if data is overlapping.
buf | Pointer to memory |
size | Size of buf in bytes |
Definition at line 115 of file endian.c.
Referenced by anaReadHeader(), dcmFileWrite(), dcmWriteFileTag(), niftiReadHeader(), and niftiWriteHeader().
|
extern |
Swap the specified short int, int, long int, float, or double from little endian to big endian or vice versa.
Arguments are allowed to overlap.
from | Pointer to a short int, int, long int, float, or double variable. |
to | Pointer to a short int, int, long int, float, or double variable. |
size | Size of from and to (byte nr) must be 1, 2, 4 or 8. |
Definition at line 69 of file endian.c.
Referenced by dcmitemGetInt(), dcmitemGetReal(), dcmReadFileTag(), dcmReadFileVL(), dcmReadFileVRVL(), dcmValueString(), dcmWriteFileVRVL(), and swap().
|
extern |
In-place big-little endian swapping of an array of 16 bit (2 byte) integers.
buf | Pointer to memory. |
size | Nr of 16 bit values in the array. |
Definition at line 234 of file endian.c.
Referenced by imgReadNifti(), niftiReadHeader(), and niftiWriteHeader().
|
extern |
In-place big-little endian swapping of an array of 32 bit (4 byte) integers or floating point values.
buf | Pointer to memory. |
size | Nr of 32 bit values in the array. |
Definition at line 210 of file endian.c.
Referenced by imgReadNifti(), niftiReadHeader(), and niftiWriteHeader().
|
extern |
In-place big-little endian swapping of an array of 64 bit (8 byte) integers or floating point values.
buf | Pointer to memory. |
size | Nr of 64 bit values in the array. |
Definition at line 184 of file endian.c.
Referenced by imgReadNifti(), niftiReadHeader(), and niftiWriteHeader().
|
extern |
In-place swab and swaw, switches words and bytes from an array of 4-byte ints or floats.
buf | Pointer to memory |
size | Size of buf in bytes |
Definition at line 138 of file endian.c.
Referenced by anaReadHeader(), ecatMListRead(), niftiReadHeader(), and niftiWriteHeader().
|
extern |
In-place swaw, switches words (but not bytes) from an array of 4-byte ints or floats.
buf | Pointer to memory |
size | Size of buf in bytes |
Definition at line 161 of file endian.c.
|
extern |
Convert calendar time to local broken-down time.
This function is copied from GNU C Library with tiny modifications.
totalsecs | number of seconds elapsed since 00:00:00 on January 1, 1970, UTC; can be negative to represent times before 1970. |
offset | offset seconds adding to totalsecs (e.g. -timezone). |
result | pointer to struct tm variable to receive broken-down time. |
Definition at line 443 of file datetime.c.
|
extern |
Inverse of gmtime, converting struct tm to time_t.
Otherwise same as mktime, except that mktime uses local time. Uses gmtime_r or gmtime_s, if available, otherwise gmtime, which is thread-safe in Windows.
tm | Pointer to struct tm. |
Definition at line 77 of file datetime.c.
Referenced by tmAdd().
|
extern |
Add given time in seconds to the date and time.
s | Time to add in seconds; can be negative. |
d | Pointer to tm structure. |
Definition at line 500 of file datetime.c.
Referenced by abssWrite(), and strDateTimeAdd().
|
extern |
Calculate the difference in seconds between two given dates and times.
tm1 | Pointer to tm structure. |
tm0 | Pointer to tm structure. |
Definition at line 486 of file datetime.c.
Referenced by strDateTimeDifference().
|
extern |
Write program usage given as argument, plus program name, tpcclib version, and default copyright text, into HTML file.
program | Program name, may contain extension and path. |
text | Program usage text. |
path | Path name where to create file programname.html; path may contain trailing '/' or '\'. |
Definition at line 169 of file proginfo.c.
|
extern |
Print tpctools build information.
program | Program name; enter NULL, if not to be printed. |
fp | File pointer where to print; usually stdout. |
Definition at line 339 of file proginfo.c.
|
extern |
Print program usage given as argument, plus program name, tpcclib version, and default copyright text.
program | Program name. |
text | Program usage text. |
fp | File pointer where to print; usually stdout. |
Definition at line 114 of file proginfo.c.
|
extern |
Check if given command-line argument string is one of the standard command-line options of this project.
s | Pointer to command-line option string. |
print_usage | If option string is either -h or –help, then this variable is set to 1. |
print_version | If option string is either -v, -V, –version, or –build, then this variable is set to 1. |
verbose_level | The level of debugging messages and listings:
|
Definition at line 47 of file proginfo.c.
|
extern |
Process program name and optionally version into given string, based on user-given string, usually argv[0].
program | Set to argv[0]. |
version | Add version (1) or do not add (0). |
copyright | Add copyright (1) or do not add (0). |
prname | Pointer to string where program name is written. |
n | Buffer length of prname, max n-1 characters are written into it, plus nul char. |
Definition at line 406 of file proginfo.c.
|
extern |
Check whether argument string is 'y(es)' or 'n(o)', or 'on' or 'off'.
s | String to be tested. |
Definition at line 459 of file proginfo.c.
|
extern |
Check whether the combination of units is an identifiable combinatorial unit.
u1 | Unit #1 of dividend |
u2 | Unit #2 of dividend |
v1 | Unit #1 of divider |
v2 | Unit #2 of divider |
Definition at line 745 of file units.c.
Referenced by unitDividerMassVolumeConversion(), and unitMultiply().
|
extern |
Calculates conversion factor between specified two units, if possible.
Multiply value with factor to get the value in unit2.
u1 | Enum unit 1. |
u2 | Enum unit 2. |
Definition at line 487 of file units.c.
Referenced by parReadCSV(), tacDecayCorrection(), tacFittime(), tacXMatch(), tacXUnitConvert(), tacYUnitConvert(), and unitConversionFactor().
|
extern |
Check whether the unit has radioactivity in the dividend.
u | Enum unit |
Definition at line 710 of file units.c.
Referenced by unitIsRAConc().
|
extern |
Check whether the unit has mass in divider.
u | Enum unit |
Definition at line 694 of file units.c.
Referenced by tacYUnitMass2Volume(), unitDividerMassVolumeConversion(), and unitIsRAConc().
|
extern |
Check whether the unit has volume in divider.
u | Enum unit |
Definition at line 678 of file units.c.
Referenced by tacYUnitVolume2Mass(), unitDividerMassVolumeConversion(), and unitIsRAConc().
|
extern |
Convert unit that has either volume or mass unit in divider to corresponding unit (assuming density of 1 g/mL) with either mass or volume in divider.
u | Unit (enum) |
Definition at line 775 of file units.c.
Referenced by tacYUnitMass2Volume(), and tacYUnitVolume2Mass().
|
extern |
Identify the unit based on string representation s of the unit.
s | Unit as a string. |
Definition at line 162 of file units.c.
Referenced by doubleGetWithUnit(), floatGetWithUnit(), iftGetDoubleWithUnit(), imgGetNiftiHeader(), imgReadDICOM(), parFromIFT(), parReadCSV(), parReadFIT(), parReadRES(), parWriteCSV(), tacAllocateWithPAR(), tacGetHeaderTimeunit(), tacGetHeaderUnit(), tacRead4DM(), tacReadCarimasTxt(), tacReadCSV(), tacReadDFT(), tacReadHRRTHC(), tacReadInveonCSV(), and tacReadPMOD().
|
extern |
Identify calibration unit based on file name.
s | File name. |
Definition at line 311 of file units.c.
Referenced by tacRead().
|
extern |
|
extern |
Check whether the unit is a combinatorial unit.
u | Enum unit |
Definition at line 468 of file units.c.
Referenced by unitConversionFactor(), unitDividendHasRadioactivity(), unitDividerHasMass(), unitDividerHasVolume(), and unitIsRAConc().
|
extern |
Check whether the unit is a unit of distance.
u | Enum unit. |
Definition at line 339 of file units.c.
Referenced by tacWriteDFT(), and unitConversionFactor().
|
extern |
Check whether the unit is a unit of mass.
u | Enum unit. |
Definition at line 402 of file units.c.
Referenced by unitConversionFactor(), unitDividerHasMass(), unitDividerMassVolumeConversion(), and unitIsRAConc().
|
extern |
Check whether the unit is a unit of chemical mass.
u | Enum unit. |
Definition at line 423 of file units.c.
Referenced by unitConversionFactor().
|
extern |
Check whether the unit is a known unit of radioactivity per mass or volume.
u | Enum unit |
Definition at line 726 of file units.c.
Referenced by tacSetWeights().
|
extern |
Check whether the unit is a unit of radioactivity.
u | Enum unit |
Definition at line 444 of file units.c.
Referenced by tacSetWeights(), unitConversionFactor(), unitDividendHasRadioactivity(), and unitIsRAConc().
|
extern |
Check whether the unit is a unit of time.
u | Enum unit. |
Definition at line 359 of file units.c.
Referenced by bfm1TCM(), parWriteCSV(), tacDecayCorrection(), tacPlotFitSVG(), tacPlotLineSVG(), tacSetWeights(), and unitConversionFactor().
|
extern |
Check whether the unit is a unit of volume.
u | Enum unit. |
Definition at line 382 of file units.c.
Referenced by unitConversionFactor(), unitDividerHasVolume(), unitDividerMassVolumeConversion(), and unitIsRAConc().
|
extern |
Multiply two units.
ua | Unit A |
ub | Unit B |
Definition at line 809 of file units.c.
|
extern |
Get the string representation of the unit specified with its unit_code.
unit_code | unit_code as enum or the index of unit in the table. |
Definition at line 143 of file units.c.
Referenced by imgCompareUnit(), imgContents(), imgFillOHeader(), imgReadDICOM(), imgSetNiftiHeader(), parAllocateWithTAC(), parCompareParameterUnits(), parExamplePerfectBolus(), parExampleTTACs(), parToIFT(), parWriteCSV(), parWriteRES(), parWriteXML(), tacCompareUnit(), tacPlotFitSVG(), tacPlotLineSVG(), tacRead(), tacRead4DM(), tacSetHeaderTimeunit(), tacSetHeaderUnit(), tacWriteCSV(), tacWriteDFT(), tacWritePMOD(), tacWriteSheetIntoXML(), tacWriteSimple(), tacWriteXML(), tacXUnitConvert(), tacYUnitConvert(), and unitMultiply().