|
TPCCLIB
|
Working with x values (sample times) in TAC structure. More...
#include "tpcclibConfig.h"#include "tpcift.h"#include <stdio.h>#include <stdlib.h>#include <math.h>#include <time.h>#include <string.h>#include "tpctac.h"Go to the source code of this file.
Functions | |
| int | tacXCopy (TAC *tac1, TAC *tac2, int i1, int i2) |
| int | tacCorrectFrameOverlap (TAC *d, TPCSTATUS *status) |
| Correct PET frame start and end times if frames are slightly overlapping or have small gaps in between. | |
| int | tacXRange (TAC *d, double *xmin, double *xmax) |
| Get the range of x values (times) in TAC structure. | |
| int | tacSampleXRange (TAC *d, double *xmin, double *xmax) |
| Get the range of x values (times) in TAC structure. | |
| int | tacMinX (TAC *d) |
| Get the minimum x value in TAC structure. | |
| int | tacIsX (TAC *d) |
| Verify if TAC structure contains reasonable x values (times). | |
| int | tacXMatch (TAC *d1, TAC *d2, const int verbose) |
| Check whether sample (frame) times are the same (or very close to) in two TAC structures. | |
| int | tacAddZeroSample (TAC *d, TPCSTATUS *status) |
| Add an initial sample to TAC(s) with zero time and concentration. | |
| int | tacDeleteSample (TAC *d, int i) |
| Delete a certain sample (time frame) from TAC structure. | |
| int | tacDeleteMissingSamples (TAC *d) |
| Delete those samples (time frames) from TAC structure, which contain only missing y values, and/or x is NaN. | |
| int | tacExtractRange (TAC *d1, TAC *d2, double startT, double endT) |
| Extract the specified time (x) range from TAC structure. | |
| int | tacExtractSamples (TAC *d1, TAC *d2, int si, int ei) |
| Extract the specified sample range from TAC structure. | |
| int | tacCheckX1X2X (TAC *d) |
| Check that sample (time frame) x, x1, and x2 values are reasonably set when compared to each other in TAC structure. | |
| int | tacSetX (TAC *d, TPCSTATUS *status) |
| Set TAC x values based on x1 and x2 values, or guess x1 and x2 values based on x values. | |
| int | tacGetSampleInterval (TAC *d, double ilimit, double *minfdur, double *maxfdur) |
| Get the shortest and longest sampling intervals or frame lengths in TAC structure. | |
| int | tacToBars (TAC *tac1, TAC *tac2) |
| Transform TAC data with frame start and end times into suitable form for plotting with frames as bars. | |
| int | tacFramesToSteps (TAC *inp, TAC *out, TPCSTATUS *status) |
| Transform TAC with frames into TAC with frames represented with stepwise changing dot-to-dot data. | |
| int | tacIsXContiguous (TAC *d) |
| Check that PET TAC frame times are contiguous, without even tiny overlap or gaps in between. | |
| int | tacSetXContiguous (TAC *d) |
| Set PET TAC frame times contiguous, without even tiny overlap or gaps in between. | |
Add an initial sample to TAC(s) with zero time and concentration.
If the sample time of the first sample is zero (or smaller) already, then nothing is done. Sort by sample time before calling this.
| d | Pointer to the TAC structure. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 366 of file tacx.c.
Referenced by tacInput2sim().
| int tacCheckX1X2X | ( | TAC * | d | ) |
Check that sample (time frame) x, x1, and x2 values are reasonably set when compared to each other in TAC structure.
| d | Pointer to the TAC structure. TAC samples must be sorted. TAC isframe setting has no effect here. |
Definition at line 621 of file tacx.c.
Referenced by tacSetX().
Correct PET 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. If TAC file does not contain frame start and end times, but just mid time point, then this function does nothing but check that samples are in correct order. Data must be sorted for increasing sample time before calling this function, otherwise an error is returned.
| d | Pointer to TAC data which is sorted by increasing sample time. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 65 of file tacx.c.
Referenced by tacReadModelingData().
| int tacDeleteMissingSamples | ( | TAC * | d | ) |
Delete those samples (time frames) from TAC structure, which contain only missing y values, and/or x is NaN.
| d | Pointer to the TAC structure. |
Definition at line 450 of file tacx.c.
Referenced by tacMultipleSamples().
| int tacDeleteSample | ( | TAC * | d, |
| int | i ) |
Delete a certain sample (time frame) from TAC structure.
| d | Pointer to the TAC structure. |
| i | Index of the sample to delete, [0..sampleNr-1]. |
Definition at line 426 of file tacx.c.
Referenced by tacDeleteMissingSamples(), and tacMultipleSamples().
Extract the specified time (x) range from TAC structure.
| d1 | Pointer to the source TAC structure. Data must be sorted by ascending x. |
| d2 | Pointer to the target TAC structure; any previous contents are deleted. The source TAC pointer can be given for in-place extraction. |
| startT | Start time of data that is preserved (in same units as in TAC) |
| endT | End time of data that is preserved (in same units as in TAC) |
Definition at line 486 of file tacx.c.
Extract the specified sample range from TAC structure.
| d1 | Pointer to the source TAC structure. Data must be sorted by ascending x. |
| d2 | Pointer to the target TAC structure; any previous contents are deleted. |
| si | Index of first sample to extract. |
| ei | Index of last sample to extract. |
Definition at line 568 of file tacx.c.
Transform TAC with frames into TAC with frames represented with stepwise changing dot-to-dot data.
| inp | Pointer to source TAC structure. |
| out | Pointer to the initiated target TAC structure; any previous contents are deleted. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 942 of file tacx.c.
Referenced by tacAUC(), and tacDelay().
| int tacGetSampleInterval | ( | TAC * | d, |
| double | ilimit, | ||
| double * | minfdur, | ||
| double * | maxfdur ) |
Get the shortest and longest sampling intervals or frame lengths in TAC structure.
Data is not modified. Data must be sorted by increasing x.
| d | Pointer to TAC structure. |
| ilimit | Interval limit: smaller sampling intervals of frame lengths are not accepted; use this to prevent 0 interval in case of step functions or zero length frames; enter NaN if not applied. |
| minfdur | Pointer to variable for minimum interval (NULL if not needed). |
| maxfdur | Pointer to variable for maximum interval (NULL if not needed). |
Definition at line 832 of file tacx.c.
Referenced by tacInterpolateToEqualLengthFrames().
| int tacIsX | ( | TAC * | d | ) |
Verify if TAC structure contains reasonable x values (times).
Data is not modified. Data does not need to be sorted. Data can contain NaNs, as long as some x values are available. Note that x values are considered not to exist even when there is only one sample with x=0.
| d | Pointer to TAC structure; not modified. |
Definition at line 226 of file tacx.c.
Referenced by tacInterpolateToEqualLengthFrames(), tacMultipleSamples(), tacReadReference(), tacSetWeights(), and tacSetX().
| int tacIsXContiguous | ( | TAC * | d | ) |
Check that PET TAC frame times are contiguous, without even tiny overlap or gaps in between.
| d | Pointer to TAC data which is sorted by increasing sample time. |
Definition at line 1130 of file tacx.c.
Referenced by tacFramesToSteps(), and tacSetXContiguous().
| int tacMinX | ( | TAC * | d | ) |
Get the minimum x value in TAC structure.
Data does not need to be sorted, and it can contain missing x and y values (NaNs).
| d | Pointer to the TAC structure; not modified. |
Definition at line 201 of file tacx.c.
Referenced by tacMultipleSamples().
| int tacSampleXRange | ( | TAC * | d, |
| double * | xmin, | ||
| double * | xmax ) |
Get the range of x values (times) in TAC structure.
Data is not modified. Data does not need to be sorted. Data can contain NaNs, and x values are omitted if no finite y values exist for that x. If data contains sample weights, samples with zero weight are not included.
| d | Pointer to TAC structure; not modified. |
| xmin | Pointer to variable for min x value (NULL if not needed). |
| xmax | Pointer to variable for max x value (NULL if not needed). |
Definition at line 162 of file tacx.c.
Referenced by mtgaPlotSVG(), tacPlotFitSVG(), tacPlotHistogramSVG(), and tacPlotLineSVG().
Set TAC x values based on x1 and x2 values, or guess x1 and x2 values based on x values.
This is not an idiot proof method, but works reasonably well in common cases.
| d | Pointer to the TAC structure. TAC samples must be sorted for increasing x, if x1 and x2 are to be estimated from x values. TAC tunit should be specified as a time unit that can be internally converted to seconds to get most reliable results. |
| status | Pointer to status data; enter NULL if not needed. |
Definition at line 653 of file tacx.c.
Referenced by tacInput2sim().
| int tacSetXContiguous | ( | TAC * | d | ) |
Set PET TAC frame times contiguous, without even tiny overlap or gaps in between.
Tiny overlaps and gaps are fixed by modifying frame times. Large gaps are filled with new frames based on linear interpolation between adjacent frames. Error is returned in case of larger frame overlaps.
| d | Pointer to TAC data which is sorted by increasing sample time. |
Definition at line 1166 of file tacx.c.
Transform TAC data with frame start and end times into suitable form for plotting with frames as bars.
| tac1 | Pointer to input TAC structure; not modified. Must be sorted by increasing x. |
| tac2 | Pointer to output TAC structure; must be initiated; any previous content is destroyed. |
Definition at line 888 of file tacx.c.
Copy x values (frame times) from one TAC structure to another.
| tac1 | Pointer to source TAC structure. |
| tac2 | Pointer to target TAC structure. |
| i1 | Index of the first sample time to copy. |
| i2 | Index of the last sample time to copy. |
Definition at line 24 of file tacx.c.
Referenced by bfm1TCM(), tacAllocateMoreSamples(), tacDuplicate(), tacExtract(), tacInterpolate(), tacReadReference(), tacSetWeights(), and tacSetX().
Check whether sample (frame) times are the same (or very close to) in two TAC structures.
Data is not modified. Sort by sample time before calling this. The order of TAC structures is not important. If sampleNr is different, then only common number of samples are compared.
| d1 | Pointer to the first TAC structure; not modified. |
| d2 | Pointer to the second TAC structure; time unit does not matter if conversion can be done. Sample nr may be different than in tac1. Contents not modified. |
| verbose | Verbose level; if zero, then nothing is printed to stderr or stdout. |
Definition at line 249 of file tacx.c.
Referenced by tacInterpolate(), tacInterpolateInto(), and tacReadReference().
| int tacXRange | ( | TAC * | d, |
| double * | xmin, | ||
| double * | xmax ) |
Get the range of x values (times) in TAC structure.
Data is not modified. Data does not need to be sorted. Data can contain NaNs, but x values are not omitted if y is NaN and x is not. Samples with zero weight are included.
| d | Pointer to TAC struct |
| xmin | Pointer to variable for min x value (NULL if not needed). |
| xmax | Pointer to variable for max x value (NULL if not needed). |
Definition at line 124 of file tacx.c.
Referenced by sifWeight(), tacAUC(), tacDelay(), tacDelayFit(), tacFittime(), tacInterpolate(), tacInterpolateInto(), tacInterpolateToEqualLengthFrames(), tacIsX(), tacReadModelingData(), and tacXMatch().