My Project
img.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 by Turku PET Centre
3 
4  img.h - definitions for img.c
5 
6  Version:
7  2002-01-05 Vesa Oikonen
8  2002-03-28 VO
9  sampleDistance included in IMG structure.
10  2002-08-23 VO
11  _dataType included in IMG structure.
12  2002-12-01 VO
13  imgDecayCorrection() can be used also to remove decay correction.
14  2002-12-03 VO
15  imgCopyhdr() included.
16  2002-12-23 VO
17  patientName included in IMG structure.
18  imgIsotope() included.
19  decayCorrFactor[] included in IMG structure.
20  2003-09-04 VO
21  _fileFormat and its definitions included in IMG structure.
22  2003-10-04 VO
23  One more _fileFormat definition added (Analyze little endian byte order).
24  2003-12-14 VO
25  Memory for all pixels is allocated in one chunk;
26  pointers are changed accordingly.
27  (Patient) orientation included in IMG structure.
28  Scanner (type) included in IMG structure.
29  Scanner type definitions moved here from imgproc.h.
30  2003-12-18 VO
31  Added struct IMG_PIXEL and IMG_RANGE.
32  Defined function imgExtractRange().
33  2004-05-23 VO
34  Added comments.
35  2004-07-26 VO
36  More comments.
37  2004-08-23 VO
38  MAX_STUDYNR_LEN applied.
39  2006-10-30 VO
40  2007-01-28 VO
41  Definitions for library version 1.2.0:
42  Added defines for NIfTI-1 file formats.
43  Additional scanner types defined.
44  Added definitions for error status messages.
45  Additions in IMG structure:
46  patientID, userProcessCode, studyDescription,
47  gapx, gapy, gapz,
48  resolutionx, resolutiony, resolutionz,
49  prompts and randoms.
50  2007-02-11 VO
51  Added errstatus in IMG struct.
52  2007-02-27 VO
53  Added STATUS_WRONGFILETYPE and STATUS_CANNOTERASE.
54  2007-03-13 VO
55  Added STATUS_CANNOTREAD and STATUS_CANNOTWRITE.
56  2007-03-26 VO
57  Added variables for polar map in IMG struct.
58  2008-07-14 VO
59  Added imgAllocateWithHeader().
60  2009-02-16 VO
61  Added definitions for scanner and image type.
62 
63 
64 */
65 #ifndef _IMG_H
66 #define _IMG_H
67 /*===========================================================================*/
68 #include "studynr.h"
69 /*===========================================================================*/
71 #define IMG_STATUS_UNINITIALIZED 0
72 #define IMG_STATUS_INITIALIZED 1
73 #define IMG_STATUS_OCCUPIED 2
74 #define IMG_STATUS_ERROR 3
76 #define IMG_ERR_OK 0
77 #define IMG_ERR_CALLING 1
78 #define IMG_ERR_OOM 2
80 #define IMG_TYPE_IMAGE 1
81 #define IMG_TYPE_RAW 2
82 #define IMG_TYPE_POLARMAP 3
84 #define IMG_UNKNOWN 0
85 #define IMG_E63 1
86 #define IMG_E7 2
87 #define IMG_E7_2D 3
88 #define IMG_POLARMAP 9
89 #define IMG_ANA 11
90 #define IMG_ANA_L 12 /* little endian variant */
91 #define IMG_INTERFILE 21
92 #define IMG_NIFTI_1D 31 /* dual file format */
93 #define IMG_NIFTI_1S 32 /* single file format */
94 #define IMG_MICROPET 41
96 #define SCANNER_UNKNOWN 0
97 #define SCANNER_ECAT931 12
98 #define SCANNER_ADVANCE 12096
99 #define SCANNER_HRPLUS 3
100 #define SCANNER_HRRT 4
101 /* these may change later */
102 #define SCANNER_MRI 5
103 #define SCANNER_STEVCT_PET 6
104 #define SCANNER_STEVCT_CT 7
105 /* Concorde/MicropET scanners */
106 #define SCANNER_PRIMATE 2000
107 #define SCANNER_RODENT 2001
108 #define SCANNER_MICROPET2 2002
109 #define SCANNER_FOCUS_220 2500
110 #define SCANNER_FOCUS_120 2501
111 #define SCANNER_INVEON_DEDICATED_PET 5000
112 #define SCANNER_INVEON_MM_PET 5500
113 #define SCANNER_MR_PET_HEAD_INSERT 6000
114 #define SCANNER_TUEBINGEN_PET_MR 8000
116 #define MAX_POLARMAP_NUM_RINGS 32
127 /*===========================================================================*/
129 /*===========================================================================*/
130 typedef struct {
132  int x;
134  int y;
136  int z;
138  int f;
139 } IMG_PIXEL;
140 typedef struct {
142  int x1, x2;
144  int y1, y2;
146  int z1, z2;
148  int f1, f2;
149 } IMG_RANGE;
150 /*===========================================================================*/
151 
152 /*===========================================================================*/
156 typedef struct {
157 
158  /*
159  * State of image
160  */
164  char status;
166  const char *statmsg;
167 
168  /*
169  * Information on the study
170  */
172  char unit;
174  char studyNr[MAX_STUDYNR_LEN+1];
176  char patientName[32];
178  char patientID[16];
180  char radiopharmaceutical[32];
186  time_t scanStart;
190  char userProcessCode[11];
192  char studyDescription[32];
193 
194  /*
195  * Information on the image
196  */
198  char type;
200  float zoom;
202  float axialFOV;
208  float sizex;
210  float sizey;
212  float sizez;
214  float gapx;
216  float gapy;
218  float gapz;
220  float resolutionx;
222  float resolutiony;
224  float resolutionz;
231  int scanner;
232 
233  /*
234  * Definitions for polar map
235  */
244  int polarmap_sectors_per_ring[MAX_POLARMAP_NUM_RINGS];
247  float polarmap_ring_position[MAX_POLARMAP_NUM_RINGS];
250  short int polarmap_ring_angle[MAX_POLARMAP_NUM_RINGS];
253 
254  /*
255  * Image data
256  */
257  /* Dimensions */
259  unsigned short int dimt;
261  unsigned short int dimx;
263  unsigned short int dimy;
265  unsigned short int dimz;
267  float *_pxl;
268  float **_col;
269  float ***_row;
270  float ****_pln;
271  float *_header;
272  /* Pointers for data to be used */
274  float ****m;
276  float ****plane;
278  float ***row;
280  float **column;
282  float *pixel;
285 
286  /*
287  * Frame times
288  */
290  float *start;
292  float *end;
294  float *mid;
295 
296  /*
297  * Frame weights
298  */
300  char isWeight;
302  float *weight;
304  float *sd;
306  float *prompts;
308  float *randoms;
309 
310  /*
311  * Decay correction factors for each frame
312  */
315 
317  int errstatus;
318 
319 } IMG;
320 /*===========================================================================*/
321 
322 /*===========================================================================*/
323 /*
324  * Function definitions
325  */
326 /* Initialization and memory handling of img data */
327 extern void imgInit(IMG *image);
328 extern void imgEmpty(IMG *image);
329 extern int imgAllocate(IMG *image, int planes, int rows, int columns, int frames);
330 extern int imgAllocateWithHeader(
331  IMG *image, int planes, int rows, int columns, int frames, IMG *image_from);
332 /* Retrieving image information */
333 extern char *imgStatus(int status_index);
334 extern void imgSetStatus(IMG *img, int status_index);
335 extern void imgInfo(IMG *image);
336 extern int imgCopyhdr(IMG *image1, IMG *image2);
337 extern int imgExtractRange(IMG *img1, IMG_RANGE r, IMG *img2);
338 /*===========================================================================*/
339 
340 /*===========================================================================*/
341 #endif /* _IMG_H */
342 
@ STATUS_UNSUPPORTEDPOLARMAP
Definition: img.h:126
@ STATUS_NOHEADERFILE
Definition: img.h:122
@ STATUS_NOSIFDATA
Definition: img.h:123
@ STATUS_UNSUPPORTEDAXIALCOMP
Definition: img.h:121
@ STATUS_NOIMGDATA
Definition: img.h:123
@ STATUS_INVALIDPOLARMAP
Definition: img.h:126
@ STATUS_NOMATLIST
Definition: img.h:120
@ STATUS_WRONGSIFDATA
Definition: img.h:123
@ STATUS_NOIMGDATAFILE
Definition: img.h:122
@ STATUS_CANNOTERASE
Definition: img.h:125
@ STATUS_INVALIDHEADER
Definition: img.h:122
@ STATUS_OK
Definition: img.h:118
@ STATUS_DISKFULL
Definition: img.h:119
@ STATUS_WRONGFILETYPE
Definition: img.h:124
@ STATUS_NOWRITEPERM
Definition: img.h:119
@ STATUS_UNKNOWNFORMAT
Definition: img.h:118
@ STATUS_NOFILE
Definition: img.h:118
@ STATUS_CANTWRITEIMGFILE
Definition: img.h:124
@ STATUS_NOMATRIX
Definition: img.h:121
@ STATUS_CANTWRITEHEADERFILE
Definition: img.h:124
@ STATUS_CANNOTWRITE
Definition: img.h:125
@ STATUS_CANNOTREAD
Definition: img.h:125
@ STATUS_MISSINGMATRIX
Definition: img.h:119
@ STATUS_INVALIDMATLIST
Definition: img.h:120
@ STATUS_NOSUBHEADER
Definition: img.h:121
@ STATUS_VARMATSIZE
Definition: img.h:120
@ STATUS_UNSUPPORTED
Definition: img.h:119
@ STATUS_FAULT
Definition: img.h:118
@ STATUS_NOMAINHEADER
Definition: img.h:120
@ STATUS_NOMEMORY
Definition: img.h:118
int IMG_TEST
Definition: img.h:128
char * imgStatus(int status_index)
Definition: img.c:384
void imgInfo(IMG *image)
Definition: img.c:414
int imgExtractRange(IMG *img1, IMG_RANGE r, IMG *img2)
Definition: img.c:570
int imgAllocate(IMG *image, int planes, int rows, int columns, int frames)
Definition: img.c:285
int imgCopyhdr(IMG *image1, IMG *image2)
Definition: img.c:501
int imgAllocateWithHeader(IMG *image, int planes, int rows, int columns, int frames, IMG *image_from)
Definition: img.c:357
#define MAX_POLARMAP_NUM_RINGS
Definition: img.h:116
void imgSetStatus(IMG *img, int status_index)
Definition: img.c:399
void imgEmpty(IMG *image)
Definition: img.c:216
void imgInit(IMG *image)
Definition: img.c:163
Definition: img.h:130
int y
Definition: img.h:134
int z
Definition: img.h:136
int x
Definition: img.h:132
int f
Definition: img.h:138
Definition: img.h:140
int z1
Definition: img.h:146
int x1
Definition: img.h:142
int y1
Definition: img.h:144
int f1
Definition: img.h:148
Definition: img.h:156
float * pixel
Definition: img.h:282
float sizex
Definition: img.h:208
int polarmap_num_rings
Definition: img.h:239
unsigned short int dimx
Definition: img.h:261
char type
Definition: img.h:198
float resolutionx
Definition: img.h:220
int errstatus
Definition: img.h:317
float * sd
Definition: img.h:304
float resolutiony
Definition: img.h:222
float *** _row
Definition: img.h:269
float sampleDistance
Definition: img.h:206
short int polarmap_start_angle
Definition: img.h:252
float gapx
Definition: img.h:214
float **** m
Definition: img.h:274
float transaxialFOV
Definition: img.h:204
float ** _col
Definition: img.h:268
float **** _pln
Definition: img.h:270
char unit
Definition: img.h:172
float *** row
Definition: img.h:278
char status
Definition: img.h:164
time_t scanStart
Definition: img.h:186
int _fileFormat
Definition: img.h:229
char decayCorrected
Definition: img.h:184
float * _header
Definition: img.h:271
float * prompts
Definition: img.h:306
unsigned short int dimt
Definition: img.h:259
int _dataType
Definition: img.h:226
int * planeNumber
Definition: img.h:284
int scanner
Definition: img.h:231
float sizey
Definition: img.h:210
float * weight
Definition: img.h:302
float **** plane
Definition: img.h:276
float * start
Definition: img.h:290
unsigned short int dimz
Definition: img.h:265
unsigned short int dimy
Definition: img.h:263
int orientation
Definition: img.h:188
float * end
Definition: img.h:292
float ** column
Definition: img.h:280
float zoom
Definition: img.h:200
float * decayCorrFactor
Definition: img.h:314
const char * statmsg
Definition: img.h:166
float * _pxl
Definition: img.h:267
float isotopeHalflife
Definition: img.h:182
float gapy
Definition: img.h:216
float * randoms
Definition: img.h:308
float gapz
Definition: img.h:218
float axialFOV
Definition: img.h:202
float * mid
Definition: img.h:294
char isWeight
Definition: img.h:300
float sizez
Definition: img.h:212
float resolutionz
Definition: img.h:224