libtpcimgio
 All Data Structures Files Functions Variables Typedefs Enumerator Defines
Data Structures | Defines | Enumerations | Functions | Variables
include/img.h File Reference
#include "studynr.h"
#include "ift.h"
Include dependency graph for img.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  IMG_PIXEL
struct  IMG_RANGE
struct  IMG

Defines

#define IMG_STATUS_UNINITIALIZED   0
#define IMG_STATUS_INITIALIZED   1
#define IMG_STATUS_OCCUPIED   2
#define IMG_STATUS_ERROR   3
#define IMG_ERR_OK   0
#define IMG_ERR_CALLING   1
#define IMG_ERR_OOM   2
#define IMG_TYPE_UNKNOWN   0
#define IMG_TYPE_IMAGE   1
#define IMG_TYPE_RAW   2 /* sinogram */
#define IMG_TYPE_POLARMAP   3
#define IMG_UNKNOWN   0
#define IMG_E63   1
#define IMG_E7   2
#define IMG_E7_2D   3
#define IMG_POLARMAP   9
#define IMG_ANA   11
#define IMG_ANA_L   12 /* little endian variant */
#define IMG_INTERFILE   21
#define IMG_NIFTI_1D   31 /* dual file format */
#define IMG_NIFTI_1S   32 /* single file format */
#define IMG_MICROPET   41
#define IMG_DICOM   100
#define IMG_MODALITY_UNKNOWN   0
#define IMG_MODALITY_PET   1
#define IMG_MODALITY_MRI   2
#define IMG_MODALITY_CT   3
#define IMG_MODALITY_SPECT   4
#define SCANNER_UNKNOWN   0
#define SCANNER_ECAT931   12
#define SCANNER_ADVANCE   12096
#define SCANNER_HRPLUS   3
#define SCANNER_HRRT   4
#define SCANNER_MRI   5
#define SCANNER_STEVCT_PET   6
#define SCANNER_STEVCT_CT   7
#define SCANNER_PRIMATE   2000
#define SCANNER_RODENT   2001
#define SCANNER_MICROPET2   2002
#define SCANNER_FOCUS_220   2500
#define SCANNER_FOCUS_120   2501
#define SCANNER_INVEON_DEDICATED_PET   5000
#define SCANNER_INVEON_MM_PET   5500
#define SCANNER_MR_PET_HEAD_INSERT   6000
#define SCANNER_TUEBINGEN_PET_MR   8000
#define MAX_POLARMAP_NUM_RINGS   32

Enumerations

enum  {
  STATUS_OK, STATUS_FAULT, STATUS_NOMEMORY, STATUS_NOFILE,
  STATUS_UNKNOWNFORMAT, STATUS_UNSUPPORTED, STATUS_MISSINGMATRIX, STATUS_NOWRITEPERM,
  STATUS_DISKFULL, STATUS_NOMATLIST, STATUS_INVALIDMATLIST, STATUS_VARMATSIZE,
  STATUS_NOMAINHEADER, STATUS_NOSUBHEADER, STATUS_NOMATRIX, STATUS_UNSUPPORTEDAXIALCOMP,
  STATUS_NOIMGDATAFILE, STATUS_NOHEADERFILE, STATUS_INVALIDHEADER, STATUS_NOIMGDATA,
  STATUS_NOSIFDATA, STATUS_WRONGSIFDATA, STATUS_CANTWRITEIMGFILE, STATUS_CANTWRITEHEADERFILE,
  STATUS_WRONGFILETYPE, STATUS_CANNOTERASE, STATUS_CANNOTREAD, STATUS_CANNOTWRITE,
  STATUS_UNSUPPORTEDPOLARMAP, STATUS_INVALIDPOLARMAP
}

Functions

void imgInit (IMG *image)
void imgEmpty (IMG *image)
int imgAllocate (IMG *image, int planes, int rows, int columns, int frames)
int imgAllocateWithHeader (IMG *image, int planes, int rows, int columns, int frames, IMG *image_from)
char * imgStatus (int status_index)
void imgSetStatus (IMG *img, int status_index)
void imgInfo (IMG *image)
int imgCopyhdr (IMG *image1, IMG *image2)
int imgExtractRange (IMG *img1, IMG_RANGE r, IMG *img2)

