Data Structures | Defines | Functions | Variables
sif.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <string.h>
#include <strings.h>
Include dependency graph for sif.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SIF

Defines

#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

Define Documentation

#define emptySIF   sifEmpty

Definition at line 78 of file sif.h.

#define initSIF   sifInit

Definition at line 80 of file sif.h.

#define printSIF   sifPrint

Definition at line 77 of file sif.h.

#define readSIF   sifRead

Definition at line 75 of file sif.h.

#define setmemSIF   sifSetmem

Definition at line 81 of file sif.h.

#define weightSIF   sifWeight

Definition at line 79 of file sif.h.

#define writeSIF   sifWrite

Definition at line 76 of file sif.h.


Function Documentation

void libsif_printdate ( FILE *  fp)
void sifEmpty ( SIF data)

Free memory allocated for SIF. All contents are destroyed.

Parameters:
dataponter 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.

Parameters:
datapointer 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.

Parameters:
sifPointer to SIF in which the trues are moderated
limitMax 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.

Parameters:
dataPointer 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.

Returns:
Returns 0 if ok, 1 invalid input, 2 failed to open file, 3 failed to allocate memory, 4 header parsing error, 5 wrong file type, 6 failed to allocate memory, 8 parse error, 9 wrong data format
Parameters:
filenameSIF filename to be read
dataPointer 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().

Here is the call graph for this function:

int sifSetmem ( SIF data,
int  frameNr 
)

Allocates memory for SIF data. Old data is destroyed.

Parameters:
datapointer to SIF data allocated here
frameNrnumber of PET time frames
Returns:
0 if ok, 1 failed memory allocation

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().

Here is the call graph for this function:

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.

See also:
Mazoyer BM, Huesman RH, Budinger TF, Knittel BL. Dynamic PET data analysis. J Comput Assist Tomogr 1986; 10:645-653.
Parameters:
datasif data
halflifehalflife (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.

Returns:
Returns 0 if successful, 1 invalid input, 2 failed to open file, 3 failed to write into file.
Parameters:
dataPointer to SIF struct containing data to be written in file
filenameFilename 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.


Variable Documentation

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().