#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <string.h>
#include <strings.h>
Go to the source code of this file.
Data Structures | |
struct | SIF |
Macros | |
#define | readSIF sifRead |
#define | writeSIF sifWrite |
#define | printSIF sifPrint |
#define | emptySIF sifEmpty |
#define | weightSIF sifWeight |
#define | initSIF sifInit |
#define | setmemSIF sifSetmem |
Functions | |
void | libsif_printdate (FILE *fp) |
int | sifRead (char *filename, SIF *data) |
int | sifWrite (SIF *data, char *filename) |
void | sifPrint (SIF *data) |
void | sifEmpty (SIF *data) |
void | sifInit (SIF *data) |
int | sifSetmem (SIF *data, int frameNr) |
void | sifWeight (SIF *data, double halflife) |
void | sifModerate (SIF *sif, double limit) |
Variables | |
char | siferrmsg [128] |
int | SIF_TEST |
void libsif_printdate | ( | FILE * | fp | ) |
void sifEmpty | ( | SIF * | data | ) |
Free memory allocated for SIF. All contents are destroyed.
data | ponter to sif data |
Definition at line 74 of file sif.c.
References SIF::colNr, SIF::frameNr, SIF::isotope_name, SIF::prompts, SIF::randoms, SIF::scantime, SIF_TEST, SIF::studynr, SIF::trues, SIF::version, SIF::weights, SIF::x1, and SIF::x2.
Referenced by imgReadAnalyze(), imgReadAnalyzeFrame(), imgReadAnalyzeHeader(), sifRead(), and sifSetmem().
void sifInit | ( | SIF * | data | ) |
Initiate SIF structure. This should be called once before first use.
data | pointer to sif data |
Definition at line 61 of file sif.c.
References SIF::colNr, SIF::frameNr, and SIF_TEST.
Referenced by imgReadAnalyze(), imgReadAnalyzeFrame(), and imgReadAnalyzeHeader().
void sifModerate | ( | SIF * | sif, |
double | limit | ||
) |
Moderate the trues in SIF. True values in SIF are used to calculate weight factors for time frames. If trues are very low in certain frames, the weight factors in other frames may become very low. This function finds the maximum trues, and adds max/limit to each trues value, if min trues < max trues / limit. Negative trues are always eliminated.
sif | Pointer to SIF in which the trues are moderated |
limit | Max trues / limit is added to all trues values; 100.0 might be good |
Definition at line 102 of file weight.c.
References SIF::frameNr, and SIF::trues.
void sifPrint | ( | SIF * | data | ) |
Prints to stdout the contents of SIF data structure.
data | Pointer to SIF struct |
Definition at line 224 of file sifio.c.
References SIF::frameNr, SIF::isotope_name, SIF::prompts, SIF::randoms, SIF::scantime, SIF::trues, SIF::weights, SIF::x1, and SIF::x2.
int sifRead | ( | char * | filename, |
SIF * | data | ||
) |
Reads SIF file contents to the specified data structure. Weights are set to 1.
filename | SIF filename to be read |
data | Pointer to initiated SIF struct; any existing contents will be deleted |
Definition at line 64 of file sifio.c.
References SIF::colNr, SIF::frameNr, SIF::isotope_name, SIF::prompts, SIF::randoms, SIF::scantime, SIF_TEST, sifEmpty(), siferrmsg, sifSetmem(), SIF::studynr, SIF::trues, SIF::version, SIF::weights, SIF::x1, and SIF::x2.
Referenced by imgReadAnalyze(), imgReadAnalyzeFrame(), and imgReadAnalyzeHeader().
int sifSetmem | ( | SIF * | data, |
int | frameNr | ||
) |
Allocates memory for SIF data. Old data is destroyed.
data | pointer to SIF data allocated here |
frameNr | number of PET time frames |
Definition at line 95 of file sif.c.
References SIF::frameNr, SIF::prompts, SIF::randoms, SIF_TEST, sifEmpty(), siferrmsg, SIF::trues, SIF::weights, SIF::x1, and SIF::x2.
Referenced by imgGetMicropetSIF(), and sifRead().
void sifWeight | ( | SIF * | data, |
double | halflife | ||
) |
Calculate weights for frames in SIF data, normalized between 0-1. Weights are calculated from formula weight=(frame duration)^2 / (trues in a frame). Before calling this routine, trues must be calculated as total counts - randoms. Counts in SIF are not corrected for physical decay. Therefore, isotope halflife must be known, if weights are to be calculated for decay corrected TACs. Isotope halflife must be set to 0, if weights are used for TACs that are not corrected for decay.
data | sif data |
halflife | halflife (sec) of isotope label; If halflife is 0, the weights are calculated for non-decay corrected data. If halflife (sec) is >0, the weights are calculated using decay corrected trues, but trues data is not changed. |
Definition at line 61 of file weight.c.
References SIF::frameNr, SIF_TEST, SIF::trues, SIF::weights, SIF::x1, and SIF::x2.
int sifWrite | ( | SIF * | data, |
char * | filename | ||
) |
Write SIF data to a standard SIF file, emptying files old contents.
data | Pointer to SIF struct containing data to be written in file |
filename | Filename for SIF; file is overwritten without backup |
Definition at line 167 of file sifio.c.
References SIF::colNr, SIF::frameNr, SIF::isotope_name, SIF::prompts, SIF::randoms, SIF::scantime, SIF_TEST, siferrmsg, SIF::studynr, SIF::version, SIF::x1, and SIF::x2.
int SIF_TEST |
Definition at line 63 of file sif.h.
Referenced by sifEmpty(), sifInit(), sifRead(), sifSetmem(), sifWeight(), and sifWrite().
char siferrmsg[128] |
Definition at line 33 of file sif.h.
Referenced by sifRead(), sifSetmem(), and sifWrite().