Variables

int IMG_TEST

Define Documentation

#define IMG_ANA   11
#define IMG_ANA_L   12 /* little endian variant */
#define IMG_DICOM   100

Definition at line 107 of file img.h.

Referenced by imgFormatDetermine(), and imgFormatFromFName().

#define IMG_E63   1
#define IMG_E7   2
#define IMG_E7_2D   3
#define IMG_ERR_CALLING   1

Definition at line 88 of file img.h.

#define IMG_ERR_OK   0

Definitions for img error status message

Definition at line 87 of file img.h.

#define IMG_ERR_OOM   2

Definition at line 89 of file img.h.

#define IMG_INTERFILE   21

Definition at line 103 of file img.h.

Referenced by imgFormatDetermine(), and imgFormatFromFName().

#define IMG_MICROPET   41

Definition at line 106 of file img.h.

Referenced by imgFormatDetermine(), imgGetMicropetHeader(), and imgReadFrame().

#define IMG_MODALITY_CT   3

Definition at line 112 of file img.h.

#define IMG_MODALITY_MRI   2

Definition at line 111 of file img.h.

#define IMG_MODALITY_PET   1

Definition at line 110 of file img.h.

#define IMG_MODALITY_SPECT   4

Definition at line 113 of file img.h.

#define IMG_MODALITY_UNKNOWN   0

Definitions for modality

Definition at line 109 of file img.h.

Referenced by imgFormatDetermine().

#define IMG_NIFTI_1D   31 /* dual file format */

Definition at line 104 of file img.h.

#define IMG_NIFTI_1S   32 /* single file format */

Definition at line 105 of file img.h.

#define IMG_POLARMAP   9
#define IMG_STATUS_ERROR   3

Definition at line 85 of file img.h.

Referenced by imgInfo(), svolInfo(), and volInfo().

#define IMG_STATUS_INITIALIZED   1
#define IMG_STATUS_OCCUPIED   2
#define IMG_STATUS_UNINITIALIZED   0

Definitions for img status

Definition at line 82 of file img.h.

Referenced by ecat63ReadPlaneToImg(), img2svol(), img2vol(), imgAllocate(), imgExtractRange(), imgInfo(), svolAllocate(), svolInfo(), volAllocate(), and volInfo().

#define IMG_TYPE_IMAGE   1
#define IMG_TYPE_POLARMAP   3
#define IMG_TYPE_RAW   2 /* sinogram */
#define IMG_TYPE_UNKNOWN   0

Definitions for image type

Definition at line 91 of file img.h.

Referenced by imgFormatDetermine().

#define IMG_UNKNOWN   0
#define MAX_POLARMAP_NUM_RINGS   32

Maximum nr of rings in polar map (based on ECAT 7 polar map header)

Definition at line 135 of file img.h.

Referenced by imgCopyhdr(), imgEmpty(), imgInit(), and imgReadEcat7Header().

#define SCANNER_ADVANCE   12096

Definition at line 117 of file img.h.

#define SCANNER_ECAT931   12

Definition at line 116 of file img.h.

#define SCANNER_FOCUS_120   2501

Definition at line 129 of file img.h.

#define SCANNER_FOCUS_220   2500

Definition at line 128 of file img.h.

#define SCANNER_HRPLUS   3

Definition at line 118 of file img.h.

#define SCANNER_HRRT   4

Definition at line 119 of file img.h.

#define SCANNER_INVEON_DEDICATED_PET   5000

Definition at line 130 of file img.h.

#define SCANNER_INVEON_MM_PET   5500

Definition at line 131 of file img.h.

#define SCANNER_MICROPET2   2002

Definition at line 127 of file img.h.

#define SCANNER_MR_PET_HEAD_INSERT   6000

Definition at line 132 of file img.h.

#define SCANNER_MRI   5

Definition at line 121 of file img.h.

#define SCANNER_PRIMATE   2000

Definition at line 125 of file img.h.

