|
TPCCLIB
|
Header file for libtpcpar. More...
#include "tpcclibConfig.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include "tpcextensions.h"#include "tpccsv.h"#include "tpcift.h"#include "tpcmodels.h"Go to the source code of this file.
Data Structures | |
| struct | PARR |
| struct | PARN |
| struct | PAR |
Enumerations | |
| enum | parformat { PAR_FORMAT_UNKNOWN , PAR_FORMAT_RES , PAR_FORMAT_FIT , PAR_FORMAT_IFT , PAR_FORMAT_CSV_INT , PAR_FORMAT_CSV_UK , PAR_FORMAT_TSV_INT , PAR_FORMAT_TSV_UK , PAR_FORMAT_XML , PAR_FORMAT_HTML , PAR_FORMAT_LAST } |
Functions | |
| void | parInit (PAR *par) |
| void | parrInit (PARR *parr) |
| void | parnInit (PARN *parn) |
| void | parFree (PAR *par) |
| void | parrFree (PARR *parr) |
| int | parAllocate (PAR *par, int parNr, int tacNr) |
| int | parAllocateMore (PAR *par, int parNr, int tacNr) |
| int | parrAllocate (PARR *parr, int parNr) |
| char * | parIsStudyNr (PAR *par) |
| int | parSetStudyNr (PAR *par, const char *s) |
| void | parEnsureNames (PAR *d) |
| int | parIsWSS (PAR *par) |
| int | parIsFitRange (PAR *par) |
| int | parIsModel (PAR *par) |
| int | parSDWithPar (PAR *par, int pi) |
| int | parCLWithPar (PAR *par, int pi) |
| int | parIsFitNr (PAR *par) |
| int | parIsDataNr (PAR *par) |
| int | parDeletePar (PAR *par, int pi) |
| int | parDeleteTAC (PAR *par, int ti) |
| char * | parIsOptcrit (PAR *par) |
| char * | parFormattxt (parformat c) |
| int | parFormatIdentify (const char *s) |
| int | parFormatFromExtension (const char *s) |
| char * | parDefaultExtension (parformat c) |
| int | parWrite (PAR *par, FILE *fp, parformat format, int extra, TPCSTATUS *status) |
| int | parRead (PAR *par, const char *fname, TPCSTATUS *status) |
| void | parListLimits (PAR *par, FILE *fp) |
| int | parWriteLimits (PAR *par, const char *fname, const int verbose) |
| int | parReadLimits (PAR *par, const char *fname, const int verbose) |
| int | parWriteCSV (PAR *par, FILE *fp, parformat format, int extra, TPCSTATUS *status) |
| int | parReadCSV (PAR *par, CSV *csv, IFT *hdr, TPCSTATUS *status) |
| int | parToIFT (PAR *par, IFT *ift, TPCSTATUS *status) |
| int | parWriteIFT (PAR *par, FILE *fp, TPCSTATUS *status) |
| int | parFromIFT (PAR *par, IFT *ift, TPCSTATUS *status) |
| int | parWriteRES (PAR *par, FILE *fp, TPCSTATUS *status) |
| int | parReadRES (PAR *par, CSV *csv, IFT *ift, TPCSTATUS *status) |
| int | parPrintType (PAR *par, int parIndex) |
| int | parWriteFIT (PAR *par, FILE *fp, TPCSTATUS *status) |
| int | parReadFIT (PAR *par, CSV *csv, IFT *ift, TPCSTATUS *status) |
| int | parWriteXML (PAR *par, FILE *fp, TPCSTATUS *status) |
| int | parSelectByAnother (PAR *d1, PAR *d2, int *pn, int *pr, TPCSTATUS *status) |
| int | parCombineTACs (PAR *d1, PAR *d2, TPCSTATUS *status) |
| int | parCompareParameterNames (PAR *d1, PAR *d2, const int i, const int casens, TPCSTATUS *status) |
| int | parCompareParameterUnits (PAR *d1, PAR *d2, const int i, TPCSTATUS *status) |
| int | parCompareTacNames (PAR *d1, PAR *d2, const int i, const int casens, TPCSTATUS *status) |
| int | parCompareParameters (PAR *d1, PAR *d2, const int pi, const int ti, int checkpar, int checksd, int checkcl, const double test_abs, const double test_rel, TPCSTATUS *status) |
| int | parCompareWSS (PAR *d1, PAR *d2, const int ti, const double test_abs, const double test_rel, TPCSTATUS *status) |
| int | parSortByName (PAR *d, TPCSTATUS *status) |
| int | parSelectTACs (PAR *d, const char *region_name, int reset, TPCSTATUS *status) |
| int | parSelectedTACs (PAR *d) |
| int | parSelectParameters (PAR *d, const char *par_name, int reset, TPCSTATUS *status) |
| int | parSelectedParameters (PAR *d) |
| int | parFindParameter (PAR *d, const char *par_name) |
| double | parGetParameter (PAR *d, const char *par_name, const int ti) |
| int | parGetParameterUnit (PAR *d, const char *par_name) |
| void | parValueRange (PAR *d, const int i, double *pmin, double *pmax) |
| int | parExampleTTACs (PAR *d, int type, TPCSTATUS *status) |
| int | parExamplePerfectBolus (PAR *d, TPCSTATUS *status) |
| int | parExampleRadiowaterBolus (PAR *d, TPCSTATUS *status) |
Header file for libtpcpar.
Header file for model parameter library.
Definition in file tpcpar.h.
| enum parformat |
PAR file format codes;
| Enumerator | |
|---|---|
| PAR_FORMAT_UNKNOWN | Unknown format. |
| PAR_FORMAT_RES | Model result format of Turku PET Centre. |
| PAR_FORMAT_FIT | Function fit format of Turku PET Centre. |
| PAR_FORMAT_IFT | Interfile-type data (supported for writing). |
| PAR_FORMAT_CSV_INT | International CSV. |
| PAR_FORMAT_CSV_UK | UK CSV. |
| PAR_FORMAT_TSV_INT | International TSV (comma as decimal separator). |
| PAR_FORMAT_TSV_UK | UK TSV (point as decimal separator). |
| PAR_FORMAT_XML | XML format (currently not supported). |
| PAR_FORMAT_HTML | HTML table format (currently not supported). |
| PAR_FORMAT_LAST | End of list. |
Definition at line 27 of file tpcpar.h.
|
extern |
Allocate memory for PAR data.
Any previous contents are deleted.
| par | Pointer to initiated PAR struct data; any old contents are deleted. tacNr and parNr inside the struct are set to or kept at zero. |
| parNr | Nr of parameters to allocate |
| tacNr | Nr of parameter sets (TACs) to allocate |
Definition at line 108 of file par.c.
Referenced by parAllocateWithTAC(), parExamplePerfectBolus(), parExampleRadiowaterBolus(), parExampleTTACs(), parFromIFT(), parReadCSV(), parReadFIT(), and parReadRES().
|
extern |
Allocate more memory for PAR data. Previous contents are preserved.
| par | Pointer to initiated and previously allocated PAR struct data; any old contents are preserved, including tacNr and parNr. |
| parNr | Nr of additional parameters to allocate; if struct contains unused space for requested parameters already, then nothing is done. |
| tacNr | Nr of additional parameter sets (TACs) to allocate; if struct contains unused space for requested parameters already, then nothing is done. |
Definition at line 183 of file par.c.
Referenced by parCombineTACs().
|
extern |
Check if specified parameter has confidence limits in at least one of the regions.
| par | Pointer to parameter data. |
| pi | Index of parameter [0..parNr-1] to check. |
Definition at line 325 of file par.c.
Referenced by parWriteCSV(), and parWriteXML().
Copy parameters from source PAR structure to target structure for TACs that are available in both structures.
| d1 | Pointer to target PAR structure. |
| d2 | Pointer to source PAR structure; not modified. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 99 of file parcomb.c.
|
extern |
Check whether parameter names are the same in two PAR data.
Comparison is very strict, thus the names may need to be preprocessed if this is used for other purpose than SW testing.
| d1 | Pointer to PAR struct. |
| d2 | Pointer to PAR struct. |
| i | Parameter index [0..parNr-1] to compare; enter <0 to verify all. |
| casens | Case-sensitivity: 0=case does not have to match; <>0=case must match. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 28 of file parcomp.c.
|
extern |
Check whether parameter values are the same in two PAR data.
Note that units are ignored here. If either absolute or relative difference is below the limit, the test is reported as passed.
| d1 | Pointer to PAR structure. |
| d2 | Pointer to PAR structure. |
| pi | PAR index [0..parNr-1] to compare; enter <0 to verify all parameters. |
| ti | TAC index [0..tacNr-1] to compare; enter <0 to verify all TACs. |
| checkpar | Check parameter values (1) or do not check (0). |
| checksd | Check parameter SD values (1) or do not check (0). |
| checkcl | Check parameter CL values (1) or do not check (0). |
| test_abs | Limit for accepted absolute difference; obligatory. |
| test_rel | Optional limit for accepted relative difference |2*(x1-x2)/(x1+x2)| ; set to negative value to not test this; in case of zero mean, this test is assumed to fail, but test for absolute difference may still pass. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 237 of file parcomp.c.
Check whether parameter units are the same in two PAR data.
| d1 | Pointer to PAR structure. |
| d2 | Pointer to PAR structure. |
| i | Parameter index [0..parNr-1] to compare; enter <0 to verify all. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 103 of file parcomp.c.
|
extern |
Check whether TAC names are the same in two PAR data.
Comparison is very strict, thus the names may need to be preprocessed if this is used for other purpose than SW testing.
| d1 | Pointer to PAR structure. |
| d2 | Pointer to PAR structure. |
| i | Parameter index [0..tacNr-1] to compare; enter <0 to verify all. |
| casens | Case-sensitivity: 0=case does not have to match; <>0=case must match. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 157 of file parcomp.c.
|
extern |
Check whether fit WSS values are the same in two PAR data.
Note that units are ignored here. If either absolute or relative difference is below the limit, the test is reported as passed.
| d1 | Pointer to PAR structure. |
| d2 | Pointer to PAR structure. |
| ti | TAC index [0..tacNr-1] to compare; enter <0 to verify all TACs. |
| test_abs | Limit for accepted absolute difference; obligatory. |
| test_rel | Optional limit for accepted relative difference |2*(x1-x2)/(x1+x2)| ; set to negative value to not test this; in case of zero mean, this test is assumed to fail, but test for absolute difference may still pass. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 378 of file parcomp.c.
|
extern |
Return pointer to default PAR file name extension, including the dot, based on the PAR format code.
| c | PAR format code |
Definition at line 133 of file pario.c.
|
extern |
Deletes the specified parameter (column) from data.
| par | Pointer to parameter data. |
| pi | Index of parameter [0..parNr-1] to remove. |
Definition at line 478 of file par.c.
Referenced by parReadCSV(), and parReadRES().
|
extern |
Deletes the specified TAC (row) from data.
| par | Pointer to parameter data. |
| ti | Index of TAC [0..tacNr-1] to remove. |
Definition at line 519 of file par.c.
|
extern |
Ensure that PAR struct contains a name for each TAC and parameters. If not available, then index+1 is written as name.
| d | Pointer to parameter data. |
Definition at line 449 of file par.c.
Create PAR data containing function parameters for perfect bolus TAC, starting from zero and approaching zero after the peak.
Creates Gamma variate function (gammav) function with zero delay and with p[1]=1. Maximum is at 1.2 s and max value is 100 kBq/mL. Integral from 0 to infinity is 326.19382 (p[0]*p[2]^2).
| d | Pointer to initiated PAR struct, which will be allocated and filled here; any previous content will be deleted. |
| status | Pointer to status data; enter NULL if not needed |
Definition at line 120 of file parexample.c.
Create PAR data containing function parameters for bolus injection radiowater BTAC.
| d | Pointer to initiated PAR structure, which will be allocated and filled here; any previous content will be deleted. |
| status | Pointer to status data; enter NULL if not needed |
Definition at line 184 of file parexample.c.
Create PAR data containing function parameters for typical-looking PET TTACs for use in algorithm and software tests.
Creates three fengm2 functions with zero delay.
| d | Pointer to initiated PAR struct, which will be allocated and filled here; any previous content will be deleted. |
| type | TTAC type; currently unused |
| status | Pointer to status data; enter NULL if not needed |
Definition at line 24 of file parexample.c.
|
extern |
Searches PAR structure for the given parameter name (case insensitive).
| d | Pointer to PAR structure. |
| par_name | Name of the parameter. Comparison is case-insensitive, but otherwise strict match is required. |
Definition at line 219 of file parselect.c.
|
extern |
Identify the PAR file format from the extension of file name.
| s | Pointer to file name with or without path; mere extension is not accepted here. For example /path/filename.res or filename.fit.bak are accepted. |
Definition at line 102 of file pario.c.
|
extern |
Identify the string representations of the PAR file format.
| s | PAR format as a string. |
Definition at line 74 of file pario.c.
|
extern |
Return pointer to PAR file format description with the format code.
| c | PAR format code. |
Definition at line 59 of file pario.c.
Referenced by parRead(), parWrite(), and parWriteCSV().
|
extern |
Free memory allocated for PAR. All data is cleared.
| par | Pointer to PAR struct |
Definition at line 75 of file par.c.
Referenced by parAllocate(), parFromIFT(), parRead(), parReadCSV(), parReadFIT(), and parReadRES().
Copy parameters data in IFT into PAR struct. IFT contents must be in specific format and order.
| par | Pointer to initiated target PAR struct; any previous contents are deleted |
| ift | Pointer to source IFT struct, contents of which are to be copied |
| status | Pointer to status data; enter NULL if not needed |
Definition at line 207 of file parift.c.
Referenced by parRead().
|
extern |
Searches PAR structure for the given parameter name (case insensitive).
| d | Pointer to PAR structure. |
| par_name | Name of the parameter. Comparison is case-insensitive, but otherwise strict match is required. |
| ti | TAC index [0..tacNr-1]. |
Definition at line 242 of file parselect.c.
|
extern |
Searches PAR structure for the given parameter name (case insensitive).
| d | Pointer to PAR structure. |
| par_name | Name of the parameter. Comparison is case-insensitive, but otherwise strict match is required. |
Definition at line 267 of file parselect.c.
|
extern |
|
extern |
Check if any of parameter sets has dataNr specified.
| par | Pointer to parameter data |
Definition at line 362 of file par.c.
Referenced by parToIFT(), parWriteCSV(), and parWriteXML().
|
extern |
Check if any of parameter sets has fitNr specified.
| par | Pointer to parameter data. |
Definition at line 343 of file par.c.
Referenced by parToIFT(), parWriteCSV(), and parWriteXML().
|
extern |
Check if any of parameter sets has fit range specified.
| par | Pointer to parameter data. |
Definition at line 267 of file par.c.
Referenced by parToIFT(), parWriteCSV(), and parWriteXML().
|
extern |
Check if any of parameter sets has model id specified.
| par | Pointer to parameter data. |
Definition at line 288 of file par.c.
Referenced by parToIFT(), parWriteCSV(), and parWriteXML().
|
extern |
Check if PAR data contains optimality criterion.
| par | Pointer to parameter data. |
Definition at line 381 of file par.c.
|
extern |
Check if PAR data contains study number.
| par | Pointer to parameter data. |
Definition at line 399 of file par.c.
|
extern |
Check if any of parameter sets has WSS.
| par | Pointer to parameter data. |
Definition at line 252 of file par.c.
Referenced by parWriteCSV(), parWriteRES(), and parWriteXML().
|
extern |
List parameter limits in PAR structure.
| par | Pointer to PAR structure, from which the limits are printed. |
| fp | File pointer for the output; usually stdout. |
Definition at line 406 of file pario.c.
|
extern |
Initiate the PARN struct before any use.
| parn | Pointer to PARN |
Definition at line 59 of file par.c.
Referenced by parAllocate(), and parAllocateMore().
|
extern |
Determine whether the parameter should be printed as integer (0), float (1), or exponential (2).
| par | Pointer to the PAR structure. |
| parIndex | Index of the parameter to test. |
Definition at line 584 of file parres.c.
Referenced by parWriteRES().
|
extern |
Allocate memory for PARR data. Any previous contents are deleted.
| parr | Pointer to initiated PARR struct data; any old contents are deleted. |
| parNr | Nr of parameters to allocate. |
Definition at line 150 of file par.c.
Referenced by parAllocate(), and parAllocateMore().
Read parameter file contents into PAR data structure. This function reads RES and FIT format, and some CSV formats.
| par | Pointer to initiated PAR struct where parameter data will be written; any old content is deleted. Call parInit() before first use. |
| fname | Pointer to the file name; this string is not modified. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 232 of file pario.c.
Read parameter data into PAR structure.
| par | Pointer to target PAR structure. |
| csv | Pointer to CSV from which data is read. |
| hdr | Pointer to possible header data, which, if available, is processed and copied to PAR too; enter NULL if not available. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 221 of file parcsv.c.
Referenced by parRead().
Read (old) fit data into PAR struct.
| par | Pointer to target PAR struct. |
| csv | Pointer to source CSV from which data is read. |
| ift | Pointer to source IFT struct which contains whole result file data, in case the data could not be read into CSV. |
| status | Pointer to status data; enter NULL if not needed |
Definition at line 131 of file parfit.c.
Referenced by parRead().
|
extern |
Read the specified file and try to find constraints and tolerance for parameters listed in PAR structure.
| par | Pointer to PAR structure, into which the limits are saved. This must also list the parameter names that are searched for from the file. |
| fname | Input file name. |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 489 of file pario.c.
Read result (RES) data into PAR struct.
| par | Pointer to target PAR struct. |
| csv | Pointer to CSV from which data is read. |
| ift | Pointer to IFT struct which contains whole result file data, in case the data could not be read into CSV (which happens when spaces were used as field separator). |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 268 of file parres.c.
Referenced by parRead().
|
extern |
Free memory allocated for PARR. All data is cleared.
| parr | Pointer to PARR struct |
Definition at line 87 of file par.c.
Referenced by parDeleteTAC(), parFree(), and parrAllocate().
|
extern |
Initiate the PARR struct before any use.
| parr | Pointer to PARR |
Definition at line 41 of file par.c.
Referenced by parAllocate(), parAllocateMore(), parDeleteTAC(), and parrFree().
|
extern |
Check if specified parameter has SD in at least one of the regions.
| par | Pointer to parameter data. |
| pi | Index of parameter [0..parNr-1] to check. |
Definition at line 307 of file par.c.
Referenced by parWriteCSV(), and parWriteXML().
Select parameters and regions in a PAR structure that are available in another PAR structure.
| d1 | Pointer to target PAR structure, in which the PARN and PARR switches are set. |
| d2 | Pointer to PAR structure to which the first is compared to; not modified. |
| pn | Pointer to store the number of available parameters; enter NULL, if not needed. |
| pr | Pointer to store the number of available regions; enter NULL, if not needed. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 22 of file parcomb.c.
Referenced by parCombineTACs().
|
extern |
Get the number of selected parameters (sw!=0) in PAR structure.
| d | Pointer to PAR data |
Definition at line 199 of file parselect.c.
Referenced by parSelectByAnother().
|
extern |
Get the number of selected TACs (sw!=0) in PAR structure.
| d | Pointer to PAR data. |
Definition at line 100 of file parselect.c.
Referenced by parSelectByAnother().
Select the parameter(s) in PAR struct that have matching name or number.
| d | Pointer to PAR structure. |
| par_name | Name of parameter, or parameter numbers (as string, for example '1-3' or '1,2,3'); string can be given with quotation marks. Enter NULL to select all parameters, or empty string to select parameters with empty name (which really should not exist). |
| reset | 1=Non-matching parameters are deselected, 0=Old selections are preserved. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 120 of file parselect.c.
Select the TAC(s) in PAR structure that have matching ID name or number.
| d | Pointer to PAR structure. |
| region_name | Name of TAC, or TAC numbers (as string, for example '1-3' or '1,2,3'); string can be given with quotation marks. Enter NULL to select all TACs, or empty string to select TACs with empty name fields (which really should not exist). |
| reset | 1=Non-matching VOIs are deselected, 0=Old selections are preserved. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 24 of file parselect.c.
|
extern |
Set study number in PAR data, overwriting any previous study number.
| par | Pointer to parameter data. |
| s | Pointer to string containing the study number; enter NULL or "" if you only want to delete studynr in header. |
Definition at line 417 of file par.c.
Sort TACs in alphabetical order by their TAC name.
| d | Pointer to PAR struct. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 30 of file parorder.c.
Copy PAR data into IFT struct.
| par | Pointer to source PAR struct, contents of which are to be copied |
| ift | Pointer to initiated target IFT struct; any previous contents are deleted |
| status | Pointer to status data; enter NULL if not needed |
Definition at line 24 of file parift.c.
Referenced by parWriteIFT().
|
extern |
Finds the min and max parameter value in PAR structure.
| d | Pointer to PAR structure. |
| i | Parameter index [0..parNr-1]. |
| pmin | Pointer to min parameter value; NULL if not needed. |
| pmax | Pointer to max parameter value; NULL if not needed. |
Definition at line 287 of file parselect.c.
Write PAR data into specified file in specified format.
| par | Pointer to PAR struct, contents of which are to be written. |
| fp | Output file pointer. |
| format | File format code; enter PAR_FORMAT_UNKNOWN (0) to write data in the format specified inside the PAR struct. |
| extra | Write (1) or do not write (0) also extra header fields found in PAR; only effective with CSV formats. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 148 of file pario.c.
Write PAR data into specified file pointer in specified CSV or TSV format.
| par | Pointer to source PAR structure, contents of which are to be written. |
| fp | Output file pointer. |
| format | File format code; enter PAR_FORMAT_UNKNOWN (0) to write data in the format specified inside PAR structure. |
| extra | Write (1) or do not write (0) also extra header fields found in PAR. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 26 of file parcsv.c.
Referenced by parWrite().
Write FIT data into specified file pointer in (old) fit file format.
| par | Pointer to PAR struct, contents of which are to be written. |
| fp | Output file pointer. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 27 of file parfit.c.
Referenced by parWrite().
Write PAR data into specified file pointer in IFT format.
| par | Pointer to source PAR struct, contents of which are to be written |
| fp | Output file pointer |
| status | Pointer to status data; enter NULL if not needed |
Definition at line 167 of file parift.c.
Referenced by parWrite().
|
extern |
Write parameter constraints from PAR structure into specified file.
| par | Pointer to PAR structure, from which the limits are to be written. |
| fname | Output file name. Enter 'stdout' to print to stdout. |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout |
Definition at line 432 of file pario.c.
Write PAR data into specified file pointer in result (RES) file format.
| par | Pointer to source PAR struct, contents of which are to be written. |
| fp | Output file pointer. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 26 of file parres.c.
Referenced by parWrite().
Write PAR data into specified file pointer in Excel compatible XML format.
| par | Pointer to source PAR struct, contents of which are to be written |
| fp | File pointer |
| status | Pointer to status data; enter NULL if not needed |
Definition at line 26 of file parxmlio.c.
Referenced by parWrite().