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
75 
76 #define IMG_ERR_OK 0
77 #define IMG_ERR_CALLING 1
78 #define IMG_ERR_OOM 2
79 
80 #define IMG_TYPE_IMAGE 1
81 #define IMG_TYPE_RAW 2
82 #define IMG_TYPE_POLARMAP 3
83 
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
95 
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
115 
116 #define MAX_POLARMAP_NUM_RINGS 32
117 
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