1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * filename: m-defs.h                                                      *
3  *                                                                         *
4  * UTIL C-source: Medical Image Conversion Utility                         *
5  *                                                                         *
6  * purpose      : project variables, structs & datatypes                   *
7  *                                                                         *
8  * project      : (X)MedCon by Erik Nolf                                   *
9  *                                                                         *
10  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
11 /*
12  */
13 
14 /*
15    Copyright (C) 1997-2021 by Erik Nolf
16 
17    This program is free software; you can redistribute it and/or modify it
18    under the terms of the GNU General Public License as published by the
19    Free Software Foundation; either version 2, or (at your option) any later
20    version.
21 
22    This program is distributed in the hope that it will be useful, but
23    WITHOUT ANY WARRANTY; without even the implied warranty of
24    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
25    Public License for more details.
26 
27    You should have received a copy of the GNU General Public License along
28    with this program; if not, write to the Free Software Foundation, Inc.,
29    59 Place - Suite 330, Boston, MA 02111-1307, USA.  */
30 
31 #ifndef __M_DEFS_H__
32 #define __M_DEFS_H__
33 
34 #include "m-depend.h"
35 #include "m-config.h"
36 
37 #ifdef HAVE_INTTYPES_H
38 #include <inttypes.h>
39 #else
40 #ifdef HAVE_STDINT_H
41 #include <stdint.h>
42 #endif
43 #endif
44 
45 /**************************
46   COMPILATION CONDITIONALS
47  **************************/
48 
49 #ifdef _WIN32
50 /* dos/mswindows */
51 #define MDC_PATH_DELIM_STR "\\"
52 #define MDC_PATH_DELIM_CHR '\\'
53 #define MDC_NEWLINE "\r\n"
54 #else
55 /* unix/linux */
56 #define MDC_PATH_DELIM_STR "/"
57 #define MDC_PATH_DELIM_CHR '/'
58 #define MDC_NEWLINE "\n"
59 #endif
60 
61 /* For output formats without slice_spacing key, it is prefered
62  * to use slice_spacing as the slice_width parameter, and thus
63  * virtually "eliminating" any gaps/overlaps between those sices.
64  * If not wanted, comment out following define line.
65  */
66 #define MDC_USE_SLICE_SPACING 1
67 
68 /****************************************************************************
69                               D E F I N E S
70 ****************************************************************************/
71 
72 #define MDC_ONE           1
73 #define MDC_ZERO          0
74 
75 #define MDC_FALSE        (0)
76 #define MDC_TRUE         (!MDC_FALSE)
77 
78 #define MDC_UNKNOWN      MDC_ZERO
79 
80 #define MDC_UNKNOWN_ENDIAN (-1)
81 #define MDC_BIG_ENDIAN     MDC_ZERO
82 #define MDC_LITTLE_ENDIAN  MDC_ONE
83 
84 #define MDC_1KB_OFFSET     1024
85 #define MDC_2KB_OFFSET     2048
86 
87 #define MDC_INPUT_NORM_STYLE   1
88 #define MDC_INPUT_ECAT_STYLE   2
89 
90 #define MDC_MAX_PATH  256
91 #define MDC_MAX_LIST  256
92 
93 #define MDC_YES    MDC_ONE
94 #define MDC_NO     MDC_ZERO
95 
96 #define MDC_ARG_FILE    0
97 #define MDC_ARG_CONV    1
98 #define MDC_ARG_EXTRACT 2
99 
100 #define MDC_FILES     0
101 #define MDC_CONVS     1
102 
103 /* precision */
104 #define MDC_FLT_EPSILON 1.1920928955078125e-07
105 
106 /* passess */
107 #define MDC_PASS0     0
108 #define MDC_PASS1     1
109 #define MDC_PASS2     2
110 
111 /* output message levels */
112 #define MDC_LEVEL_MESG    1
113 #define MDC_LEVEL_WARN    2
114 #define MDC_LEVEL_ERR     3
115 #define MDC_LEVEL_ALL     4
116 
117 /* supported color maps */
118 #define MDC_MAP_PRESENT   MDC_ZERO /* 256 RGB   colormap */
119 #define MDC_MAP_GRAY      1        /* grayscale colormap */
120 #define MDC_MAP_INVERTED  2        /* inverted  colormap */
121 #define MDC_MAP_RAINBOW   3        /* rainbow   colormap */
122 #define MDC_MAP_COMBINED  4        /* combined  colormap */
123 #define MDC_MAP_HOTMETAL  5        /* hotmetal  colormap */
124 
125 #define MDC_MAP_LOADED    6        /* loaded    colormap */
126 
127 /* supported color modes */
128 #define MDC_COLOR_INDEXED 0        /* 256 indexed colors */
129 #define MDC_COLOR_RGB     1        /* 24bit true  colors */
130 
131 /* supported formats */
132 #define MDC_FRMT_BAD     MDC_ZERO
133 #define MDC_FRMT_NONE    MDC_FRMT_BAD
134 #define MDC_FRMT_RAW     1
135 #define MDC_FRMT_ASCII   2
136 #define MDC_FRMT_GIF     3
137 #define MDC_FRMT_ACR     4
138 #define MDC_FRMT_INW     5
139 #define MDC_FRMT_ECAT6   6
140 #define MDC_FRMT_ECAT7   7
141 #define MDC_FRMT_INTF    8
142 #define MDC_FRMT_ANLZ    9
143 #define MDC_FRMT_DICM    10
144 #define MDC_FRMT_PNG     11
145 #define MDC_FRMT_CONC    12
146 #define MDC_FRMT_NIFTI   13
147 
148 #define MDC_MAX_FRMTS    14        /* total+1 conversion formats supported */
149 
150 /* acquisition types */                      /*  InterFile and DICOM   */
151 #define MDC_ACQUISITION_UNKNOWN    MDC_ZERO  /* unknown = static       */
152 #define MDC_ACQUISITION_STATIC     1         /* static, simple default */
153 #define MDC_ACQUISITION_DYNAMIC    2         /* dynamic                */
154 #define MDC_ACQUISITION_TOMO       3         /* tomographic            */
155 #define MDC_ACQUISITION_GATED      4         /* gated                  */
156 #define MDC_ACQUISITION_GSPECT     5         /* gated spect            */
157 
158 #define MDC_MAX_ACQUISITIONS       6         /* total acquisitions + 1 */
159 
160 /* ECAT sort order */
161 #define MDC_ANATOMICAL   1
162 #define MDC_BYFRAME      2
163 
164 /* pat_orient */
165 #define MDC_LEFT         1
166 #define MDC_RIGHT        2
167 #define MDC_ANTERIOR     3
168 #define MDC_POSTERIOR    4
169 #define MDC_HEAD         5
170 #define MDC_FEET         6
171 
172 /* patient rotation */
173 #define MDC_SUPINE            1       /* on the back            */
174 #define MDC_PRONE             2       /* on the face            */
175 #define MDC_DECUBITUS_RIGHT   3       /* on the right side      */
176 #define MDC_DECUBITUS_LEFT    4       /* on the left side       */
177 
178 /* patient orientation */
179 #define MDC_HEADFIRST   1             /* head first in scanner  */
180 #define MDC_FEETFIRST   2             /* feet first in scanner  */
181 
182 /* slice orientation */               /* consider a patient on  */
183                                       /* his back on the table, */
184                                       /* then the direction is: */
185 #define MDC_TRANSAXIAL  1             /* //  device ;_|_ ground */
186 #define MDC_SAGITTAL    2             /* _|_ device ;_|_ ground */
187 #define MDC_CORONAL     3             /* _|_ device ; // ground */
188 
189 /* patient/slice combined */
190 #define MDC_SUPINE_HEADFIRST_TRANSAXIAL           1
191 #define MDC_SUPINE_HEADFIRST_SAGITTAL             2
192 #define MDC_SUPINE_HEADFIRST_CORONAL              3
193 #define MDC_SUPINE_FEETFIRST_TRANSAXIAL           4
194 #define MDC_SUPINE_FEETFIRST_SAGITTAL             5
195 #define MDC_SUPINE_FEETFIRST_CORONAL              6
196 #define MDC_PRONE_HEADFIRST_TRANSAXIAL            7
197 #define MDC_PRONE_HEADFIRST_SAGITTAL              8
198 #define MDC_PRONE_HEADFIRST_CORONAL               9
199 #define MDC_PRONE_FEETFIRST_TRANSAXIAL           10
200 #define MDC_PRONE_FEETFIRST_SAGITTAL             11
201 #define MDC_PRONE_FEETFIRST_CORONAL              12
202 #define MDC_DECUBITUS_RIGHT_HEADFIRST_TRANSAXIAL 13
203 #define MDC_DECUBITUS_RIGHT_HEADFIRST_SAGITTAL   14
204 #define MDC_DECUBITUS_RIGHT_HEADFIRST_CORONAL    15
205 #define MDC_DECUBITUS_RIGHT_FEETFIRST_TRANSAXIAL 16
206 #define MDC_DECUBITUS_RIGHT_FEETFIRST_SAGITTAL   17
207 #define MDC_DECUBITUS_RIGHT_FEETFIRST_CORONAL    18
208 #define MDC_DECUBITUS_LEFT_HEADFIRST_TRANSAXIAL  19
209 #define MDC_DECUBITUS_LEFT_HEADFIRST_SAGITTAL    20
210 #define MDC_DECUBITUS_LEFT_HEADFIRST_CORONAL     21
211 #define MDC_DECUBITUS_LEFT_FEETFIRST_TRANSAXIAL  22
212 #define MDC_DECUBITUS_LEFT_FEETFIRST_SAGITTAL    23
213 #define MDC_DECUBITUS_LEFT_FEETFIRST_CORONAL     24
214 #define MDC_MAX_ORIENT                           25 /* total orientations + 1 */
215 
216 /* detector rotation */
217 #define MDC_ROTATION_CW   1   /* clockwise               */
218 #define MDC_ROTATION_CC   2   /* counter-clocwise        */
219 
220 /* detector motion   */
221 #define MDC_MOTION_STEP   1   /* stepped                 */
222 #define MDC_MOTION_CONT   2   /* continuous              */
223 #define MDC_MOTION_DRNG   3   /* during step             */
224 
225 /* gated spect nesting outer level */
226 #define MDC_GSPECT_NESTING_SPECT 1
227 #define MDC_GSPECT_NESTING_GATED 2
228 
229 /* gated heart rate */
230 #define MDC_HEART_RATE_ACQUIRED  1
231 #define MDC_HEART_RATE_OBSERVED  2
232 
233 /* image padding */
234 #define MDC_PAD_AROUND        1
235 #define MDC_PAD_TOP_LEFT      2
236 #define MDC_PAD_BOTTOM_RIGHT  3
237 
238 /* some maximum limits */
239 #define MDC_MAX_FILES 10000 /* maximum files handled        */
240                             /* 3-char prefix: 34696 uniques */
241 
242 #define MDC_MAXSTR      35  /* max length of strings        */
243 
244 #define MDC_BUF_ITMS    10  /* realloc per BUF_ITMS items   */
245 
246 #define MDC_CHAR_BUF   100  /* max chars for string buffer  */
247 
248 #define MDC_MAX_PREFIX  15  /* max chars for prefix         */
249 
250 /* pixel types                             */
251 #define BIT1      1    /*  1-bit           */
252 #define BIT8_S    2    /*  8-bit signed    */
253 #define BIT8_U    3    /*  8-bit unsigned  */
254 #define BIT16_S   4    /* 16-bit signed    */
255 #define BIT16_U   5    /* 16-bit unsigned  */
256 #define BIT32_S   6    /* 32-bit signed    */
257 #define BIT32_U   7    /* 32-bit unsigned  */
258 #define BIT64_S   8    /* 64-bit signed    */
259 #define BIT64_U   9    /* 64-bit unsigned  */
260 #define FLT32    10    /* 32-bit float     */
261 #define FLT64    11    /* 64-bit double    */
262 #define ASCII    12    /* ascii            */
263 #define VAXFL32  13    /* 32-bit vaxfloat  */
264 #define COLRGB   20    /* RGB triplets     */
265 
266 /* define maximum integer values */
267 #define MDC_MAX_BIT8_U    255
268 #define MDC_MAX_BIT16_S   ((1<<16)/2) - 1
269 
270 /* file compression type */
271 #define MDC_COMPRESS  1
272 #define MDC_GZIP      2
273 
274 /****************************************************************************
275                             T Y P E D E F S
276 ****************************************************************************/
277 
278 /*  8 bit type */
279 typedef  int8_t   Int8;
280 typedef uint8_t  Uint8;
281 
282 /* 16 bit type */
283 typedef  int16_t  Int16;
284 typedef uint16_t Uint16;
285 
286 /* 32 bit type */
287 typedef  int32_t  Int32;
288 typedef uint32_t Uint32;
289 
290 /* 64 bit type */
291 typedef  int64_t  Int64;
292 typedef uint64_t Uint64;
293 
294 /* define different modalities */
295 typedef enum {
296 
297   M_AS=('A'<<8)|'S',    /* Angioscopy                                 */
298   M_AU=('A'<<8)|'U',    /* Audio                                      */
299   M_BI=('B'<<8)|'I',    /* Biomagnetic Imaging                        */
300   M_CD=('C'<<8)|'D',    /* Color Flow Doppler                         */
301   M_CF=('C'<<8)|'F',    /* Cinefluorography                           */
302   M_CP=('C'<<8)|'P',    /* Culposcopy                                 */
303   M_CR=('C'<<8)|'R',    /* Computed Radiography                       */
304   M_CS=('C'<<8)|'S',    /* Cystoscopy                                 */
305   M_CT=('C'<<8)|'T',    /* Computed Tomography                        */
306   M_DD=('D'<<8)|'D',    /* Duplex Doppler                             */
307   M_DF=('D'<<8)|'F',    /* Digital Fluoroscopy                        */
308   M_DG=('D'<<8)|'G',    /* Diaphanography                             */
309   M_DM=('D'<<8)|'M',    /* Digital Microscopy                         */
310   M_DS=('D'<<8)|'S',    /* Digital Substraction Angiography           */
311   M_DX=('D'<<8)|'X',    /* Digital Radiography                        */
312   M_EC=('E'<<8)|'C',    /* Echocardiography                           */
313   M_ES=('E'<<8)|'S',    /* Endoscopy                                  */
314   M_FA=('F'<<8)|'A',    /* Fluorescein Angiography                    */
315   M_FS=('F'<<8)|'S',    /* Fundoscopy                                 */
316   M_GM=('G'<<8)|'M',    /* General Microscopy                         */
317   M_HD=('H'<<8)|'D',    /* Hemodynamic Waveform                       */
318   M_IO=('I'<<8)|'O',    /* Intra-Oral Radiography                     */
319   M_HC=('H'<<8)|'C',    /* Hardcopy                                   */
320   M_LP=('L'<<8)|'P',    /* Laparoscopy                                */
321   M_MA=('M'<<8)|'A',    /* Magnetic Resonance Angiography             */
322   M_MG=('M'<<8)|'G',    /* Mammography                                */
323   M_MR=('M'<<8)|'R',    /* Magnetic Resonance                         */
324   M_MS=('M'<<8)|'S',    /* Magnetic Resonance Spectroscopy            */
325   M_NM=('N'<<8)|'M',    /* Nuclear Medicine                           */
326   M_OT=('O'<<8)|'T',    /* Other                                      */
327   M_PT=('P'<<8)|'T',    /* Positron Emission Tomography               */
328   M_PX=('P'<<8)|'X',    /* Panoramic X-Ray                            */
329   M_RF=('R'<<8)|'F',    /* Radio Fluoroscopy                          */
330   M_RG=('R'<<8)|'G',    /* Radiographic Imaging                       */
331   M_RT=('R'<<8)|'T',    /* Radiotherapy                               */
332   M_SM=('S'<<8)|'M',    /* Slide Microscopy                           */
333   M_SR=('S'<<8)|'R',    /* SR Document                                */
334   M_ST=('S'<<8)|'T',    /* Single-Photon Emission Computed Tomography */
335   M_TG=('T'<<8)|'G',    /* Thermography                               */
336   M_US=('U'<<8)|'S',    /* Ultrasound                                 */
337   M_VF=('V'<<8)|'F',    /* Videofluorography                          */
338   M_XA=('X'<<8)|'A',    /* X-Ray Angiography                          */
339   M_XC=('X'<<8)|'C'     /* External-Camera Photography                */
340 
341 }
342 MDC_MODALITY;
343 
344 
345 #endif /* __M_DEFS_H__ */
346