#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <math.h>#include <ctype.h>#include <string.h>#include <strings.h>#include "decpoint.h"#include "include/dft.h"#include "include/dftunit.h"#include "include/dftio.h"Go to the source code of this file.
Functions | |
| int | dftQSortName (const void *voi1, const void *voi2) |
| int | dftQSortPlane (const void *voi1, const void *voi2) |
| 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 | 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 | 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) |
| void | dftSetComments (DFT *dft) |
| int | dftFillInitialGap (DFT *dft) |
| int | dftAddSpaceForFrames (DFT *dft, int nr_to_add) |
| double dft_kBqMax | ( | DFT * | data | ) |
Returns the highest activity value in DFT
Definition at line 1196 of file dft.c.
References DFT::frameNr, DFT::voi, DFT::voiNr, and Voi::y.
| double dft_kBqMin | ( | DFT * | data | ) |
Returns the lowest activity value in DFT
Definition at line 1179 of file dft.c.
References DFT::frameNr, DFT::voi, DFT::voiNr, and Voi::y.
| int dft_nr_of_NA | ( | DFT * | dft | ) |
Check DFT for NA's in sample times and values.
Definition at line 973 of file dft.c.
References DFT_TIME_STARTEND, DFT::frameNr, DFT::timetype, DFT::voi, DFT::voiNr, DFT::x, DFT::x1, DFT::x2, and Voi::y.
Add the specified voi [0,voiNr-1] from data2 to data1. Allocates memory for additional data VOI, if necessary.
Definition at line 379 of file dft.c.
References DFT::_type, DFT::_voidataNr, DFT_FORMAT_PLAIN, dftAddmem(), dftCopyvoihdr(), dfterrmsg, DFT::frameNr, DFT::isweight, DFT::timeunit, DFT::unit, DFT::voi, DFT::voiNr, DFT::w, Voi::y, Voi::y2, and Voi::y3.
Adds room for additional VOI TAC(s) into DFT data struct. Old data is left unchanged.
| dft | Pointer to DFT data struct |
| voiNr | Nr of additional VOI memory blocks |
Definition at line 298 of file dft.c.
References DFT::_data, DFT::_dataSize, DFT::_voidataNr, DFT::frameNr, Voi::hemisphere, Voi::name, Voi::place, Voi::size, Voi::sw, Voi::sw2, Voi::sw3, DFT::voi, Voi::voiname, DFT::voiNr, DFT::w, DFT::x, DFT::x1, DFT::x2, Voi::y, Voi::y2, and Voi::y3.
Referenced by dftAdd().
| int dftAddnullframe | ( | DFT * | data | ) |
Include a frame with time 0, unless one already exists.
Definition at line 835 of file dft.c.
References DFT::_type, DFT::comments, dftEmpty(), dftInit(), dftSetmem(), DFT::frameNr, Voi::hemisphere, DFT::isweight, Voi::name, Voi::place, Voi::size, DFT::studynr, Voi::sw, Voi::sw2, Voi::sw3, DFT::timetype, DFT::timeunit, DFT::unit, DFT::voi, Voi::voiname, DFT::voiNr, DFT::w, DFT::x, DFT::x1, DFT::x2, Voi::y, Voi::y2, and Voi::y3.
| 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 1436 of file dft.c.
References DFT::comments, dftCopymainhdr(), dftCopyvoihdr(), dftdup(), dftEmpty(), dftInit(), dftSetmem(), DFT::frameNr, DFT::isweight, DFT::voi, DFT::voiNr, DFT::w, DFT::x, DFT::x1, DFT::x2, Voi::y, Voi::y2, and Voi::y3.
| int dftAllocateWithHeader | ( | DFT * | dft, |
| int | frameNr, | ||
| int | voiNr, | ||
| DFT * | dft_from | ||
| ) |
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 787 of file dft.c.
References dftCopymainhdr(), dftCopyvoihdr(), dftEmpty(), dftSetmem(), DFT::frameNr, DFT::isweight, DFT::voi, DFT::voiNr, DFT::w, DFT::x, DFT::x1, DFT::x2, Voi::y, Voi::y2, and Voi::y3.
| int dftCopymainhdr | ( | DFT * | dft1, |
| DFT * | dft2 | ||
| ) |
Copy main header info from dft1 to dft2.
Definition at line 706 of file dft.c.
References DFT::_type, DFT::comments, DFT::decayCorrected, DFT::injectionTime, DFT::isotope, DFT::radiopharmaceutical, DFT::scanStartTime, DFT::studynr, DFT::timetype, DFT::timeunit, and DFT::unit.
Referenced by dftAddSpaceForFrames(), dftAllocateWithHeader(), dftdup(), and dftFillInitialGap().
| int dftCopyvoi | ( | DFT * | data, |
| int | from, | ||
| int | to | ||
| ) |
Copy VOI data inside DFT data structure from one place to another.
Definition at line 633 of file dft.c.
References DFT::_voidataNr, DFT::frameNr, Voi::hemisphere, Voi::name, Voi::place, Voi::size, Voi::sw, Voi::sw2, Voi::sw3, DFT::voi, Voi::voiname, Voi::y, Voi::y2, and Voi::y3.
Referenced by dftRead().
| int dftCopyvoihdr | ( | DFT * | dft1, |
| int | from, | ||
| DFT * | dft2, | ||
| int | to | ||
| ) |
Copy voi header info from dft1.voi[from] to dft2.voi[to].
Definition at line 724 of file dft.c.
References DFT::_voidataNr, Voi::hemisphere, Voi::name, Voi::place, Voi::size, Voi::sw, Voi::sw2, Voi::sw3, DFT::voi, and Voi::voiname.
Referenced by dftAdd(), dftAddSpaceForFrames(), dftAllocateWithHeader(), dftdup(), and dftFillInitialGap().
Delete specified TAC (0..voiNr-1) from the DFT structure.
Definition at line 687 of file dft.c.
References dftMovevoi(), and DFT::voiNr.
Referenced by csv2dft_a().
| int dftDeleteFrameOverlap | ( | 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 1268 of file dft.c.
References DFT_TIME_STARTEND, DFT::frameNr, DFT::timetype, DFT::timeunit, DFT::x1, and DFT::x2.
| int dftDeleteFrameOverlap_old | ( | DFT * | dft | ) |
Correct frame start and end times if frames are slightly overlapping or have small gaps in between. Data is not corrected if time unit is not known to be min or sec.
Definition at line 1244 of file dft.c.
References DFT::frameNr, DFT::timeunit, DFT::x1, and DFT::x2.
Makes a duplicate of DFT structure pointed to by dft1 into dft2. Any existing content of dft2 will be deleted. Dft2 must be initiated.
Definition at line 748 of file dft.c.
References dftCopymainhdr(), dftCopyvoihdr(), dftEmpty(), dftSetmem(), DFT::frameNr, DFT::isweight, DFT::voi, DFT::voiNr, DFT::w, DFT::x, DFT::x1, DFT::x2, Voi::y, Voi::y2, and Voi::y3.
Referenced by dftAddSpaceForFrames(), and dftFillInitialGap().
Free memory allocated for DFT. All data is cleared.
Definition at line 226 of file dft.c.
References DFT::_data, DFT::_dataSize, DFT::_voidataNr, DFT::comments, DFT::decayCorrected, DFT::frameNr, DFT::injectionTime, DFT::isotope, DFT::radiopharmaceutical, DFT::scanStartTime, DFT::studynr, DFT::timetype, DFT::timeunit, DFT::unit, DFT::voi, and DFT::voiNr.
Referenced by cptReadOne(), csv2dft_a(), csv2dft_b(), dftAddnullframe(), dftAddSpaceForFrames(), dftAllocateWithHeader(), dftdup(), dftFillInitialGap(), dftRead(), dftSetmem(), idwcRead(), ifRead(), and roikbqRead().
| 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.
Definition at line 1357 of file dft.c.
References DFT::comments, DFT_TIME_STARTEND, dftCopymainhdr(), dftCopyvoihdr(), dftdup(), dftEmpty(), dftInit(), dftSetmem(), DFT::frameNr, DFT::isweight, DFT::timetype, DFT::voi, DFT::voiNr, DFT::w, DFT::x, DFT::x1, DFT::x2, Voi::y, Voi::y2, and Voi::y3.
| void dftFrametimes | ( | DFT * | data | ) |
Calculate frame mid or start and end times. Timetype is not changed.
Definition at line 517 of file dft.c.
References DFT_TIME_END, DFT_TIME_MIDDLE, DFT_TIME_START, DFT_TIME_STARTEND, DFT::frameNr, DFT::timetype, DFT::x, DFT::x1, and DFT::x2.
Referenced by csv2dft_a(), dftRead(), and idwcRead().
Initiate DFT structure. This should be called once before use.
Definition at line 241 of file dft.c.
References DFT::_dataSize, DFT::_voidataNr, DFT::comments, DFT::decayCorrected, DFT::frameNr, DFT::injectionTime, DFT::isotope, DFT::isweight, DFT::radiopharmaceutical, DFT::scanStartTime, DFT::studynr, DFT::timetype, DFT::timeunit, DFT::unit, and DFT::voiNr.
Referenced by dftAddnullframe(), dftAddSpaceForFrames(), and dftFillInitialGap().
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 1140 of file dft.c.
References DFT_TIME_STARTEND, DFT::frameNr, DFT::timetype, DFT::voi, DFT::voiNr, DFT::x, DFT::x1, DFT::x2, and Voi::y.
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 1034 of file dft.c.
References DFT_TIME_STARTEND, DFT::frameNr, DFT::timetype, DFT::voi, DFT::voiNr, DFT::x, DFT::x1, DFT::x2, and Voi::y.
| int dftMinMaxTAC | ( | DFT * | dft, |
| int | tacindex, | ||
| double * | minx, | ||
| double * | maxx, | ||
| double * | miny, | ||
| double * | maxy, | ||
| int * | mini, | ||
| int * | maxi | ||
| ) |
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 |
Definition at line 1082 of file dft.c.
References DFT_TIME_STARTEND, DFT::frameNr, DFT::timetype, DFT::voi, DFT::voiNr, DFT::x, DFT::x1, DFT::x2, and Voi::y.
| int dftMovevoi | ( | DFT * | dft, |
| int | from, | ||
| int | to | ||
| ) |
Move VOI in DFT structure from one position to another.
Definition at line 663 of file dft.c.
References DFT::_voidataNr, and DFT::voi.
Referenced by dftDelete().
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.
Definition at line 994 of file dft.c.
References DFT::frameNr, DFT::voi, DFT::voiNr, DFT::x, and Voi::y.
| int dftOverflow | ( | DFT * | data | ) |
| int dftQSortName | ( | const void * | voi1, |
| const void * | voi2 | ||
| ) |
| int dftQSortPlane | ( | const void * | voi1, |
| const void * | voi2 | ||
| ) |
Definition at line 954 of file dft.c.
Referenced by dftSortPlane().
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().
Definition at line 423 of file dft.c.
References Voi::hemisphere, Voi::place, Voi::sw, DFT::voi, Voi::voiname, and DFT::voiNr.
| 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 491 of file dft.c.
References Voi::hemisphere, Voi::place, Voi::sw, DFT::voi, Voi::voiname, and DFT::voiNr.
| 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 462 of file dft.c.
References Voi::name, Voi::sw, DFT::voi, and DFT::voiNr.
| 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.
Definition at line 1302 of file dft.c.
References DFT::_type, DFT::comments, DFT::decayCorrected, DFT_DECAY_CORRECTED, DFT_DECAY_NOTCORRECTED, DFT_FORMAT_PMOD, DFT_FORMAT_STANDARD, DFT::injectionTime, DFT::isotope, DFT::radiopharmaceutical, DFT::scanStartTime, DFT::studynr, DFT::timeunit, and DFT::unit.
Allocate memory for DFT data and sets data pointers. Old data is destroyed.
Definition at line 256 of file dft.c.
References DFT::_data, DFT::_dataSize, DFT::_voidataNr, dftEmpty(), DFT::voi, DFT::w, DFT::x, DFT::x1, DFT::x2, Voi::y, Voi::y2, and Voi::y3.
Referenced by cptReadOne(), csv2dft_a(), csv2dft_b(), dftAddnullframe(), dftAddSpaceForFrames(), dftAllocateWithHeader(), dftdup(), dftFillInitialGap(), dftRead(), idwcRead(), ifRead(), roikbqRead(), tsvRead(), and xelRead().
Sort DFT regions in alphabetical order by their name.
Definition at line 923 of file dft.c.
References dftQSortName(), DFT::voi, and DFT::voiNr.
| int dftSortByFrame | ( | DFT * | dft | ) |
| int dftSortPlane | ( | DFT * | data | ) |
Sort DFT regions in alphabetical order by their plane.
Definition at line 947 of file dft.c.
References dftQSortPlane(), DFT::voi, and DFT::voiNr.
Referenced by cptWrite().
1.8.0