Defines | Functions | Variables
libtpcimgio.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <ctype.h>
#include "libtpcmisc.h"
#include "include/imgio.h"
Include dependency graph for libtpcimgio.c:

Go to the source code of this file.

Defines

#define LIB_NAME   "libtpcimgio"
#define IMG_IO   1
#define POLARMAP_IO   2
#define MODULE   3
#define MAXVAL   100000;
#define TEST_WITH_FILENAME(filename, desired_length, error_value)
#define TEST_WITH_FORMAT(filename, desired_format, error_value)

Functions

int test_create_img (IMG *img, int dim_x, int dim_y, int dim_z, int dim_t)
int test_create_polarmap (IMG *img, int num_rings, int *sectors_per_ring, float *ring_position, short int *ring_angle, short int start_angle)
int test_img_io (IMG *img)
int test_polarmap_io (IMG *img)
int test_modules (IMG *img)
void print_usage ()
int main (int argc, char *argv[])

Variables

int VERBOSE = 0

Define Documentation

#define IMG_IO   1

Serial numbers for function names.

Definition at line 48 of file libtpcimgio.c.

Referenced by main().

#define LIB_NAME   "libtpcimgio"

Copyright (c) 2004-2008 by Turku PET Centre

File: libtpcimgio.c

Purpose: methods for testing functions in the library libtpcimgio, and for printing out libtpcimgio information, such as Readme, History and build information.

NOTICE! This program should always have the same version with the library.

Version:

2005-02-22 1.0.0 Jarkko Johansson 2005-04-26 1.1.0 Jarkko Johansson 2005-08-01 1.1.1 Jarkko Johansson 2005-11-21 1.1.3 Vesa Oikonen 2005-12-12 1.1.4 Vesa Oikonen 2006-10-31 1.1.5 Vesa Oikonen 2006-12-28 1.1.6 Vesa Oikonen 2007-02-02 1.2.0 Vesa Oikonen Added basic test functions for image i/o. 2007-02-11 1.2.1 VO 2007-02-27 1.2.2 VO 2007-03-13 1.2.3 VO 2007-03-14 1.2.4 VO 2007-03-25 1.2.5 VO 2007-04-03 1.3.0 VO Added test function for polar map img i/o. 2007-17-07 Harri Merisaari Modified for optional ANSi compatibility 2007-09-10 1.3.2 VO 2007-09-10 1.3.3 VO 2007-09-11 1.3.4 VO 2007-09-12 1.3.5 VO 2008-07-07 1.3.6 VO 2008-07-11 1.3.7 VO Later: see libtpcimgiov.c. Library name.

Definition at line 45 of file libtpcimgio.c.

Referenced by print_usage().

#define MAXVAL   100000;

Definition at line 64 of file libtpcimgio.c.

#define MODULE   3

Definition at line 50 of file libtpcimgio.c.

Referenced by main().

#define POLARMAP_IO   2

Definition at line 49 of file libtpcimgio.c.

Referenced by main().

#define TEST_WITH_FILENAME (   filename,
  desired_length,
  error_value 
)
Value:
sprintf(test_str,filename); \
  anaRemoveFNameExtension(test_str); \
  i = 0; \
  while(test_str[i] != 0) i++; \
  if(i != desired_length) return(error_value); \
  memset(test_str,0,256); \
  \

Referenced by test_modules().

#define TEST_WITH_FORMAT (   filename,
  desired_format,
  error_value 
)
Value:
img->_fileFormat = IMG_UNKNOWN; \
        sprintf(test_str,filename); \
  imgFormatFromFName(img, test_str); \
  if(img->_fileFormat != desired_format) return(error_value); \
  memset(test_str,0,256); \
  \

Referenced by test_modules().


Function Documentation

int main ( int  argc,
char *  argv[] 
)

Main function. For retrieval of library information and for testing.

Parameters:
argcnumber of arguments
argvarray of pointers to string arguments
Returns:
0 in case of successfull execution

Definition at line 85 of file libtpcimgio.c.

References IMG_IO, imgEmpty(), imgInit(), libtpcimgio_print_build(), libtpcimgio_print_dhistory(), libtpcimgio_print_dreadme(), libtpcimgio_print_history(), libtpcimgio_print_readme(), MODULE, POLARMAP_IO, print_usage(), test_create_img(), test_create_polarmap(), test_img_io(), test_modules(), test_polarmap_io(), and VERBOSE.

