TPCCLIB
|
Functions for processing TAC data in DFT structures. More...
Go to the source code of this file.
Functions | |
void | dftEmpty (DFT *data) |
void | dftInit (DFT *data) |
int | dftSetmem (DFT *data, int frameNr, int voiNr) |
int | dftAddmem (DFT *dft, int voiNr) |
int | dftAdd (DFT *data1, DFT *data2, int voi) |
int | dftSelect (DFT *data, char *name) |
int | dftSelectRegions (DFT *dft, char *region_name, int reset) |
int | dftSelectBestReference (DFT *dft) |
void | dftFrametimes (DFT *data) |
int | dftOverflow (DFT *data) |
int | dftCopyvoi (DFT *data, int from, int to) |
int | dftMovevoi (DFT *dft, int from, int to) |
int | dftDelete (DFT *dft, int voi) |
int | dftCopymainhdr (DFT *dft1, DFT *dft2) |
int | dftCopymainhdr2 (DFT *dft1, DFT *dft2, int ow) |
int | dftCopyvoihdr (DFT *dft1, int from, DFT *dft2, int to) |
int | dftdup (DFT *dft1, DFT *dft2) |
int | dftAllocateWithHeader (DFT *dft, int frameNr, int voiNr, DFT *dft_from) |
int | dftAddnullframe (DFT *data) |
int | dftSort (DFT *data) |
int | dftSortPlane (DFT *data) |
int | dft_nr_of_NA (DFT *dft) |
int | dftNAfill (DFT *dft) |
int | dftMinMax (DFT *dft, double *minx, double *maxx, double *miny, double *maxy) |
int | dftMinMaxTAC (DFT *dft, int tacindex, double *minx, double *maxx, double *miny, double *maxy, int *mini, int *maxi, int *mins, int *maxs) |
int | dftMaxY (DFT *dft, double t1, double t2, double *miny, double *maxy) |
double | dft_kBqMin (DFT *data) |
double | dft_kBqMax (DFT *data) |
int | dftSortByFrame (DFT *dft) |
int | dftDeleteFrameOverlap_old (DFT *dft) |
int | dftDeleteFrameOverlap (DFT *dft) |
int | dftRemoveTimeRange (DFT *dft, double startT, double endT) |
void | dftSetComments (DFT *dft) |
int | dftFillInitialGap (DFT *dft) |
int | dftAddSpaceForFrames (DFT *dft, int nr_to_add) |
void | dftRNameSimplify (DFT *dft, int hemisphere, int place) |
int | dftMeanTAC (DFT *dft, DFT *mean) |
int | dftValidNr (DFT *dft, double tstart, double tstop, int index) |
Variables | |
char | dfterrmsg [64] |
double dft_kBqMax | ( | DFT * | data | ) |
Returns the highest activity value in DFT
data | Pointer to DFT struct |
Definition at line 1148 of file dft.c.
Referenced by dftInterpolateCheckStart().
double dft_kBqMin | ( | DFT * | data | ) |
int dft_nr_of_NA | ( | DFT * | dft | ) |
Check DFT for NA's in sample times and values.
dft | Pointer to DFT struct |
Definition at line 905 of file dft.c.
Referenced by dftInterpolateInto(), dftReadModelingData(), and imgReadModelingData().
Add the specified voi [0,voiNr-1] from data2 to data1. Allocates memory for additional data VOI, if necessary.
data1 | Pointer to DFT struct data |
data2 | Pointer to DFT struct data |
voi | Index of TAC in the 2nd DFT |
Definition at line 188 of file dft.c.
int dftAddmem | ( | DFT * | dft, |
int | voiNr ) |
Adds room for additional VOI TAC(s) into DFT data structure.
Old data is left unchanged.
dft | Pointer to DFT data structure |
voiNr | Nr of additional VOI memory blocks |
Definition at line 107 of file dft.c.
Referenced by dftAdd(), dftInterpolateInto(), dftReadModelingData(), and imgReadModelingData().
int dftAddnullframe | ( | DFT * | data | ) |
Include a frame with time 0, unless one already exists.
data | Pointer to DFT struct |
Definition at line 752 of file dft.c.
int dftAddSpaceForFrames | ( | DFT * | dft, |
int | nr_to_add ) |
Add space for additional frames into DFT, keeping the existing data. frameNr is increased by nr_to_add, but new last frame(s) are empty.
dft | Allocated and data-filled DFT where new frame(s) are added to the end |
nr_to_add | Nr of frames to add |
Definition at line 1465 of file dft.c.
Allocates a DFT structure with specified size, containing no TAC data but header information as available in another DFT struct.
Any existing content of dft2 will be deleted. Dft2 must be initiated.
dft | Pointer to initiated DFT struct which will be allocated here; any previous contents will be deleted. |
frameNr | Nr of frames to be allocated |
voiNr | Nr of planes to be allocated |
dft_from | Pointer to DFT struct where header contents will be copied from |
Definition at line 702 of file dft.c.
Referenced by dftInterpolateForIMG(), dftMeanTAC(), and dftTimeIntegral().
Copy main header info from dft1 to dft2.
dft1 | Pointer to DFT struct from where information is copied |
dft2 | Pointer to DFT struct into which information is copied to |
Definition at line 561 of file dft.c.
Referenced by dftAddSpaceForFrames(), dftAllocateWithHeader(), dftAutointerpolate(), dftDivideFrames(), dftDoubleFrames(), dftdup(), dftFillInitialGap(), dftInterpolate(), extrapolate_monoexp(), and plotdata_as_dft().
Copy main header info from dft1 to dft2. Comments are not copied, because those may contain outdated units and other information.
dft1 | Pointer to DFT struct from where information is copied |
dft2 | Pointer to DFT struct into which information is copied to |
ow | Existing header field content is overwritten (1) or kept (0) |
Definition at line 587 of file dft.c.
Referenced by bfIrr2TCM(), and bfRadiowater().
int dftCopyvoi | ( | DFT * | data, |
int | from, | ||
int | to ) |
Copy VOI data inside DFT data structure from one place to another.
data | Pointer to DFT struct |
from | TAC index |
to | TAC index |
Definition at line 472 of file dft.c.
Referenced by dftRead().
Copy voi header info from dft1.voi[from] to dft2.voi[to].
Definition at line 623 of file dft.c.
Referenced by dftAdd(), dftAddSpaceForFrames(), dftAllocateWithHeader(), dftAutointerpolate(), dftDivideFrames(), dftDoubleFrames(), dftdup(), dftFillInitialGap(), dftInterpolate(), dftInterpolateInto(), extrapolate_monoexp(), and plotdata_as_dft().
int dftDelete | ( | DFT * | dft, |
int | voi ) |
Delete specified TAC (0..voiNr-1) from the DFT structure.
dft | Pointer to DFT struct |
voi | TAC index |
Definition at line 538 of file dft.c.
Referenced by csv2dft_a(), and dftReadinput().
int dftDeleteFrameOverlap | ( | DFT * | dft | ) |
Correct frame start and end times if frames are slightly overlapping or have small gaps in between. Gap before the first time frame is not corrected. Large gap is not corrected and it does not lead to an error.
dft | Pointer to DFT data. Data must be sorted by increasing time. Time unit does not need to be set. Timetype must be DFT_TIME_STARTEND, i.e. both frame start and end time must be present; if not, then return value is always 0 (passed). |
Definition at line 1237 of file dft.c.
Referenced by dftReadModelingData().
int dftDeleteFrameOverlap_old | ( | DFT * | dft | ) |
Correct frame start and end times if frames are slightly overlapping or have small gaps in between. Large gap is not corrected and it does not lead to an error.
dft | Pointer to DFT data. Time unit must be set, otherwise no checking is done. Timetype must be DFT_TIME_STARTEND, i.e. both frame start and end time must be present. |
Definition at line 1200 of file dft.c.
Makes a duplicate of DFT structure pointed to by dft1 into dft2.
dft1 | Pointer to DFT struct |
dft2 | Pointer to initiated DFT struct; any existing content of dft2 will be deleted. |
Definition at line 655 of file dft.c.
Referenced by dftAddSpaceForFrames(), dftFillInitialGap(), dftReadinput(), and imgReadModelingData().
void dftEmpty | ( | DFT * | data | ) |
Free memory allocated for DFT. All data is cleared.
data | Pointer to initiated DFT struct data |
Definition at line 20 of file dft.c.
Referenced by bfIrr2TCM(), bfRadiowater(), clusterTACs(), cptReadOne(), csv2dft_a(), csv2dft_b(), csv2dft_linkset(), csv2dft_mat(), dftAddnullframe(), dftAddSpaceForFrames(), dftAllocateWithHeader(), dftAutointerpolate(), dftDivideFrames(), dftDoubleFrames(), dftdup(), dftFillInitialGap(), dftInterpolate(), dftInterpolateForIMG(), dftInterpolateInto(), dftMeanTAC(), dftRead(), dftReadinput(), dftReadModelingData(), dftReadReference(), dftSetmem(), extrapolate_monoexp(), idwcRead(), ifRead(), img_k1_using_ki(), img_logan(), img_patlak(), imgMaskPixelTACs(), imgReadModelingData(), noiseSD4SimulationFromDFT(), plotdata_as_dft(), roikbqRead(), and simMyocDiameterCurve().
int dftFillInitialGap | ( | DFT * | dft | ) |
Check if there is a time gap between time zero and first sample time; if gap does not exist, then nothing is done; if gap exists, then gap is filled with an extra frame.
dft | Pointer to DFT struct |
Definition at line 1385 of file dft.c.
Referenced by dftFixPeak().
void dftFrametimes | ( | DFT * | data | ) |
Calculate frame mid or start and end times. Timetype is not changed.
data | Pointer to DFT struct |
Definition at line 340 of file dft.c.
Referenced by csv2dft_a(), dftRead(), and idwcRead().
void dftInit | ( | DFT * | data | ) |
Initiate DFT structure. This should be called once before use.
data | Pointer to initiated DFT struct data |
Definition at line 38 of file dft.c.
Referenced by dftAddnullframe(), dftAddSpaceForFrames(), dftFillInitialGap(), dftReadinput(), dftReadModelingData(), dftReadReference(), img_k1_using_ki(), img_logan(), img_patlak(), imgReadModelingData(), noiseSD4SimulationFromDFT(), and plotdata_as_dft().
int dftMaxY | ( | DFT * | dft, |
double | t1, | ||
double | t2, | ||
double * | miny, | ||
double * | maxy ) |
Search the min and max values of DFT TAC data inside specified time range.
Data may contain NA's.
dft | Pointer to the DFT TAC data to search |
t1 | Start time |
t2 | End time |
miny | Pointer to min Y; set to NULL if not needed |
maxy | Pointer to max Y; set to NULL if not needed |
Definition at line 1090 of file dft.c.
Referenced by plot_fitrange_svg().
Calculates mean TAC of all TACs in DFT struct. Mean is NOT weighted by VOI sizes. Also SD and CV for each sample time are calculated.
dft | Pointer to TAC data from which mean TAC is calculated; missing values (NaN) are allowed |
mean | Pointer to initialized or pre-allocated DFT struct in where mean, SD, and CV will be written in y, y2, and y3, respectively. |
Definition at line 1580 of file dft.c.
Referenced by noiseSD4SimulationFromDFT().
int dftMinMax | ( | DFT * | dft, |
double * | minx, | ||
double * | maxx, | ||
double * | miny, | ||
double * | maxy ) |
Search the min and max values of DFT TAC data. Data may contain NA's.
Note that minx and maxx are the smallest and highest x values in data, not the x values at y minimum and maximum; use dftMinMaxTAC() for that.
dft | Pointer to the DFT TAC data to search |
minx | Pointer to min X; set to NULL if not needed |
maxx | Pointer to max X; set to NULL if not needed |
miny | Pointer to min Y; set to NULL if not needed |
maxy | Pointer to max Y; set to NULL if not needed |
Definition at line 974 of file dft.c.
Referenced by plot_fit_svg(), and plot_fitrange_svg().
int dftMinMaxTAC | ( | DFT * | dft, |
int | tacindex, | ||
double * | minx, | ||
double * | maxx, | ||
double * | miny, | ||
double * | maxy, | ||
int * | mini, | ||
int * | maxi, | ||
int * | mins, | ||
int * | maxs ) |
Search the min and max values of DFT TAC data. Data may contain NA's. This is not a replacement of dftMinMax() which is needed e.g. in plotting functions.
dft | Pointer to the DFT TAC data to search |
tacindex | Index of the only TAC which is searched for min and max; <0 if all |
minx | Pointer to X at TAC min; set to NULL if not needed |
maxx | Pointer to X at TAC max; set to NULL if not needed |
miny | Pointer to min Y; set to NULL if not needed |
maxy | Pointer to max Y; set to NULL if not needed |
mini | Index of min TAC; set to NULL if not needed |
maxi | Index of max TAC; set to NULL if not needed |
mins | Index of min sample; set to NULL if not needed |
maxs | Index of max sample; set to NULL if not needed |
Definition at line 1024 of file dft.c.
Referenced by dftFixPeak(), and dftVerifyPeak().
int dftMovevoi | ( | DFT * | dft, |
int | from, | ||
int | to ) |
Move VOI in DFT structure from one position to another.
dft | Pointer to DFT struct |
from | TAC index |
to | TAC index |
Definition at line 508 of file dft.c.
Referenced by dftDelete(), and dftReadinput().
int dftNAfill | ( | DFT * | dft | ) |
Replace NA's in basic DFT data with interpolated values. If extrapolation is necessary, then the values (0,0) and (Infinity,last measured) are assumed.
dft | Pointer to DFT struct |
Definition at line 930 of file dft.c.
int dftOverflow | ( | DFT * | data | ) |
int dftRemoveTimeRange | ( | DFT * | dft, |
double | startT, | ||
double | endT ) |
Extract specified sample time interval from TAC data.
dft | Pointer to DFT struct from where samples outside time range will be removed. Data must be sorted to increasing frame times before calling this function. |
startT | Start time of data that is preserved (in same units as in DFT) |
endT | End time of data that is preserved (in same units as in DFT) |
Definition at line 1275 of file dft.c.
void dftRNameSimplify | ( | DFT * | dft, |
int | hemisphere, | ||
int | place ) |
Simplify TAC names in DFT struct: empty hemisphere and/or place field in case those are the same in all TACs.
dft | Pointer to DFT struct |
hemisphere | Is hemisphere field simplified (1) or not (0), when possible |
place | Is place field simplified (1) or not (0), when possible |
Definition at line 1534 of file dft.c.
int dftSelect | ( | DFT * | data, |
char * | name ) |
Select VOIs (sets sw=1), whose names are matching specified string. If no string is specified, then all VOIs are selected. This function is to replaced by dftSelectRegions().
data | Pointer to DFT struct |
name | String to search in TAC name fields |
Definition at line 239 of file dft.c.
int dftSelectBestReference | ( | DFT * | dft | ) |
Select the best reference region in case that several were found with dftSelectRegions.
dft | Pointer to DFT struct, after using dftSelectRegions() |
Definition at line 314 of file dft.c.
Referenced by dftReadinput(), and dftReadReference().
int dftSelectRegions | ( | DFT * | dft, |
char * | region_name, | ||
int | reset ) |
Select the VOIs that have matching region name or number. Sets sw=1 or sw=0. This function will replace dftSelect().
dft | Pointer to DFT data where VOIs are selected |
region_name | Name or VOI number which is searched |
reset | 1=Non-matching VOIs are deselected, 0=Old selections are preserved |
Definition at line 285 of file dft.c.
Referenced by dftReadinput(), and dftReadReference().
void dftSetComments | ( | DFT * | dft | ) |
Overwrites DFT comments with information in current DFT header.
If DFT format specifies that titles are to be saved, that information is not included in comments.
dft | Pointer to DFT struct |
Definition at line 1326 of file dft.c.
Referenced by dftRead().
int dftSetmem | ( | DFT * | data, |
int | frameNr, | ||
int | voiNr ) |
Allocate memory for DFT data and sets data pointers.
data | Pointer to initiated DFT structure data; any old contents are deleted. |
frameNr | Nr of time frames (samples) to allocate |
voiNr | Nr of concentration arrays (regional TACs) to allocate |
Definition at line 57 of file dft.c.
Referenced by bf_srtm(), bfIrr2TCM(), bfRadiowater(), clusterTACs(), cptReadOne(), csv2dft_a(), csv2dft_b(), csv2dft_linkset(), csv2dft_mat(), dftAddnullframe(), dftAddSpaceForFrames(), dftAllocateWithHeader(), dftAllocateWithIMG(), dftAutointerpolate(), dftDivideFrames(), dftDoubleFrames(), dftdup(), dftFillInitialGap(), dftInterpolate(), dftRead(), extrapolate_monoexp(), idwcRead(), ifRead(), img_k1_using_ki(), img_logan(), img_patlak(), plotdata_as_dft(), roikbqRead(), sif2dft(), simMyocDiameterCurve(), tsvRead(), and xelRead().
int dftSort | ( | DFT * | data | ) |
int dftSortByFrame | ( | DFT * | dft | ) |
Sorts TAC frames by increasing sample time.
dft | Pointer to DFT struct |
Definition at line 1169 of file dft.c.
Referenced by dftReadModelingData(), and dftVerifyPeak().
int dftSortPlane | ( | DFT * | data | ) |
Sort DFT regions in alphabetical order by their plane.
data | Pointer to DFT struct |
Definition at line 875 of file dft.c.
Referenced by cptWrite().
int dftValidNr | ( | DFT * | dft, |
double | tstart, | ||
double | tstop, | ||
int | index ) |
Determine the nr of valid data points inside the given time range.
dft | Pointer to DFT struct |
tstart | Time range start |
tstop | Time range stop |
index | Index of TAC to use; enter <0 to use all, in which case the minimum number of valid points is returned. |
Definition at line 1638 of file dft.c.
Referenced by dftValidNr().
char dfterrmsg[64] |
Error message from DFT functions.
Definition at line 6 of file dft.c.
Referenced by dftAdd(), dftRead(), dftReadModelingData(), dftWrite(), dftWriteHTML(), idwcRead(), idwcWrite(), ifRead(), ifWrite(), imgReadModelingData(), roikbqRead(), roikbqWrite(), tsvRead(), and xelRead().