TPCCLIB
Loading...
Searching...
No Matches
sif.c File Reference

Routines for Scan Information Files (SIF). More...

#include "libtpcimgio.h"

Go to the source code of this file.

Functions

void sifInit (SIF *data)
void sifEmpty (SIF *data)
int sifSetmem (SIF *data, int frameNr)

Variables

int SIF_TEST
char siferrmsg [128]

Detailed Description

Routines for Scan Information Files (SIF).

Author
Vesa Oikonen

Definition in file sif.c.

Function Documentation

◆ sifEmpty()

void sifEmpty ( SIF * data)

Free memory allocated for SIF. All contents are destroyed.

See also
sifInit, sifSetmem
Parameters
dataPointer to sif data struct.

Definition at line 33 of file sif.c.

36 {
37 if(SIF_TEST) printf("sifEmpty()\n");
38 if(data==NULL) return;
39 if(data->frameNr>0) {
40 free((char*)(data->x1)); free((char*)(data->x2));
41 free((char*)(data->prompts)); free((char*)(data->randoms));
42 free((char*)(data->trues)); free((char*)(data->weights));
43 data->frameNr=data->colNr=0;
44 }
45 data->scantime=(time_t)0; data->version=0;
46 strcpy(data->studynr, ""); strcpy(data->isotope_name, "");
47}
int SIF_TEST
Definition sif.c:6
double * x1
double * prompts
int frameNr
double * x2
int version
char studynr[MAX_STUDYNR_LEN+1]
time_t scantime
char isotope_name[8]
double * weights
int colNr
double * randoms
double * trues

Referenced by imgReadAnalyze(), imgReadAnalyzeFrame(), imgReadAnalyzeHeader(), imgReadModelingData(), imgReadNiftiFrame(), imgReadNiftiHeader(), imgSetWeights(), imgWriteNifti(), sifAllocateWithIMG(), sifRead(), and sifSetmem().

◆ sifInit()

void sifInit ( SIF * data)

Initiate SIF structure. This should be called once before first use.

See also
sifEmpty, sifRead, sifSetmem
Parameters
dataPointer to sif data struct.

Definition at line 17 of file sif.c.

20 {
21 if(SIF_TEST) printf("sifInit()\n");
22 if(data==NULL) return;
23 memset(data, 0, sizeof(SIF));
24 data->frameNr=data->colNr=0;
25}

Referenced by imgReadAnalyze(), imgReadAnalyzeFrame(), imgReadAnalyzeHeader(), imgReadModelingData(), imgReadNiftiFrame(), imgReadNiftiHeader(), imgSetWeights(), imgWriteAnalyze(), and imgWriteNifti().

◆ sifSetmem()

int sifSetmem ( SIF * data,
int frameNr )

Allocates memory for SIF data.

See also
sifInit, sifEmpty
Returns
0 if ok, 1 failed memory allocation
Parameters
dataPointer to initiated sif data struct. Any existing data is destroyed.
frameNrNumber of PET time frames.

Definition at line 56 of file sif.c.

61 {
62 if(SIF_TEST) printf("sifSetmem()\n");
63 if(data==NULL) return(1);
64 /* Clear previous data, if necessary */
65 if(data->frameNr>0) sifEmpty(data);
66 if(frameNr<1) return(0);
67
68 /* Allocate memory */
69 data->x1=(double*)calloc(frameNr, sizeof(double));
70 data->x2=(double*)calloc(frameNr, sizeof(double));
71 data->prompts=(double*)calloc(frameNr, sizeof(double));
72 data->randoms=(double*)calloc(frameNr, sizeof(double));
73 data->trues=(double*)calloc(frameNr, sizeof(double));
74 data->weights=(double*)calloc(frameNr, sizeof(double));
75 if(data->x1==NULL || data->x2==NULL || data->prompts==NULL ||
76 data->randoms==NULL || data->trues==NULL || data->weights==NULL) {
77 strcpy(siferrmsg, "out of memory"); return(1);}
78 data->frameNr=frameNr;
79
80 return(0);
81}
char siferrmsg[128]
Definition sif.c:7
void sifEmpty(SIF *data)
Definition sif.c:33

Referenced by img2sif(), imgGetMicropetSIF(), sifAllocateWithIMG(), and sifRead().

Variable Documentation

◆ SIF_TEST

int SIF_TEST

Verbose prints from SIF functions

Definition at line 6 of file sif.c.

Referenced by sifEmpty(), sifInit(), sifModerateTrues(), sifModerateWeights(), sifRead(), sifSetmem(), sifWeight(), sifWeightByFrames(), sifWeightNorm(), and sifWrite().

◆ siferrmsg

char siferrmsg[128]

Error message from SIF functions

Definition at line 7 of file sif.c.

Referenced by imgReadModelingData(), sifRead(), sifSetmem(), and sifWrite().