Here is the call graph for this function:

void print_usage ( )

Function for printing the usage information of the libtpcimgio test program.

Definition at line 513 of file libtpcimgio.c.

References LIB_NAME, and libtpcimgio_print_build().

Referenced by main().

Here is the call graph for this function:

int test_create_img ( IMG img,
int  dim_x,
int  dim_y,
int  dim_z,
int  dim_t 
)

Create IMG for testing purposis.

Parameters:
imgPointer to an initiated but not allocated IMG
dim_xX dimension (nr of columns)
dim_yY dimension (nr of rows)
dim_zZ dimension (nr of planes)
dim_ttime dimension (nr of time frames, or gates)
Returns:
0 if IMG could be created, or nonzero in case of error.

Definition at line 206 of file libtpcimgio.c.

References IMG::decayCorrFactor, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, IMG::end, IMG_STATUS_INITIALIZED, IMG_TYPE_IMAGE, imgAllocate(), IMGUNIT_KBQ_PER_ML, IMG::m, IMG::mid, IMG::planeNumber, IMG::start, IMG::status, IMG::type, and IMG::unit.

Referenced by main().

Here is the call graph for this function:

int test_create_polarmap ( IMG img,
int  num_rings,
int *  sectors_per_ring,
float *  ring_position,
short int *  ring_angle,
short int  start_angle 
)

Create POLARMAP IMG for testing purposis.

Parameters:
imgPointer to an initiated but not allocated IMG
num_ringsNumber of polar map rings
sectors_per_ringSectors per ring
ring_positionRing positions
ring_angleRing angles
start_anglePolar map start angle for rings, as defined in ECAT 7 header
Returns:
0 if IMG could be created, or nonzero in case of error.

Definition at line 252 of file libtpcimgio.c.

References IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, IMG::end, IMG_STATUS_INITIALIZED, IMG_TYPE_POLARMAP, imgAllocate(), IMGUNIT_KBQ_PER_ML, IMG::m, IMG::mid, IMG::polarmap_num_rings, IMG::polarmap_ring_angle, IMG::polarmap_ring_position, IMG::polarmap_sectors_per_ring, IMG::polarmap_start_angle, IMG::start, IMG::status, IMG::type, and IMG::unit.

Referenced by main().

Here is the call graph for this function:

int test_img_io ( IMG img)

Test bench for IO functions. Tests include:
ECAT7 image write and read
ECAT7 image values write and read
ECAT6 image volume write and read
Analyze image volume write and read

Parameters:
imgrelated image stucture
Returns:
0 in case of success
11 = write error
110 = img max is not correct
111 = img abs max is not correct
112 = img min is not correct
113 = img frame min or max is not correct
12 = read error
13 = write error
14 = read error
21 = write error
22 = read error
31 = write error
32 = read error
33 = write error
34 = read error

Definition at line 313 of file libtpcimgio.c.

References IMG::_fileFormat, IMG_ANA, IMG_ANA_L, IMG_E63, IMG_E7, IMG_E7_2D, IMG_TYPE_IMAGE, imgAbsMax(), imgEmpty(), imgFrameMinMax(), imgInit(), imgMax(), imgMinMax(), imgRead(), imgWrite(), and IMG::type.

Referenced by main().

Here is the call graph for this function:

int test_modules ( IMG img)

Testbench for module tests.

Parameters:
imgimg structure for testing
Returns:
0 if ok

Definition at line 415 of file libtpcimgio.c.

References IMG::_fileFormat, IMG_ANA, IMG_E63, IMG_E7, IMG_POLARMAP, imgGetEcat7MHeader(), ecat7_mainheader::scan_start_time, IMG::scanStart, TEST_WITH_FILENAME, and TEST_WITH_FORMAT.

Referenced by main().

Here is the call graph for this function:

int test_polarmap_io ( IMG img)

Testbench for polar map images

Parameters:
imgimg structure for testing
Returns:
0 if ok

Definition at line 387 of file libtpcimgio.c.

References IMG::_fileFormat, IMG_POLARMAP, IMG_TYPE_POLARMAP, imgEmpty(), imgInit(), imgRead(), imgWrite(), and IMG::type.

Referenced by main().

Here is the call graph for this function:


Variable Documentation

int VERBOSE = 0

Definition at line 76 of file libtpcimgio.c.

Referenced by main().