#define SCANNER_RODENT   2001

Definition at line 126 of file img.h.

#define SCANNER_STEVCT_CT   7

Definition at line 123 of file img.h.

#define SCANNER_STEVCT_PET   6

Definition at line 122 of file img.h.

#define SCANNER_TUEBINGEN_PET_MR   8000

Definition at line 133 of file img.h.

#define SCANNER_UNKNOWN   0

Definition for scanner model (system type)

Definition at line 115 of file img.h.

Referenced by imgFormatDetermine().


Enumeration Type Documentation

anonymous enum

Definitions for img status message

Enumerator:
STATUS_OK 
STATUS_FAULT 
STATUS_NOMEMORY 
STATUS_NOFILE 
STATUS_UNKNOWNFORMAT 
STATUS_UNSUPPORTED 
STATUS_MISSINGMATRIX 
STATUS_NOWRITEPERM 
STATUS_DISKFULL 
STATUS_NOMATLIST 
STATUS_INVALIDMATLIST 
STATUS_VARMATSIZE 
STATUS_NOMAINHEADER 
STATUS_NOSUBHEADER 
STATUS_NOMATRIX 
STATUS_UNSUPPORTEDAXIALCOMP 
STATUS_NOIMGDATAFILE 
STATUS_NOHEADERFILE 
STATUS_INVALIDHEADER 
STATUS_NOIMGDATA 
STATUS_NOSIFDATA 
STATUS_WRONGSIFDATA 
STATUS_CANTWRITEIMGFILE 
STATUS_CANTWRITEHEADERFILE 
STATUS_WRONGFILETYPE 
STATUS_CANNOTERASE 
STATUS_CANNOTREAD 
STATUS_CANNOTWRITE 
STATUS_UNSUPPORTEDPOLARMAP 
STATUS_INVALIDPOLARMAP 

Definition at line 137 of file img.h.


Function Documentation

int imgAllocate ( IMG image,
int  planes,
int  rows,
int  columns,
int  frames 
)

Allocates memory for img data. Old contents are not saved.

Parameters:
imageinitialized image
planesnumber of allcoated planes
rowsnumber of allocated rows
columnsnumber of allocated columns
framesnumber of allocated frames
Returns:
0 if ok, 1 image is not initialized, 2 invalid input dimension(s), 3 failed to allocate header, 4 - 8 failed to allocate image data

Definition at line 302 of file img.c.

References IMG::_col, IMG::_header, IMG::_pln, IMG::_pxl, IMG::_row, IMG::column, IMG::decayCorrFactor, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, IMG::end, IMG_STATUS_OCCUPIED, IMG_STATUS_UNINITIALIZED, IMG_TEST, imgEmpty(), imgSetStatus(), IMG::m, IMG::mid, IMG::pixel, IMG::plane, IMG::planeNumber, IMG::prompts, IMG::randoms, IMG::row, IMG::sd, IMG::start, IMG::status, STATUS_FAULT, STATUS_NOMEMORY, STATUS_OK, and IMG::weight.

Referenced by ecat63ReadAllToImg(), ecat63ReadPlaneToImg(), imgAllocateWithHeader(), imgExtractRange(), imgMicropetCTToEcat7(), imgMicropetPETToEcat7(), imgReadAnalyze(), imgReadAnalyzeFirstFrame(), imgReadEcat63FirstFrame(), imgReadEcat7(), imgReadEcat7FirstFrame(), imgReadFrame(), imgReadMicropetFirstFrame(), test_create_img(), and test_create_polarmap().

Here is the call graph for this function:

int imgAllocateWithHeader ( IMG image,
int  planes,
int  rows,
int  columns,
int  frames,
IMG image_from 
)

This functions just combines imgAllocate() and imgCopyhdr().

Returns:
Returns 0 if successful, otherwise returns <>0.
Parameters:
imagePointer to IMG struct which will be allocated here
planesImage matrix dimensions; z
rowsImage matrix dimensions; y
columnsImage matrix dimensions; x
framesImage matrix dimensions; t
image_fromPointer to IMG struct where header contents will be copied from

