TPCCLIB
|
Header file for libtpcmisc. More...
#include "tpcclibConfig.h"
#include <errno.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#include <stdint.h>
#include <unistd.h>
Go to the source code of this file.
Data Structures | |
struct | IFT_KEY_AND_VALUE |
struct | IFT |
struct | INT_list |
struct | INTEGER_LIST |
struct | STR_TOKEN_LIST |
Macros | |
#define | BRANCHING_O 0.999 |
#define | BRANCHING_C 0.998 |
#define | BRANCHING_Cu64 0.174 |
#define | BRANCHING_N 0.998 |
#define | BRANCHING_F 0.967 |
#define | BRANCHING_Ge 0.891 |
#define | BRANCHING_Ga 0.891 |
#define | BRANCHING_Rb 0.950 |
#define | HL_O15 2.05 /* 123 s */ |
#define | HL_N13 10.0 |
#define | HL_C11 20.4 |
#define | HL_F18 109.8 |
#define | HL_Ge68 396000.0 /* 275 d */ |
#define | HL_Ga68 68.0 |
#define | HL_Br75 98.0 |
#define | HL_Br76 978.33 /* 58700 s */ |
#define | HL_Cu62 9.7 /* 582 s */ |
#define | HL_Cu64 762.018 /* 12.7003 h */ |
#define | HL_Fe52 4980.0 |
#define | HL_Na22 1368000.0 |
#define | HL_O14 1.1818 |
#define | HL_Rb82 1.25 /* 75 s */ |
#define | HL_Zn62 558.0 |
#define | HL_I124 6013.44 /* 4.176 */ |
#define | M_LN2 0.69314718055994530942 |
#define | MAX_UNITS_LEN 31 |
#define | MAX_REGIONNAME_LEN 20 |
#define | MAX_REGIONSUBNAME_LEN 6 |
#define | MAX_STUDYNR_LEN 255 |
Functions | |
int | backupExistingFile (char *filename, char *backup_ext, char *status) |
int | fileCopy (char *filename1, char *filename2, char *status) |
float | branchingFraction (int isotope) |
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 calendard 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 | isdate (char *str) |
int | isdate2 (char *str, char *intdate) |
int | isdate3 (char *str, char *intdate) |
int | isdate4 (int dateint, int *year, int *month, int *day) |
int | istime (char *str) |
int | isdatetime (char *str, char *intdate) |
int | get_datetime (char *str, struct tm *date, int verbose) |
int | get_date (char *str, struct tm *date) |
long int | math_div (long int a, long int b) |
int | isleapyear (long int year) |
long int | leaps_between (long int year1, long int year2) |
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) |
int | dec_comma_is (char *str) |
int | dec_separator (char *str) |
void | dec_separator_change (char *str, int decsep) |
double | atof_dpi (char *str) |
int | dec_nr (char *str) |
int | atof_with_check (char *double_as_string, double *result_value) |
char * | strPtrToNextValue (char *str, char **nxtp) |
int | atoi_with_check (const char *int_as_string, int *result_value) |
void | filenameRmPath (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 (char *s) |
Get the last extension of a filename. | |
char * | filenameGetExtensions (char *s) |
Get all extensions of a filename. | |
char * | hlIsotopeCode (int isotope) |
double | hlFromIsotope (char *isocode) |
double | hl2lambda (double halflife) |
double | hlLambda2factor (double lambda, double frametime, double framedur) |
float | hlLambda2factor_float (float lambda, float frametime, float framedur) |
char * | hlCorrectIsotopeCode (char *isocode) |
int | hlIsotopeFromHalflife (double halflife) |
const char * | libpet_idcrypt_version (void) |
int | id_crypt (const char *string, const char *key, char *out, int decrypt) |
void | iftSetStatus (IFT *ift, int status) |
void | iftInit (IFT *ift) |
void | iftEmpty (IFT *ift) |
int | iftPut (IFT *ift, char *key, char *value, char *cmt_type, int verbose) |
int | iftPutDouble (IFT *ift, char *key, double value, char *cmt_type, int verbose) |
int | iftRead (IFT *ift, char *filename, int is_key_required, int verbose) |
char * | iftReadValue (char *filename, char *keystr, int verbose) |
int | iftWriteItem (IFT *ift, int item, FILE *fp, int verbose) |
int | iftWrite (IFT *ift, char *filename, int verbose) |
int | defRead (IFT *ift, char *filename, int verbose) |
int | iftGet (IFT *ift, char *key, int verbose) |
int | iftGetNth (IFT *ift, char *key, int n, int verbose) |
int | iftFindNthKey (IFT *ift, char *str, int n, int verbose) |
int | iftFindNthValue (IFT *ift, char *str, int n, int verbose) |
int | iftGetKeyNr (IFT *ift, const char *key, int verbose) |
int | iftGetFrom (IFT *ift, int si, const char *key, int verbose) |
int | iftGetFullmatchFrom (IFT *ift, int si, const char *key, const char *value, int verbose) |
int | iftGetFloatValue (IFT *ift, int si, const char *key, float *value, int verbose) |
int | iftGetDoubleValue (IFT *ift, int si, const char *key, double *value, int verbose) |
int | iftGetIntValue (IFT *ift, int si, const char *key, int *value, int verbose) |
int | iftDeleteItem (IFT *ift, int item, int verbose) |
int | iftReplaceNthValue (IFT *ift, int item, char *value, int verbose) |
int | iftdup (IFT *ift1, IFT *ift2, int verbose) |
void | intInit (INT_list *list) |
void | intEmpty (INT_list *list) |
int | intExpand (char *text, INT_list *list) |
INT_list | intMerge (INT_list *list1, INT_list *list2) |
int | _intexadd (INT_list *list, int a) |
int | integerListInit (INTEGER_LIST *l) |
int | integerListEmpty (INTEGER_LIST *l) |
int | integerListAdd (INTEGER_LIST *l, int v, int ifnew) |
int | integerListSort (INTEGER_LIST *l) |
int | integerListAddFromString (const char *s1, const char *s2, INTEGER_LIST *l, const int ifnew) |
int | integerListExpandFromString (const char *s1, const char *s2, INTEGER_LIST *l, const int ifnew) |
int | temp_roundf (float e) |
int | petCunitId (const char *unit) |
int | petTunitId (const char *timeunit) |
char * | petCunit (int cunit) |
char * | petTunit (int tunit) |
int | cunitFromFilename (char *fname) |
int | tpcProcessStdOptions (const char *s, int *print_usage, int *print_version, int *verbose_level) |
void | tpcProgramName (const char *program, int version, int copyright, char *prname, int n) |
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) |
char * | strstr_noquotation (const char *str1, const char *str2) |
int | strnCopyClean (char *str1, const char *str2, int maxlen) |
void | str_token_list_init (STR_TOKEN_LIST *lst) |
void | str_token_list_empty (STR_TOKEN_LIST *lst) |
int | str_token_list_add (STR_TOKEN_LIST *lst, char *new_item) |
int | str_token_list_del (STR_TOKEN_LIST *lst, int item) |
int | str_token_list_read (const char *filename, STR_TOKEN_LIST *lst) |
int | textfileReadLines (const char *filename, STR_TOKEN_LIST *lst) |
int | readStrtokens (const char *filename, char ***toklist) |
int | asciiCommentLine (const char *line, int *cont) |
int | rnameSplit (char *rname, char *name1, char *name2, char *name3, int max_name_len) |
int | rnameMatch (char *rname, int rnr, char *test_str) |
int | rnameRmDots (char *rname1, char *rname2) |
int | rnameCatenate (char *rname, int max_rname_len, char *name1, char *name2, char *name3, char space) |
int | roinameExists (char *roiname) |
Verifies whether TAC name exists or not. | |
int | strTokenNr (const char *str1, const char *str2) |
int | strTokenNCpy (const char *str1, const char *str2, int i, char *str3, int count) |
char * | strTokenDup (const char *s1, const char *s2, int *next) |
int | strChrCount (const char *str1, const char *str2) |
int | strUppercaseCount (const char *s) |
void | strReplaceChar (char *str, char c1, char c2) |
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 * | strcasestr (const char *haystack, const char *needle) |
int | strncpyCleanSpaces (char *s1, const char *s2, int maxlen) |
int | strCleanSpaces (char *s) |
char * | strEncodeForXML (const char *s) |
void | strCleanForXML (char *s) |
int | studynr_in_fname (char *fname, char *studynr) |
int | studynr_from_fname (char *fname, char *studynr) |
int | studynr_from_fname2 (char *fname, char *studynr, int force) |
int | studynr_match (char *studynr1, char *studynr2) |
int | studynr_validity_check2 (char *studynr, int zero_ok) |
int | studynr_validity_check (char *studynr) |
int | studynr_rm_zeroes (char *studynr) |
int | studynr_to_lowercase (char *studynr) |
int | little_endian () |
void | swap (void *orig, void *new, int size) |
void | swabip (void *buf, long long int size) |
void | swawbip (void *buf, long long int size) |
void | swawip (void *buf, long long int size) |
void | printf32bits (void *buf) |
int | doubleMatch (const double v1, const double v2, 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 | doubleMaxIndex (double *a, const unsigned int n) |
double | doubleSum (double *a, const unsigned int n) |
double | doubleMean (double *a, const unsigned int n) |
int | doubleSpanPositives (double *a, const int n) |
int | doubleCSpanPositives (double *a, const int n) |
double | inverfc (double x) |
void | statSortDouble (double *data, unsigned int n, int order) |
void | statSortFloat (float *data, unsigned int n, int order) |
Header file for libtpcmisc.
Definition in file libtpcmisc.h.
#define BRANCHING_C 0.998 |
Isotope branching ratio
Definition at line 28 of file libtpcmisc.h.
Referenced by branchingFraction().
#define BRANCHING_Cu64 0.174 |
Isotope branching ratio
Definition at line 30 of file libtpcmisc.h.
Referenced by branchingFraction().
#define BRANCHING_F 0.967 |
Isotope branching ratio
Definition at line 34 of file libtpcmisc.h.
Referenced by branchingFraction().
#define BRANCHING_Ga 0.891 |
Isotope branching ratio
Definition at line 38 of file libtpcmisc.h.
Referenced by branchingFraction().
#define BRANCHING_Ge 0.891 |
Isotope branching ratio
Definition at line 36 of file libtpcmisc.h.
Referenced by branchingFraction().
#define BRANCHING_N 0.998 |
Isotope branching ratio
Definition at line 32 of file libtpcmisc.h.
Referenced by branchingFraction().
#define BRANCHING_O 0.999 |
Isotope branching ratio
Definition at line 26 of file libtpcmisc.h.
Referenced by branchingFraction().
#define BRANCHING_Rb 0.950 |
Isotope branching ratio
Definition at line 40 of file libtpcmisc.h.
Referenced by branchingFraction().
#define HL_Br75 98.0 |
Isotope halflife in minutes; not verified from the reference
Definition at line 58 of file libtpcmisc.h.
#define HL_Br76 978.33 /* 58700 s */ |
Isotope halflife in minutes; not verified from the reference
Definition at line 60 of file libtpcmisc.h.
#define HL_C11 20.4 |
Isotope halflife in minutes
Definition at line 47 of file libtpcmisc.h.
#define HL_Cu62 9.7 /* 582 s */ |
Isotope halflife in minutes; not verified from the reference
Definition at line 62 of file libtpcmisc.h.
#define HL_Cu64 762.018 /* 12.7003 h */ |
Isotope halflife in minutes; not verified from the reference
Definition at line 64 of file libtpcmisc.h.
#define HL_F18 109.8 |
Isotope halflife in minutes
Definition at line 49 of file libtpcmisc.h.
#define HL_Fe52 4980.0 |
Isotope halflife in minutes; not verified from the reference
Definition at line 66 of file libtpcmisc.h.
#define HL_Ga68 68.0 |
Isotope halflife in minutes
Definition at line 53 of file libtpcmisc.h.
#define HL_Ge68 396000.0 /* 275 d */ |
Isotope halflife in minutes
Definition at line 51 of file libtpcmisc.h.
#define HL_I124 6013.44 /* 4.176 */ |
Isotope halflife in minutes; not verified from the reference
Definition at line 76 of file libtpcmisc.h.
#define HL_N13 10.0 |
Isotope halflife in minutes
Definition at line 45 of file libtpcmisc.h.
#define HL_Na22 1368000.0 |
Isotope halflife in minutes; not verified from the reference
Definition at line 68 of file libtpcmisc.h.
#define HL_O14 1.1818 |
Isotope halflife in minutes; not verified from the reference
Definition at line 70 of file libtpcmisc.h.
#define HL_O15 2.05 /* 123 s */ |
Isotope halflife in minutes
Definition at line 43 of file libtpcmisc.h.
#define HL_Rb82 1.25 /* 75 s */ |
Isotope halflife in minutes; not verified from the reference
Definition at line 72 of file libtpcmisc.h.
#define HL_Zn62 558.0 |
Isotope halflife in minutes; not verified from the reference
Definition at line 74 of file libtpcmisc.h.
#define M_LN2 0.69314718055994530942 |
ln(2)
Definition at line 90 of file libtpcmisc.h.
Referenced by hl2lambda(), and plasma_to_blood_ratio().
#define MAX_REGIONNAME_LEN 20 |
Max length of Region name (+1)
Definition at line 154 of file libtpcmisc.h.
Referenced by cptReadOne(), cptrnameSplit(), csv2dft_a(), csv2dft_b(), csv2dft_linkset(), csv2dft_mat(), dft_fill_hdr_from_IFT(), dftGetPmodTitle(), dftRead(), dftRNameSimplify(), fitRead(), resRead(), rnameMatch(), rnameSplit(), roikbqRead(), and tsvRead().
#define MAX_REGIONSUBNAME_LEN 6 |
Max length of Region name subfield (+1)
Definition at line 158 of file libtpcmisc.h.
Referenced by clusterTACs(), cptReadOne(), csv2dft(), csv2dft_a(), csv2dft_b(), csv2dft_linkset(), csv2dft_mat(), dft_fill_hdr_from_IFT(), dftGetPmodTitle(), dftRead(), fitRead(), fitWrite(), idwcRead(), resRead(), resWrite(), tsvRead(), and xelRead().
#define MAX_STUDYNR_LEN 255 |
Max length of Study number (+1)
Definition at line 163 of file libtpcmisc.h.
Referenced by csv2dft_b(), csv2dft_mat(), dft_fill_hdr_from_IFT(), dftAllocateWithIMG(), dftRead(), ecat63ReadAllToImg(), ecat63ReadPlaneToImg(), fitRead(), img2sif(), imgGetAnalyzeHeader(), imgGetEcat63MHeader(), imgGetEcat7MHeader(), imgInfo(), imgReadAnalyze(), imgReadAnalyzeHeader(), imgReadNiftiHeader(), resRead(), sif2img(), studynr_from_fname2(), studynr_in_fname(), studynr_match(), and studynr_validity_check2().
#define MAX_UNITS_LEN 31 |
Max length of units string (+1), based on ECAT7 format
Definition at line 95 of file libtpcmisc.h.
Referenced by cptReadOne(), dftAllocateWithIMG(), and dftGetPmodTitle().
anonymous enum |
isotope_code
Definition at line 79 of file libtpcmisc.h.
anonymous enum |
Data y units
Definition at line 99 of file libtpcmisc.h.
anonymous enum |
Data x units
Definition at line 138 of file libtpcmisc.h.
anonymous enum |
Definitions for ift status message
Definition at line 249 of file libtpcmisc.h.
|
extern |
int _intexadd(int *list, int a) ; local function. Deprecated.
list | |
a |
Definition at line 92 of file intex.c.
Referenced by intExpand().
|
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 246 of file readfile.c.
Referenced by sifRead().
|
extern |
Replacement of atof(), which works whether string contains decimal dots or decimal commas. Possible commas are replaced by dots in the argument string.
str | Pointer to string (not modified). |
Definition at line 59 of file decpoint.c.
Referenced by atof_with_check(), csv2dft_a(), csv2dft_b(), dft_fill_hdr_from_IFT(), dftRead(), fitRead(), and resRead().
|
extern |
Converts a string to float using atof(), but if its return value is zero this function checks that argument string actually contains a number. Result value is set to NaN if string was not valid value. Both decimal point and comma are accepted.
double_as_string | String which is converted to a double; not modified |
result_value | Pointer to the double float; enter NULL, if not needed |
Definition at line 107 of file decpoint.c.
Referenced by csv2dft_linkset(), csv2dft_mat(), dftRead(), and readEcat931Calibrationfile().
|
extern |
Converts a string to integer (int) using atoi, but this function verifies that argument string actually contains an integer number. String must end in NULL character. Exponentials are not accepted. Result value is set to 0 if string was not valid value.
int_as_string | String which is converted to a int; not modified |
result_value | Pointer to the int; enter NULL, if not needed |
Definition at line 238 of file decpoint.c.
Referenced by integerListAddFromString(), and pxlRead().
|
extern |
Check if specified file exists; rename existing file to a backup file. If also backup file exists, then remove that.
filename | Name of file which, if it exists, is renamed to a backup file |
backup_ext | Extension for backup file; NULL will set the default ".bak" extension. |
status | Pointer 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 14 of file backup.c.
Referenced by dftWrite(), fitWrite(), plot_fit_svg(), plot_fitrange_svg(), plot_svg(), plotdata(), and resWrite().
float branchingFraction | ( | int | isotope | ) |
Branching fraction for specified isotope.
isotope | Isotope code; see hlIsotopeFromHalflife() |
Definition at line 14 of file branch.c.
Referenced by hrrtMakeCalHdr(), imgBranchingCorrection(), and imgGetMicropetHeader().
|
extern |
Convert calendard 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 110 of file datetime.c.
Referenced by atnMake(), ecat7MHeaderToIFT(), ecat7PrintMainheader(), fitWrite(), imgGetEcat63MHeader(), imgInfo(), imgSetEcat63MHeader(), imgWriteEcat63Frame(), imgWriteFrame(), plotdata(), resWrite(), resWriteHTML_table(), and sifPrint().
|
extern |
Tries to find calibration unit from filename.
fname | Pointer to file name, where calibration unit is tried to be found. |
Definition at line 242 of file petunits.c.
|
extern |
Checks whether argument string contains a decimal comma instead of dot.
str | Pointer to string (not modified). |
Definition at line 14 of file decpoint.c.
|
extern |
Returns the number of decimal places in the argument string, representing a floating point value. String can contain either decimal dots or commas.
Definition at line 81 of file decpoint.c.
Referenced by dftRead().
|
extern |
Checks whether argument string contains a decimal comma or dot, or neither.
str | Pointer to string (not modified). |
Definition at line 28 of file decpoint.c.
|
extern |
Convert the first decimal separator to comma or dot, as required.
str | Pointer to string (modified when necessary). |
decsep | Requested decimal separator: 0=dot, 1=comma. |
Definition at line 40 of file decpoint.c.
|
extern |
Read definition file, for example microPET header file, into IFT structure.
ift | Pointer to initiated but empty IFT |
filename | Input filename |
verbose | Verbose level; if zero, then only warnings are printed into stderr |
Definition at line 321 of file iftfile.c.
Referenced by imgReadMicropetFrame(), and imgReadMicropetHeader().
|
extern |
Copy double values from the 2nd array to the first.
t | Target array |
s | Source array |
n | Length of arrays |
Definition at line 93 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 186 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 83 of file doubleutil.c.
Referenced by householder_transform().
|
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 28 of file doubleutil.c.
|
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 55 of file doubleutil.c.
|
extern |
Find the maximum value in given double array.
a | Pointer to double array. |
n | Length of array. |
Definition at line 111 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 148 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 168 of file doubleutil.c.
|
extern |
Calculate the sum of values in given double array.
a | Pointer to double array. |
n | Length of array. |
Definition at line 130 of file doubleutil.c.
|
extern |
Copy file contents to another file. Existing file will be overwritten, to prevent it call backupExistingFile() before calling this function.
filename1 | Name of file to be copied |
filename2 | Name of new file |
status | Pointer 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 65 of file backup.c.
|
extern |
Get the last extension of a filename.
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 139 of file filename.c.
|
extern |
Get all extensions of a filename.
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 164 of file filename.c.
|
extern |
Remove the last extension from file name.
s | Pointer to string |
Definition at line 34 of file filename.c.
Referenced by filenameRmExtensions(), tpcHtmlUsage(), tpcPrintBuild(), tpcPrintUsage(), and tpcProgramName().
|
extern |
Remove all extensions from file name.
s | Pointer to string |
Definition at line 51 of file filename.c.
|
extern |
Remove path from file name.
s | Pointer to string |
Definition at line 13 of file filename.c.
Referenced by tpcHtmlUsage(), tpcPrintBuild(), tpcPrintUsage(), and tpcProgramName().
|
extern |
Case-independent check whether string fname matches string key, which may contain wildcards ? and *.
fname | filename that is evaluated |
key | key string which may contain wildcards '?' and '*' |
Definition at line 100 of file filename.c.
Referenced by dftFormat(), dftWrite(), and rnameMatch().
|
extern |
Check if string fname matches string key, which may contain wildcards ? and *.
fname | filename that is evaluated |
key | key string which may contain wildcards '?' and '*' |
Definition at line 66 of file filename.c.
Referenced by fncasematch(), and fnmatch().
|
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. This string is not modified. |
date | Pointer to allocated struct tm where the date is written |
Definition at line 377 of file datetime.c.
Referenced by resRead().
|
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 This string is not modified. |
date | Pointer to allocated struct tm where date and time is written |
verbose | Verbose level; if <=0, then nothing is printed into stdout |
Definition at line 322 of file datetime.c.
Referenced by ecat7EditMHeader(), fitRead(), resRead(), and selectEcat931Calibrationfile().
|
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 22 of file datetime.c.
Referenced by ctime_r_int(), ecat63AddImg(), ecat63WriteAllImg(), ecat7EditMHeader(), ecat7ReadMainheader(), ecatCopy7to63mainheader(), imgSetAnalyzeHeader(), imgSetEcat63MHeader(), imgWriteAnalyze(), res2ift(), sifWrite(), time_to_tm(), and timegm().
|
extern |
Calculates the isotope lambda from specified halflife.
halflife | halflife time value |
Definition at line 84 of file halflife.c.
Referenced by atnMake(), dftDecayCorrection(), img2sif(), imgDecayCorrection(), imgSetDecayCorrFactors(), and noiseSD4Simulation().
|
extern |
Check that isotope code, e.g. F-18, is in valid format, containing '-' and in this order. Returns the correct isotope code.
isocode | Pointer to string "C-11", "11c" etc; contents of this string is not changed, and this is not returned in any case |
Definition at line 141 of file halflife.c.
Referenced by hlFromIsotope(), and sif2dft().
|
extern |
Identify the isotope from the specified isotope code string and return the halflife (min). This function checks the validity of the isotope string using hlCorrectIsotopeCode(), but does not change it in any way.
isocode | Pointer to string "C-11", "18f" etc. This argument is not changed. |
Definition at line 55 of file halflife.c.
Referenced by dftDecayCorrection(), imgReadAnalyzeHeader(), imgReadModelingData(), imgReadNiftiHeader(), noiseSD4SimulationFromDFT(), and sif2img().
|
extern |
Isotope code as a string, based on isotope list number.
isotope | index of PET isotope in the list in halflife.c |
Definition at line 36 of file halflife.c.
Referenced by dftDecayCorrection(), and imgIsotope().
|
extern |
Identify the isotope based on its halflife (in minutes).
halflife | Half-life in minutes |
Definition at line 195 of file halflife.c.
Referenced by dftDecayCorrection(), imgBranchingCorrection(), and imgIsotope().
|
extern |
Calculate the decay correction factor for specified isotope lambda.
lambda | Negative lambda removes decay correction |
frametime | Frame start time, or mid time if framedur<=0 |
framedur | If unknown, set <0 and give mid time for frametime |
Definition at line 98 of file halflife.c.
Referenced by atnMake(), dftDecayCorrection(), img2sif(), and noiseSD4Simulation().
|
extern |
Calculate the decay correction factor for specified isotope lambda. Version for floats (mainly image data).
lambda | Negative lambda removes decay correction |
frametime | Frame start time, or mid time if framedur<=0 |
framedur | If unknown, set <0 and give mid time for frametime |
Definition at line 118 of file halflife.c.
Referenced by imgDecayCorrection(), and imgSetDecayCorrFactors().
|
extern |
Scramble characters in ASCII range 32-126 using the Vigenere Cipher. Other characters are discarded.
string | Original string to be encrypted/decrypted |
key | Keyword string |
out | Encrypted/decrypted string |
decrypt | Set to 1 when decrypting, or to 0 when encrypting |
Definition at line 23 of file idcrypt.c.
|
extern |
Remove the specified item from IFT.
ift | Pointer to IFT structure. |
item | Index [0..keyNr-1] of key and value to delete. |
verbose | Verbose level; if zero, then only warnings are printed into stderr |
Definition at line 169 of file ift.c.
Referenced by ecat7CopyHeadersNoQuant().
Make a copy (duplicate) of IFT structure.
ift1 | Pointer to IFT structure to be copied. |
ift2 | Pointer to initiated IFT structure; any previous contents are deleted. |
verbose | Verbose level; if zero, then only warnings are printed into stderr |
Definition at line 235 of file ift.c.
Referenced by imgCopyhdr().
|
extern |
Free memory allocated for IFT. All contents are destroyed.
ift | Pointer to target IFT structure. |
Definition at line 60 of file ift.c.
Referenced by cptReadOne(), defRead(), dftRead(), ehdrEmpty(), ematEmpty(), hrrtMakeCalHdr(), iftdup(), iftRead(), iftReadValue(), imgEmpty(), imgReadMicropetFrame(), imgReadMicropetHeader(), interfileIsHeader(), irdRead(), niftiHeaderToIFT(), readEcat931Calibrationfile(), res2ift(), tsvRead(), vrdRead(), and xelRead().
|
extern |
Find the Nth item of IFT where the specified string is found in the key. Comparison is case sensitive.
ift | Pointer to IFT structure. |
str | Pointer to the case-sensitive (partial) key string. |
n | Nth (1..keyNr-1) incidence of value is searched. |
verbose | Verbose level; if zero, then only warnings are printed into stderr |
Definition at line 84 of file iftsrch.c.
Referenced by cptReadOne().
|
extern |
Find the Nth item of IFT where the specified string is found in the value. Comparison is case sensitive.
ift | Pointer to IFT structure. |
str | Pointer to the case-sensitive (partial) value string. |
n | Nth (1..keyNr-1) incidence of value is searched.. |
verbose | Verbose level; if zero, then only warnings are printed into stderr. |
Definition at line 120 of file iftsrch.c.
Referenced by cptReadOne(), and xelRead().
|
extern |
Find the key in the IFT and return the index [0..keyNr-1]. Key is case insensitive.
ift | Pointer to IFT structure. |
key | Pointer to the key string; contents are replaced by the correct key string. |
verbose | Verbose level; if zero, then only warnings are printed into stderr |
Definition at line 15 of file iftsrch.c.
Referenced by cptReadOne(), dft_fill_hdr_from_IFT(), ecat7CopyHeadersNoQuant(), imgGetMicropetHeader(), irdRead(), niftiHeaderFromIFT(), tsvRead(), vrdRead(), and xelRead().
|
extern |
Finds the specified key string from IFT structure, and reads the corresponding value as double.
ift | Pointer to existing IFT. |
si | Index [0..keyNr-1] from which the search is started. |
key | Pointer to the key string; search is case-insensitive. |
value | Pointer to double variable where value is written; NaN is written in case of an error. |
verbose | Verbose level; if zero, then only warnings are printed into stderr. |
Definition at line 268 of file iftsrch.c.
Referenced by hrrtMakeCalHdr().
|
extern |
Finds the specified key string from IFT structure, and reads the corresponding value as float.
ift | Pointer to existing IFT. |
si | Index [0..keyNr-1] from which the search is started. |
key | Pointer to the key string; search is case-insensitive. |
value | Pointer to float variable where value is written; NaN is written in case of an error. |
verbose | Verbose level; if zero, then only warnings are printed into stderr. |
Definition at line 228 of file iftsrch.c.
Referenced by imgGetMicropetHeader(), imgReadMicropetFrame(), niftiHeaderFromIFT(), and upetReadImagedata().
|
extern |
Finds the specified key in the IFT, starting from specified index. Key is case insensitive.
ift | Pointer to existing IFT. |
si | Index [0..keyNr-1] from which the search is started. |
key | Pointer to the key string; search is case-insensitive. |
verbose | Verbose level; if zero, then only warnings are printed into stderr. |
Definition at line 156 of file iftsrch.c.
Referenced by hrrtMakeCalHdr(), and interfileIsHeader().
|
extern |
Finds the index with specified key and value in the IFT, starting from specified index. Key and value are case insensitive.
ift | Pointer to existing IFT. |
si | Index [0..keyNr-1] from which the search is started. |
key | Pointer to the key string; search is case-insensitive. |
value | Pointer to the value string; search is case-insensitive. |
verbose | Verbose level; if zero, then only warnings are printed into stderr. |
Definition at line 191 of file iftsrch.c.
Referenced by imgReadMicropetFrame(), and upetReadImagedata().
|
extern |
Finds the specified key string from IFT structure, and reads the corresponding value as int.
ift | Pointer to existing IFT. |
si | Index [0..keyNr-1] from which the search is started. |
key | Pointer to the key string; search is case-insensitive. |
value | Pointer to int variable where value is written; -9999 is written in case of an error. |
verbose | Verbose level; if zero, then only warnings are printed into stderr. |
Definition at line 309 of file iftsrch.c.
Referenced by hrrtMakeCalHdr(), imgGetMicropetHeader(), niftiHeaderFromIFT(), and upetReadImagedata().
|
extern |
Find the nr of occurrences of the specified key in the IFT. Key is case insensitive.
ift | Pointer to existing IFT |
key | Pointer to the key string |
verbose | Verbose level; if zero, then only warnings are printed into stderr |
Definition at line 350 of file iftsrch.c.
|
extern |
Find the Nth key with similar name in the IFT and return the index [0..keyNr-1]. Key is case insensitive.
ift | pointer to IFT structure. |
key | Pointer to the key string; contents are replaced by the correct key string. |
n | Nth (1..) incidence of key is searched. |
verbose | Verbose level; if zero, then only warnings are printed into stderr. |
Definition at line 48 of file iftsrch.c.
Referenced by dft_fill_hdr_from_IFT(), and tsvRead().
|
extern |
Initiate IFT structure. This should be called once before first use.
ift | Pointer to target IFT structure. |
Definition at line 45 of file ift.c.
Referenced by cptReadOne(), dftRead(), ehdrInitiate(), ematInitiate(), hrrtMakeCalHdr(), iftReadValue(), imgInit(), interfileIsHeader(), irdRead(), readEcat931Calibrationfile(), tsvRead(), vrdRead(), and xelRead().
|
extern |
Add specified key and its value to the IFT.
Also comment type (first character pointed to) can be added. Either key or value can be empty, but not both of them.
ift | Pointer to initiated IFT; previous contents are not changed |
key | Key string; can be empty ("" or NULL) |
value | Value string; can be empty ("" or NULL) |
cmt_type | Pointer to comment character, e.g. '#' or ';' or '!'; can be empty ("" or NULL) |
verbose | Verbose level; if zero, then only warnings are printed into stderr |
Definition at line 82 of file ift.c.
Referenced by defRead(), ecat7ImageheaderToIFT(), ecat7MHeaderToIFT(), ecat7ScanheaderToIFT(), hrrtMakeCalHdr(), iftdup(), iftPutDouble(), iftRead(), niftiHeaderToIFT(), and res2ift().
|
extern |
Add specified key and its floating point (double) value to the IFT.
Also comment type (first character pointed to) can be added. Key can be empty.
ift | Pointer to initiated IFT; previous contents are not changed |
key | Key string; can be empty ("" or NULL) |
value | Value as double |
cmt_type | Pointer to comment character, e.g. '#' or ';' or '!'; can be empty ("" or NULL) |
verbose | Verbose level; if zero, then only warnings are printed into stderr |
Definition at line 145 of file ift.c.
Referenced by hrrtMakeCalHdr().
|
extern |
Read IFT file keys and values. Previous contents of IFT are preserved.
This function can read the initial ASCII part of files that contain also binary data.
ift | Pointer to initiated but empty IFT structure. |
filename | Input file name. |
is_key_required | 0=key name is not required, 1=only lines with key and equals sign are read. |
verbose | Verbose level; if zero, then only warnings are printed into stderr |
Definition at line 24 of file iftfile.c.
Referenced by cptReadOne(), dftRead(), hrrtMakeCalHdr(), iftReadValue(), interfileIsHeader(), irdRead(), readEcat931Calibrationfile(), tsvRead(), vrdRead(), and xelRead().
|
extern |
Read value string from IFT file.
filename | File name. |
keystr | String to search for in the key. If NULL, or key containing the string is not found, then if there is only one value in the file, pointer to that is returned. |
verbose | Verbose level; if zero, then only warnings are printed into stderr |
Definition at line 180 of file iftfile.c.
|
extern |
Replaces specified value in IFT with a new value.
ift | Pointer to IFT structure. |
item | Index [0..keyNr-1] of key and value. |
value | Value string; can be empty ("" or NULL). |
verbose | Verbose level; if zero, then only warnings are printed into stderr |
Definition at line 206 of file ift.c.
|
extern |
Sets IFT status
ift | Pointer to target IFT structure. |
status | New status value. |
Definition at line 29 of file ift.c.
Referenced by defRead(), iftDeleteItem(), iftFindNthKey(), iftFindNthValue(), iftGet(), iftGetDoubleValue(), iftGetFloatValue(), iftGetFrom(), iftGetFullmatchFrom(), iftGetIntValue(), iftGetKeyNr(), iftGetNth(), iftPut(), iftRead(), iftReplaceNthValue(), iftWrite(), and iftWriteItem().
|
extern |
Write all keys and values.
ift | Pointer to IFT structure. |
filename | Output filename, or string "stdout" to print on console. |
verbose | Verbose level; if zero, then only warnings are printed into stderr |
Definition at line 282 of file iftfile.c.
Referenced by cptReadOne(), ecat7MainheaderFromIFT(), ecat7ReadHeaders(), hrrtMakeCalHdr(), and niftiHeaderFromIFT().
|
extern |
Write one item in IFT to the specified file pointer.
ift | Pointer to initiated but empty IFT structure. |
item | Index [0..keyNr-1] of key and value to write. |
fp | Output file pointer. |
verbose | Verbose level; if zero, then only warnings are printed into stderr |
Definition at line 221 of file iftfile.c.
Referenced by iftWrite().
|
extern |
Add one integer to INTEGER_LIST.
l | Pointer to initiated list |
v | Integer value to add |
ifnew | Add integer to the list only if it is new (0=no, 1=yes) |
Definition at line 190 of file intex.c.
Referenced by imgMaskRoiNr(), integerListAddFromString(), and integerListExpandFromString().
|
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 INTEGER_LIST struct; previous contents are preserved. |
ifnew | Add integer to the list only if it is new (0=no, 1=yes) |
Definition at line 242 of file intex.c.
|
extern |
Free the memory allocated in the INTEGER_LIST struct.
l | Pointer to INTEGER_LIST struct |
Definition at line 175 of file intex.c.
Referenced by imgMaskRoiNr().
|
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 INTEGER_LIST struct; previous contents are preserved. |
ifnew | Add integer to the list only if it is new (0=no, 1=yes) |
Definition at line 278 of file intex.c.
|
extern |
Call this (once) before using INTEGER_LIST struct for the first time.
l | Pointer to INTEGER_LIST struct |
|
extern |
Sort INTEGER_LIST
l | Pointer to INTEGER_LIST struct |
Definition at line 219 of file intex.c.
Referenced by imgMaskRoiNr().
|
extern |
|
extern |
Existing list is freed and all data is cleared. Deprecated. Expanded integers are listed in list.i[] in increasing order.
text | Integer expressions to be expanded, e.g. 0-8,12,34-28 |
list | Pointer for int list data |
Definition at line 43 of file intex.c.
|
extern |
Merges two lists and returns the result. (the originals are not touched) Duplicate entries are removed. Deprecated.
list1 | The first list |
list2 | The second list |
Definition at line 124 of file intex.c.
|
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 205 of file doubleutil.c.
Referenced by imgGaussianFIRFilter().
|
extern |
Check if 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 checked; not changed in this routine |
Definition at line 146 of file datetime.c.
Referenced by dcmDA2intl(), get_date(), and isdatetime().
|
extern |
Check if specified string contains date in correct format (DD.MM.YYYY or DD/MM/YYYY). String must start with date, but any contents after it is ignored.
str | String 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. |
Definition at line 168 of file datetime.c.
Referenced by get_date(), and isdatetime().
|
extern |
Check if specified string contains date in correct format (DD.MM.YY or DD/MM/YY). String must start with date, but any contents after it is ignored.
str | String 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. |
Definition at line 199 of file datetime.c.
Referenced by get_date(), and isdatetime().
|
extern |
Check if specified integer contains date in format YYYYMMDD.
dateint | Integer to be checked; not changed in this routine |
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 230 of file datetime.c.
Referenced by ecat7ReadMainheader().
|
extern |
Check if specified string contains date and time in correct format (YYYY-MM-DD hh:mm:ss, DD.MM.YYYY hh:mm:ss, or DD.MM.YY hh:mm:ss). String must start with date, but any contents after time is ignored.
str | String to be checked; not changed in this routine |
intdate | Pointer to allocated string where date and time is written in international format (YYYY-MM-DD hh:mm:ss); enter NULL, if not needed. |
Definition at line 280 of file datetime.c.
Referenced by dcmDT2intl(), and get_datetime().
|
extern |
Check for leap year.
year | Year |
Definition at line 423 of file datetime.c.
Referenced by time_to_tm().
|
extern |
Check if 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 checked; not changed in this routine |
Definition at line 259 of file datetime.c.
Referenced by dcmTM2intl(), iftRead(), and isdatetime().
|
extern |
Calculates the number of leap years between year1 and year2.
year1 | Year 1 |
year2 | Year 2 |
Definition at line 435 of file datetime.c.
Referenced by time_to_tm().
|
extern |
|
extern |
Check whether current platform uses little endian byte order. See H&S Sec. 6.1.2 pp. 163-4.
Definition at line 14 of file swap.c.
Referenced by anaReadHeader(), anaReadImagedata(), anaWriteHeader(), dcmFileWrite(), dcmitemGetInt(), dcmitemGetReal(), dcmReadFileTag(), dcmReadFileVL(), dcmReadFileVRVL(), dcmValueString(), dcmWriteFileTag(), dcmWriteFileVRVL(), ecat63Create(), ecat63Matenter(), ecat63ReadAttnheader(), ecat63ReadImageheader(), ecat63ReadMainheader(), ecat63ReadMatdata(), ecat63ReadMatlist(), ecat63ReadNormheader(), ecat63ReadScanheader(), ecat63WriteAttnheader(), ecat63WriteImageheader(), ecat63WriteMainheader(), ecat63WriteMatdata(), ecat63WriteNormheader(), ecat63WriteScanheader(), ecat7Create(), ecat7EnterMatrix(), ecat7Read2DNormheader(), ecat7Read2DScanheader(), ecat7ReadAttenheader(), ecat7ReadImageheader(), ecat7ReadMainheader(), ecat7ReadMatlist(), ecat7ReadMatrixdata(), ecat7ReadNormheader(), ecat7ReadPolmapheader(), ecat7ReadScanheader(), ecat7Write2DNormheader(), ecat7Write2DScanheader(), ecat7WriteAttenheader(), ecat7WriteImageheader(), ecat7WriteMainheader(), ecat7WriteMatrixdata(), ecat7WriteNormheader(), ecat7WritePolmapheader(), ecat7WriteScanheader(), hrrtMakeCalHdr(), imgSetNiftiHeader(), imgWriteAnalyze(), imgWriteAnalyzeFrame(), niftiReadHeader(), niftiReadImagedata(), niftiWriteHeader(), tiffWriteImg(), and upetReadImagedata().
|
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 46 of file datetime.c.
|
extern |
Division for long integers.
a | A/b |
b | a/B |
Definition at line 409 of file datetime.c.
Referenced by leaps_between(), and time_to_tm().
|
extern |
Return pointer to string describing the calibration data units.
cunit | index of PET_data units_string[]. |
Definition at line 211 of file petunits.c.
Referenced by csv2dft_linkset(), dftGetPmodTitle(), and imgUnit().
|
extern |
Identify the specified units string as PET data unit.
Definition at line 74 of file petunits.c.
Referenced by csv2dft_a(), csv2dft_linkset(), cunit_check_dft_vs_img(), dftGetPmodTitle(), dftReadinput(), dftReadModelingData(), dftReadReference(), dftSetComments(), dftTimeIntegral(), dftUnitConversion(), and dftWrite().
|
extern |
Return pointer to string describing the time unit.
tunit | index of PET_time unit_string[]. |
Definition at line 226 of file petunits.c.
Referenced by check_times_dft_vs_dft(), csv2dft_linkset(), dftInterpolateForIMG(), dftMatchTimeunits(), dftSetComments(), dftWrite(), dftWriteHTML(), fitWrite(), imgReadModelingData(), res_allocate_with_dft(), and tsvRead().
|
extern |
Identifies the specified string as PET time (x axis) units.
Definition at line 187 of file petunits.c.
Referenced by csv2dft_linkset(), dft_fill_hdr_from_IFT(), dftGetPmodTitle(), dftRead(), dftTimeunitToDFT(), and fitRead().
|
extern |
Printfs as bit string the 32-bit variable pointed to by buf. Far from being optimized, thus only for testing and development purposes.
buf | Pointer to memory |
Definition at line 133 of file swap.c.
|
extern |
Read list of string tokens from specified file Remember to free the memory of string list.
filename | Name of file to read |
toklist | Pointer to list of strings read and allocated here |
Definition at line 181 of file readfile.c.
|
extern |
Construct full TAC name from up to three subnames.
rname | Pointer to string of length max_rname_len, in where the full name will be placed |
max_rname_len | Length of full TAC name, not including null char |
name1 | Pointer to 1st subname (anatomical region); NULL if not available |
name2 | Pointer to 1st subname (usually hemisphere); NULL if not available |
name3 | Pointer to 1st subname (usually image plane); NULL if not available |
space | Spacing character, for example ' ', '_', or '-' |
Definition at line 189 of file rname.c.
Referenced by dftRead(), dftRNameSimplify(), fitRead(), and resRead().
|
extern |
Test whether region name or number matches with a test string. Test string can contain wildcards. If test string contains only one subname, it is tested against whole rname. If it contains 2-3 subnames, those are tested against the corresponding tokens in rname. Subname '.' stands for empty name. Number is tested only if test string contains one token of all digits.
rname | Region name which is tested |
rnr | Region number (1..) |
test_str | Test string |
Definition at line 144 of file rname.c.
Referenced by dftSelectRegions(), and resSelectRegions().
|
extern |
Region name may contain dots marking non-existing identification of hemisphere or image plane etc. This function removes the dots and extra space characters.
rname1 | String which contains the original region name; the modified string is written in next string, if pointer to it is given next. |
rname2 | Pointer to previously allocated string, into which the modified region name will be written. Enter NULL, if previous string is to be modified instead. |
Definition at line 99 of file rname.c.
Referenced by plot_fit_svg(), plot_fitrange_svg(), plot_svg(), res2ift(), and rnameSplit().
|
extern |
Split region name into 1-3 subparts of given max length.
rname | Region name to split (string is not edited) |
name1 | Pointer to 1st subname (anatomical region) |
name2 | Pointer to 2nd subname (usually hemisphere) |
name3 | Pointer to 3rd subname (usually image plane) |
max_name_len | Max length of subnames, excluding terminal null |
Definition at line 14 of file rname.c.
Referenced by csv2dft_a(), csv2dft_b(), csv2dft_linkset(), csv2dft_mat(), dft_fill_hdr_from_IFT(), dftGetPmodTitle(), resRead(), and rnameMatch().
|
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 241 of file rname.c.
|
extern |
Sort the given double array into ascending or descending order.
data | Pointer to data array of size n |
n | Length of data array |
order | Ascending (0) or descending (<>0) order |
Definition at line 267 of file doubleutil.c.
|
extern |
Sort the given double list into ascending or descending order.
Sort the given float array into ascending or descending order.
data | Pointer to data array of size n |
n | Length of data array |
order | Ascending (0) or descending (<>0) order |
Definition at line 76 of file imgqntls.c.
|
extern |
Put a string in STR_TOKEN_LIST.
lst | List that has to be initialized beforehand. |
new_item | String that is added to list. |
Definition at line 42 of file readfile.c.
Referenced by str_token_list_read(), and textfileReadLines().
|
extern |
Remove the specified string item from the STR_TOKEN_LIST.
lst | List that has to be initialized beforehand. |
item | Item number to remove (1..item_nr). |
Definition at line 70 of file readfile.c.
Referenced by sifRead().
|
extern |
Free memory allocated for STR_TOKEN_LIST. All contents are destroyed.
lst | Pointer to list to be emptied. |
Definition at line 26 of file readfile.c.
Referenced by roi_read(), sifRead(), str_token_list_read(), and textfileReadLines().
|
extern |
Initiate STR_TOKEN_LIST structure. This should be called once before first use.
lst | Pointer to list to be initiated. |
Definition at line 13 of file readfile.c.
Referenced by roi_read(), and sifRead().
|
extern |
Read all string tokens from text file into STR_TOKEN_LIST. List needs to be initialized. Previous contents are deleted.
filename | Name of text file to read |
lst | Token list is allocated by this function. |
Definition at line 93 of file readfile.c.
|
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 279 of file strext.c.
Referenced by cunitFromFilename(), dftFormat(), iftReadValue(), and resWriteHTML_table().
|
extern |
Count how many times specified characters are found in a string. Search is case-sensitive.
str1 | String to search for characters; not modified. |
str2 | String containing characters which are searched for; not modified. |
Definition at line 126 of file strext.c.
Referenced by rnameSplit().
|
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 402 of file strext.c.
|
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 343 of file strext.c.
Referenced by csvRead().
|
extern |
Encode special characters for XML, including SVG.
s | Pointer to the string to be encoded. |
Definition at line 364 of file strext.c.
Referenced by dftWriteHTML(), and resWriteHTML_table().
|
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 206 of file strext.c.
Referenced by anaExists(), backupExistingFile(), dftRead(), and hrrtMakeCalHdr().
|
extern |
Safer version of strncpy or strcpy.
At most dstsize-1 characters are copied from the source string to the 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 245 of file strext.c.
Referenced by anaEditHeader(), anaExists(), backupExistingFile(), csv2dft_b(), csv2dft_mat(), dcmAddItem(), dcmFileRead(), dft_fill_hdr_from_IFT(), dftAllocateWithIMG(), dftRead(), dftWrite(), ecat63AddImg(), ecat63EditMHeader(), ecat63ReadAllToImg(), ecat63ReadPlaneToImg(), ecat63WriteAllImg(), ecat7EditMHeader(), ecat7EditVHeader(), ecatCopy63to7mainheader(), ecatCopy7to63mainheader(), fitRead(), hrrtMakeCalHdr(), img2sif(), imgGetAnalyzeHeader(), imgGetEcat63MHeader(), imgGetEcat7MHeader(), imgGetMicropetSIF(), imgReadAnalyze(), imgReadAnalyzeHeader(), imgReadNiftiHeader(), imgSetEcat63MHeader(), imgSetEcat7MHeader(), imgSetNiftiHeader(), imgWriteAnalyze(), niftiCreateFNames(), niftiExists(), niftiHeaderToIFT(), resRead(), selectEcat931Calibrationfile(), sif2img(), strncpyCleanSpaces(), strTokenDup(), strTokenNCpy(), studynr_from_fname2(), studynr_in_fname(), upetExists(), and xelRead().
|
extern |
Copy str2 to str1, removing any quotation marks around the string, and making sure that string fits to str2.
str1 | Pointer to pre-allocated result string with length of at least maxlen characters, including NULL character |
str2 | Pointer to the original string; not changed in this function |
maxlen | Max length of str1, including the end NULL |
Definition at line 52 of file quots.c.
Referenced by upetHeaderReadParameter().
|
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 308 of file strext.c.
Referenced by roi_read(), roiRead(), and strCleanSpaces().
|
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 181 of file strext.c.
Referenced by csv2dft_mat(), dcmAddItem(), dcmDA2intl(), dcmDT2intl(), dcmFileRead(), dcmFileWrite(), dcmSOPIdentify(), dcmSOPUIDName(), dcmTM2intl(), dcmTrUID(), dftWrite(), irdRead(), sifRead(), strlcat(), and tpcHtmlUsage().
|
extern |
This function searches the given string for a string representation of numerical value, possibly with decimal and exponent part. Returns also pointer to the string right after where the numerical value ended, and from where the next number can be searched. Return Returns pointer to start of the next string, or NULL if not found.
str | Pointer to string where numerical values are searched; not changed. |
nxtp | Obligatory pointer to string pointer, which will be set to point to the first character after value string, or to NULL if string ends. |
Definition at line 134 of file decpoint.c.
|
extern |
Replace certain characters in string with another character.
str | 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 159 of file strext.c.
Referenced by dftWrite(), fitRead(), roi_read(), roiRead(), and strCleanForXML().
|
extern |
The strstr_noquotation() function returns a pointer to the first occurrence in the string pointed to by str1, excluding parts that are inside quotation marks "" or '', of the string pointed to by str2.
str1 | Pointer to string to be searched |
str2 | Pointer to string with quotation marks |
Definition at line 17 of file quots.c.
Referenced by iftRead().
|
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 89 of file strext.c.
Referenced by fitRead(), and textfileReadLines().
|
extern |
The strTokenNCpy() function copies the i'th token in the string pointed to by str1 into string pointed to by str3. The characters making up the string pointed to by str2 are the delimiters that determine the token.
str1 | String from where tokens are searched; not modified in any way. |
str2 | String containing character delimiters. |
i | Token number to copy (1..nr of tokens). |
str3 | String array into where the token is copied; string will be null terminated. |
count | Length of str3, including terminal null |
Definition at line 45 of file strext.c.
Referenced by fitRead(), integerListAddFromString(), integerListExpandFromString(), pxlRead(), resRead(), and roi_read().
|
extern |
The strTokenNr() function returns the number of tokens in the string pointed to by str1. The characters making up the string pointed to by str2 are the delimiters that determine the token.
str1 | String from where tokens are calculated; not modified in any way. |
str2 | String containing character delimiters. |
Definition at line 17 of file strext.c.
Referenced by fitRead(), integerListAddFromString(), integerListExpandFromString(), pxlRead(), resRead(), and roi_read().
|
extern |
Count how many upper case characters are found in string.
s | String to search for upper case characters; not modified. |
Definition at line 146 of file strext.c.
Referenced by rnameSplit().
|
extern |
Extract study number (max MAX_STUDYNR_LEN chars) from filename. This function removes initial zeroes from the number part, and converts uppercase letters to lowercase, if necessary.
fname | Filename may include path. Filename is not modified. |
studynr | Pointer for the resulting study number. Memory (>=MAX_STUDYNR_LEN+1 chars) for it must be allocated before calling this. |
Definition at line 119 of file studynr.c.
Referenced by cptReadOne(), dftRead(), imgMicropetCTToEcat7(), imgMicropetPETToEcat7(), resFName2study(), resRead(), tsvRead(), and xelRead().
|
extern |
Extract study number (max MAX_STUDYNR_LEN chars) from filename.
This function removes initial zeroes from the number part, and converts uppercase letters to lowercase, if necessary.
fname | Filename, which may include the path. Filename is not modified. |
studynr | Pointer for the resulting study number. Memory (>=MAX_STUDYNR_LEN+1 chars) must be allocated before calling this. |
force | Validity of studynr is verified (0) or not verified (1) |
Definition at line 67 of file studynr.c.
Referenced by imgGetMicropetHeader(), and studynr_from_fname().
|
extern |
Find study number (max MAX_STUDYNR_LEN chars) inside filename; Study number must contain 1-5 letters followed by 1-5 digits, if such string is not found then error code is returned.
Initial zeroes are removed if necessary and uppercase letters are changed to lowercase.
fname | Filename may include path. Filename is not modified. |
studynr | Pointer to string (>=MAX_STUDYNR_LEN+1 chars) where the resulting study number is written. |
Definition at line 18 of file studynr.c.
Referenced by studynr_from_fname2().
|
extern |
Check whether two valid study numbers are the same. If either of study numbers is shorter than the other, the end parts are compared; thus study numbers that are changed by SPM can be matched. Argument strings are not modified.
studynr1 | compared number |
studynr2 | compared number |
Definition at line 142 of file studynr.c.
|
extern |
Remove zeroes from the number part of the PET study number.
studynr | modified study number. |
Definition at line 211 of file studynr.c.
Referenced by studynr_from_fname2(), and studynr_in_fname().
|
extern |
Convert the PET study number letters to lowercase. Conversion is not done to non-valid study number.
studynr | modified study number. |
Definition at line 233 of file studynr.c.
Referenced by studynr_from_fname2(), and studynr_in_fname().
|
extern |
Check that the argument string is a valid TPC study number.
Valid study number here is defined as containing 1-5 letters (upper- or lowercase) followed by at least 1 digit, with total length of max 10 characters.
studynr | Evaluated study number; not modified. |
Definition at line 196 of file studynr.c.
Referenced by ecat63ReadAllToImg(), ecat63ReadPlaneToImg(), imgGetEcat63MHeader(), imgGetEcat7MHeader(), and studynr_from_fname2().
|
extern |
Check that the argument string is a valid TPC study number.
Valid study number here is defined as containing 1-5 letters (upper- or lowercase) followed by at least 1 digit, with total length of max 10 characters.
studynr | String to be evaluated as study number. Not modified here. |
zero_ok | Number part of study number may start with zero (1) or may not (0) |
Definition at line 166 of file studynr.c.
Referenced by studynr_in_fname(), and studynr_validity_check().
|
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 72 of file swap.c.
Referenced by anaReadHeader(), anaReadImagedata(), anaWriteHeader(), dcmFileWrite(), dcmWriteFileTag(), ecat63ReadAttnheader(), ecat63ReadImageheader(), ecat63ReadMainheader(), ecat63ReadMatdata(), ecat63ReadNormheader(), ecat63ReadScanheader(), ecat63rFloat(), ecat63wFloat(), ecat63WriteAttnheader(), ecat63WriteImageheader(), ecat63WriteMainheader(), ecat63WriteMatdata(), ecat63WriteNormheader(), ecat63WriteScanheader(), ecat7Read2DNormheader(), ecat7Read2DScanheader(), ecat7ReadAttenheader(), ecat7ReadImageheader(), ecat7ReadMainheader(), ecat7ReadMatrixdata(), ecat7ReadNormheader(), ecat7ReadPolmapheader(), ecat7ReadScanheader(), ecat7rFloat(), ecat7Write2DNormheader(), ecat7Write2DScanheader(), ecat7WriteAttenheader(), ecat7WriteImageheader(), ecat7WriteMainheader(), ecat7WriteMatrixdata(), ecat7WriteNormheader(), ecat7WritePolmapheader(), ecat7WriteScanheader(), imgWriteAnalyze(), imgWriteAnalyzeFrame(), niftiReadHeader(), niftiReadImagedata(), niftiWriteHeader(), and upetReadImagedata().
|
extern |
Swaps 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 31 of file swap.c.
Referenced by dcmitemGetInt(), dcmitemGetReal(), dcmReadFileTag(), dcmReadFileVL(), dcmReadFileVRVL(), dcmValueString(), dcmWriteFileVRVL(), intExpand(), and swap().
|
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 93 of file swap.c.
Referenced by anaReadHeader(), anaReadImagedata(), anaWriteHeader(), ecat63Create(), ecat63Matenter(), ecat63ReadMatdata(), ecat63ReadMatlist(), ecat63rFloat(), ecat63rInt(), ecat63wFloat(), ecat63wInt(), ecat63WriteMatdata(), ecat7Create(), ecat7EnterMatrix(), ecat7Read2DNormheader(), ecat7Read2DScanheader(), ecat7ReadAttenheader(), ecat7ReadImageheader(), ecat7ReadMainheader(), ecat7ReadMatlist(), ecat7ReadMatrixdata(), ecat7ReadNormheader(), ecat7ReadPolmapheader(), ecat7ReadScanheader(), ecat7rFloat(), ecat7rInt(), ecat7Write2DNormheader(), ecat7Write2DScanheader(), ecat7WriteAttenheader(), ecat7WriteImageheader(), ecat7WriteMainheader(), ecat7WriteMatrixdata(), ecat7WriteNormheader(), ecat7WritePolmapheader(), ecat7WriteScanheader(), hrrtMakeCalHdr(), niftiReadHeader(), niftiReadImagedata(), niftiWriteHeader(), and upetReadImagedata().
|
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 114 of file swap.c.
Referenced by ecat63rFloat(), ecat63wFloat(), and ecat7rFloat().
|
extern |
int roundf(float e) - Rounds up float e to nearest int
e | float value |
Definition at line 20 of file petc99.c.
Referenced by bootstrap(), ecat63AddImg(), ecat63WriteAllImg(), ecat63WriteImageMatrix(), ecat63WriteScanMatrix(), ecat7Write2DScanMatrix(), ecat7WriteImageMatrix(), ecat7WritePolarmapMatrix(), ecat7WriteScanMatrix(), ecatCopy63to7imageheader(), img2svol(), imgMaskRoiNr(), imgSetAnalyzeHeader(), imgVoiMaskTAC(), imgWrite2DEcat7(), imgWriteAnalyze(), imgWriteAnalyzeFrame(), imgWriteEcat63Frame(), imgWriteEcat7(), imgWriteEcat7Frame(), imgWritePolarmap(), roi_onoff(), roiFillGaps(), and tsvRead().
|
extern |
Read all lines from text file into STR_TOKEN_LIST. List needs to be initialized. Previous contents are deleted.
filename | Name of text file to read |
lst | Token list is allocated by this function. |
Definition at line 136 of file readfile.c.
Referenced by roi_read(), and sifRead().
|
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 452 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 threadsafe in Windows.
tm | Pointer to struct tm |
Definition at line 69 of file datetime.c.
Referenced by ecat63Scanstarttime(), ecat63ScanstarttimeToTm(), ecat7EditMHeader(), fitRead(), get_datetime(), imgGetMicropetHeader(), resRead(), sifRead(), tmAdd(), and upetScanStart().
|
extern |
Add given time in seconds to the date and time.
s | Time to add in seconds; can be negative |
d | Pointer to tm struct |
Definition at line 514 of file datetime.c.
|
extern |
Calculate the difference in seconds between two given dates and times.
tm1 | Pointer to tm struct |
tm0 | Pointer to tm struct |
Definition at line 502 of file datetime.c.
Referenced by selectEcat931Calibrationfile().
|
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 213 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 383 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 158 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 40 of file proginfo.c.
|
extern |
Process program name and optionally version into given string from 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 | Length of prname string, including trailing zero |
Definition at line 101 of file proginfo.c.