libtpcimgio
 All Data Structures Files Functions Variables Typedefs Enumerator Defines
Functions
micropet.c File Reference
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include "libtpcmisc.h"
#include "include/imgio.h"
Include dependency graph for micropet.c:

Go to the source code of this file.

Functions

int upetHeaderReadParameter (FILE *fp, char *parameter, char *value)
int upetIsHeader (char *hdrfile)
int upetExists (const char *upetname, char *hdrfile, char *imgfile)
int upetGetImageDimensions (FILE *fp, int *z, int *x, int *y, int *f)
int upetScanStart (FILE *fp, time_t *scant)
int upetReadImagedata (FILE *fp, IFT *ift, int frame, float *data)

Function Documentation

int upetExists ( const char *  upetname,
char *  hdrfile,
char *  imgfile 
)

Check if specified image filename is a Concorde/microPET file

Returns:
Returns 0 if it is not, 1 if it is, and both image and header is found.
Parameters:
upetnameFilename, either header file, image file, or base name without extensions. If file is found, then
hdrfileIf upetname is a Concorde/microPET file, then header filename will be written in this char pointer (space needs to allocated by caller); NULL if not needed.
imgfileIf upetname is a Concorde/microPET file, then image filename will be written in this char pointer (space needs to allocated by caller); NULL if not needed.

Definition at line 138 of file micropet.c.

References MICROPET_TEST, and upetIsHeader().

Referenced by imgFormatDetermine(), imgMicropetToEcat7(), imgRead(), imgReadHeader(), imgReadMicropetFrame(), and imgReadMicropetHeader().

Here is the call graph for this function:

int upetGetImageDimensions ( FILE *  fp,
int *  z,
int *  x,
int *  y,
int *  f 
)

Read image dimensions from header

Parameters:
fpFile pointer to MicroPET image header
zPointers to dimensions: planes
xPointers to dimensions: columns
yPointers to dimensions: rows
fPointers to dimensions: frames; if not existent (CT), enter NULL

Definition at line 204 of file micropet.c.

References MAX_MICROPET_LINE_LEN, and upetHeaderReadParameter().

Referenced by imgMicropetCTToEcat7(), and imgMicropetPETToEcat7().

Here is the call graph for this function:

int upetHeaderReadParameter ( FILE *  fp,
char *  parameter,
char *  value 
)

Read specified parameter value from Concorde/MicroPET header.

Returns:
Returns 0 if parameter was found, even if value is empty, and 1, if parameter was not found, and <0 in case of other errors
Parameters:
fpFile pointer to Concorde/MicroPET header; parameter is read starting from file pointer forward, therefore rewind file pointer before calling this routine if you want to search parameter from beginning
parameterPointer to string which contains the header parameter name
valuePointer to allocated string where parameter value will be written; memory for at least MAX_MICROPET_LINE_LEN chars must be allocated; NULL if not needed.

Definition at line 69 of file micropet.c.

References MAX_MICROPET_LINE_LEN, and MICROPET_TEST.

Referenced by imgGetMicropetFrameHeader(), imgGetMicropetMainHeader(), imgGetMicropetSIF(), imgMicropetCTToEcat7(), imgMicropetToEcat7(), upetGetImageDimensions(), upetIsHeader(), and upetScanStart().

int upetIsHeader ( char *  hdrfile)

Verify that given file is a valid Concorde/microPET file header file.

Returns:
Returns 0 if not, and 1 if it is a valid header file.
Parameters:
hdrfileConcorde/microPET file header filename, with correct extension

Definition at line 108 of file micropet.c.

References MAX_MICROPET_LINE_LEN, MICROPET_TEST, and upetHeaderReadParameter().

Referenced by upetExists().

Here is the call graph for this function:

int upetReadImagedata ( FILE *  fp,
IFT *  ift,
int  frame,
float *  data 
)

Reads microPET image data, scaling values to floats if necessary. Reads only one frame at a time!

Returns:
0 when successful, otherwise <>0.
Parameters:
fpfile opened previously in binary mode
iftmicroPET header in IFT struct
frameframe number to read [1..number of frames]
datapointer to image float data allocated previously

Definition at line 285 of file micropet.c.

References MAX_MICROPET_LINE_LEN, and MICROPET_TEST.

Referenced by imgReadMicropetFrame().

int upetScanStart ( FILE *  fp,
time_t *  scant 
)

Read scan start time from Concorde/MicroPET header.

Returns:
Returns 0 when successful.
Parameters:
fpFile pointer to Concorde/MicroPET header
scantPointer to time_t where time and date will be saved

Definition at line 242 of file micropet.c.

References MAX_MICROPET_LINE_LEN, and upetHeaderReadParameter().

Referenced by imgGetMicropetSIF(), imgMicropetCTToEcat7(), and imgMicropetPETToEcat7().

Here is the call graph for this function: