1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# filename: REMARKS #
# #
# UTILITY text: Medical Image Conversion Utility #
# #
# purpose : most important remarks on the code #
# #
# project : (X)MedCon by Erik Nolf #
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# $Id: REMARKS,v 1.11 2007/09/16 20:44:24 enlf Exp $
GENERAL:
=======
- Hey, wake up! As we would say, "to convert IS to delete"
!! ALWAYS PRESERVE YOUR ORIGINAL DATA !!
- "Floating exception (core dumped)" with use of (X)MedCon library
This can occur on DEC Alpha systems ...
1) You can simply prevent this by adding the following functions
to your main code: (see also './source/medcon.c')
...
MdcIgnoreSIGFPE() /* ignore signal Floating exception */
...
MdcAcceptSIGFPE() /* accept signal Floating exception */
...
2) Possible reasons:
On a DEC Alpha, floating exceptions are not handled by default,
which is just great ... but unwanted in the following cases:
1) Perhaps you read a raw image with type float,
but didn't swap the bytes (= wrong endian choice).
2) The headers/images contain bad float values.
- pixel types: Int8, Int16, Int32, Int64
Uint8, Uint16, Uint32, Uint64,
float, double
Most pixel types will be read, internally we want the types:
1) 1-BIT converted to 'Uint8'
2) ASCII converted to 'double'
3) VAX converted to IEEE
Quantifications/Calibrations only use the 'float' type!
Therefore, 'double' values must be downscalable to 'float',
otherwise the integrity of the data can not be guaranteed!
- patient/slice orientations:
a) Only orthogonal values are supported.
b) (X)MedCon allows a simple form of reslicing along columns or rows.
- automatic filename creation:
The filenames are created automatically with the following sequence:
m000-...m999-,mA00-...mAZZ-,mB00-...mZZZ-
So a directory listing "ls" will alphabetically show the files in sequence
as created. After the sequence, filenames could overlap. (X)MedCon however
will *not* overwrite any existing file.
- NEGATIVE = ZERO: potential danger reading (RAW) images with negative pixels
By "default", (X)MedCon works in its most simplest setting, without support
for contrast remapping, quantitation nor negatives. In this mode any
"negative" values are put to "zero". An image that seems to have lost a
lot of pixel information, can mostly be brought back to the elimination
of negative pixel values!
1) supported images
----------------
The program can not see whether negative pixel values are important.
This is for the user to figure out. To preserve negative pixels, please
use the following settings.
command-line: use the '-n' option
graphical: select in Options|MedCon => positives & negatives
You are free to change the default behaviour of the program
from the source code ... (see the file: m-global.c)
2) interactive reading (RAW images)
-------------------
When reading unsupported image matrices, the program will change its
default behaviour by:
- disabling any quantitation (since there is none to be done)
- enabling negative pixel values
Ofcourse, the user will be notified of this change in settings.
Would this be OK? Or should I still persist on the user to implicitly
select and allow negative pixel values ... hmmm. A dilemma!
Now the user won't be confused by missing pixel info but we lost
a certain degree of freedom ...
- QUANTITATION
Some formats support quantified values, either stored in floats or through
integer pixels combined with a float global rescale factor or a float
slope & intercept pair; also referred to as linear (a*x) or affine (a*x+b)
transformation. For various (un)reasonable motivations, quantitation is not
supported by default. It must be selected by the user. From version 0.7.0
quantitation can be combined with negative pixel values.
To enable quantitation:
command line: use the option '-qs' or '-qc'
graphical : see Options||MedCon||Pixels||Values
1. affine transformation (generic = a*x+b)
---------------------
/* general code for "affine" rescale to new pixeltype */
{
scale = max_new_pixeltype / (max_image_value - min_image_value);
new_image_value = scale * (original_image_value - min_image_value);
}
/* 'max_image_value' and/or 'min_image_value' could be negative! */
In case of negative minimal values however, the above requires a format that
supports the slope and intercept concept in order to preserve the quantified
float values where:
(a) slope = 1/scale; (b) intercept = min_image_value;
Until now, only DICOM supports this affine transformation, therefore we
give preference to the linear version.
2. linear transformation (specific = a*x)
---------------------
The linear transformation is possible whenever the minimal negative value
can be transformed within the negative pixel range, using the same scale
factor as for the positive pixel range. In other words, the condition
for linear transformation support is:
scale * min_image_value >= min_new_pixeltype
That way, the linear transform can be as simple as:
/* general code for "linear" rescale to new pixeltype */
{
scale = max_new_pixeltype / max_image_value;
new_image_value = scale * original_image_value;
}
*************
FORMATS:
=======
ECAT6: We check the format on the value of 'mh.system_type==ECAT_SYST_TYPE'.
Change the value of ECAT_SYST_TYPE to your approriate system type in
the source code (see the file: m-ecat64.h).
For (X)MedCon however, if DICOM is unsupported, we automatically try
to read as ECAT when the format was not found or you can use the
option '-fb-ecat' to select ECAT as the fallback read format.
The patient/slice orientation (see Acr/Nema) is always considered as
MDC_SUPINE_HEADFIRST_TRANSAXIAL ...
*************
DICOM: We check the format on the presence of the signature "DICM"
(X)MedCon will automatically try to read as DICOM in case the format
was not found. So DICOM files without MetaHeader can be read as such.
Writing is only supported for reconstructed NM modality and Int16 pixels.
For display with contrast remap (window center/width and rescale
slope/intercept) you should select the '-contrast' option. (CT,MR)
For quantitation (with rescale slope/intercept) you should select
the quantification or calibration option '-qs' or '-qc'. (NM,PT)
*************
GIF: We found one image that didn't compress well with the original code.
See "eNlf: BUG??" notes in the code.
Our workaround of (byte_offset >= 253) could perhaps fail on other
images!
*************
Acr/Nema:
We do attempt to preserve some extra (DICOM) tags in our Acr/Nema files
concerning the patient/slice orientation and position.
*************
InterFile:
We try to preserve the patient/slice orientation and position.
But the format misses some specifications for slice thickness
- Tomographic : all voxel dimensions defineable
- Static/Dynamic: loses slice thickness (no format specification)
*************
Analyze:
We would like to preserve the patient/slice orientation and position,
however, the SPM software doesn't seem to interpret the value of
'orient' (patient orientation)! For our main format ECAT this was
no problem, except that we had to change the direction of all axis with
the use of options '-fv -fh -rs'.
Another problem are the "flipped" versions of 'orient': we don't know
what the meaning of "flipped" is (feet first instead of head first, or
prone instead of supine, or vice versa ...) so we ignore this and
always consider the patient orientation as MDC_SUPINE_HEADFIRST_ ...
Filenames are no longer truncated to 18 chars for filling up the
db_name[18] entry in the header. If you need this, uncomment the
line with ANLZ_SHORT_FILENAME (see the file: m-anlz.h)
With quantitation support, the default pixel value will be floats. The
SPM-like version can be enabled with the '-spm' option. In this case,
quantitation will be supported by the global scale factor in combination
with integer pixel values. If however quantitation failed because an
affine transform with slope/intercept was required, just leave out the
option so (X)MedCon will write with normal float values.
*************
NIfTI: (NIFTI)
The package now contains an integrated version of the C library, as
found on the following site:
<http://niftilib.sourceforge.net>
For using your own library version, you must compile/install it first.
Afterwards, you can compile (X)MedCon with NIfTI support enabled by
performing a proper configure, before the actual make process:
$> ./configure --enable-nifti --with-nifti-prefix=/usr/local
Quantitation should be preserved; patient orientation is currently lost
as we only write Analyze like .nii files.
*************
ECAT7: writing
First you must compile the libraries "libtpcmisc" and "libtpcimgio" from
the Turku PET Centre (TPC):
<http://www.turkupetcentre.net>
Afterwards, you can compile (X)MedCon with ECAT7 writing enabled, by
simply issuing the related configure options:
$> ./configure --enable-tpc --with-tpc-prefix=/dir/with/tpc
Make sure the prefix directory contains two subdirs, "include" and "lib"
with copied header files (.h) and static libraries (.a) respectively.
*************
|