Definition at line 375 of file img.c.

References imgAllocate(), and imgCopyhdr().

Here is the call graph for this function:

int imgCopyhdr ( IMG image1,
IMG image2 
)
void imgEmpty ( IMG image)

Free memory that is allocated for IMG.

Parameters:
imageimage structure that has allocated memory

Definition at line 229 of file img.c.

References IMG::_col, IMG::_dataType, IMG::_fileFormat, IMG::_header, IMG::_pln, IMG::_pxl, IMG::_row, IMG::axialFOV, IMG::branchingFraction, IMG::calibrationFactor, IMG::column, IMG::decayCorrected, IMG::decayCorrFactor, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, IMG::end, IMG::errstatus, IMG::gapx, IMG::gapy, IMG::gapz, IMG::ift, IMG_STATUS_INITIALIZED, IMG_STATUS_OCCUPIED, IMG_TEST, imgSetStatus(), IMG::isotopeHalflife, IMG::isWeight, IMG::m, MAX_POLARMAP_NUM_RINGS, IMG::mid, IMG::modality, IMG::orientation, IMG::patientID, IMG::patientName, IMG::pixel, IMG::plane, IMG::planeNumber, IMG::polarmap_num_rings, IMG::polarmap_ring_angle, IMG::polarmap_ring_position, IMG::polarmap_sectors_per_ring, IMG::polarmap_start_angle, IMG::radiopharmaceutical, IMG::resolutionx, IMG::resolutiony, IMG::resolutionz, IMG::row, IMG::sampleDistance, IMG::scanner, IMG::scanStart, IMG::sd, IMG::sizex, IMG::sizey, IMG::sizez, IMG::start, IMG::status, STATUS_OK, IMG::studyDescription, IMG::studyNr, IMG::transaxialFOV, IMG::type, IMG::unit, IMG::userProcessCode, IMG::weight, and IMG::zoom.

Referenced by ecat63ReadPlaneToImg(), imgAllocate(), imgExtractRange(), imgFormatDetermine(), imgMicropetCTToEcat7(), imgMicropetPETToEcat7(), imgReadFrame(), imgReadMicropet(), imgReadMinMax(), imgWriteAnalyzeFrame(), imgWriteEcat63Frame(), imgWriteEcat7Frame(), main(), test_img_io(), and test_polarmap_io().

Here is the call graph for this function:

int imgExtractRange ( IMG img1,
IMG_RANGE  r,
IMG img2 
)

Extract a smaller 4D image from inside an IMG. Any existing data is overwritten.

Parameters:
img1source image structure, 'occupied' (has allocated data)
rimage range structure
img2target image structure 'initialized' (has not allocated data)
Returns:
0 if ok, 1 invalid input, 2 failed to allocate memory for target image

Definition at line 599 of file img.c.

References IMG::decayCorrFactor, IMG::dimt, IMG::dimx, IMG::dimy, IMG::dimz, IMG::end, IMG_RANGE::f1, IMG_RANGE::f2, IMG_STATUS_OCCUPIED, IMG_STATUS_UNINITIALIZED, IMG_TEST, imgAllocate(), imgCopyhdr(), imgEmpty(), imgSetStatus(), IMG::m, IMG::mid, IMG::planeNumber, IMG::prompts, IMG::randoms, IMG::sd, IMG::start, IMG::status, STATUS_FAULT, STATUS_NOMEMORY, STATUS_OK, IMG::weight, IMG_RANGE::x1, IMG_RANGE::x2, IMG_RANGE::y1, IMG_RANGE::y2, IMG_RANGE::z1, and IMG_RANGE::z2.

Here is the call graph for this function:

void imgInfo ( IMG image)
void imgInit ( IMG image)
void imgSetStatus ( IMG img,
int  status_index 
)
char* imgStatus ( int  status_index)

Return pointer to string describing the image error status message

Parameters:
status_indexindex of img_status_string
Returns:
pointer to string

Definition at line 402 of file img.c.

References imgmsg, and STATUS_FAULT.

Referenced by imgRead().


Variable Documentation

int IMG_TEST