]> Creatis software - gdcm.git/blob - gdcmPython/testSuite.py
* src/gdcmHeader.[cxx|h]:
[gdcm.git] / gdcmPython / testSuite.py
1 import unittest
2 import os
3 from gdcmPython import *
4 if os.name == 'posix':
5    from libvtkgdcmPython import *
6 else:
7    from vtkgdcmPython import *
8
9 class gdcmTestCase(unittest.TestCase):
10    # The files whose name starts with a modality (e.g. CR-MONO1-10-chest.dcm)
11    # come from Sebastien Barre's Dicom2 highly recommendable site
12    # http://www.barre.nom.fr/medical/samples/index.html
13    BarreFiles = [
14       ####################################
15       # CR modality examples:
16       ####################################
17       ["CR-MONO1-10-chest.dcm",
18          [ ["Modality", "CR"],
19            #"Transfer Syntax UID" is absent.
20            ["Rows", "440"],
21            ["Columns", "440"],
22            ["Bits Stored", "10"],
23            ["Bits Allocated", "16"],
24            ["High Bit", "9"],
25            ["Pixel Representation", "0"],
26            ["Manufacturer", "FUJI PHOTO FILM CO. LTD."],
27            ["Manufacturer's Model Name", "9000"],
28            ["Pixel Data", "gdcm::NotLoaded. Address:776 Length:387200 x(5e880)"]
29          ] ],
30       ####################################
31       # CT modality examples:
32       ####################################
33       ["CT-MONO2-16-brain.dcm",
34          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"],  # Explicit VR, LE
35            ["Modality", "CT"],
36            ["Rows", "512"],
37            ["Columns", "512"],
38            ["Bits Stored", "16"],
39            ["Bits Allocated", "16"],
40            ["High Bit", "15"],
41            ["Pixel Representation", "1"],
42            ["Manufacturer", "Picker International, Inc."],
43            ["Manufacturer's Model Name", "PQ5000"],
44            ["Pixel Data", "gdcm::NotLoaded. Address:1680 Length:524288 x(80000)"]
45          ] ],
46       ["CT-MONO2-16-ort.dcm",
47          [ ["Transfer Syntax UID", "1.2.840.10008.1.2"],  # Implicit VR, LE
48            ["Modality", "CT"],
49            ["Rows", "512"],
50            ["Columns", "512"],
51            ["Bits Stored", "16"],
52            ["Bits Allocated", "16"],
53            ["High Bit", "15"],
54            ["Pixel Representation", "1"],
55            ["Manufacturer", "GE MEDICAL SYSTEMS"],
56            ["Manufacturer's Model Name", "HiSpeed CT/i"],
57            ["Pixel Data", "gdcm::NotLoaded. Address:1674 Length:524288 x(80000)"]
58                           ] ],
59       ["CT-MONO2-16-ankle.dcm",
60          [ ["Transfer Syntax UID", "1.2.840.10008.1.2"],  # Implicit, little
61            ["Modality", "CT"],
62            ["Rows", "512"],
63            ["Columns", "512"],
64            ["Bits Stored", "16"],
65            ["Bits Allocated", "16"],
66            ["High Bit", "15"],
67            ["Pixel Representation", "1"],
68            ["Manufacturer", "GE MEDICAL SYSTEMS"],
69            ["Manufacturer's Model Name", "GENESIS_ZEUS"],
70            ["Pixel Data", "gdcm::NotLoaded. Address:1148 Length:524288 x(80000)"]
71                           ] ],
72       ["CT-MONO2-8-abdo.dcm",
73          [ ["Transfer Syntax UID", "1.2.840.10008.1.2"],  # Implicit, little
74            ["Modality", "CT"],
75            ["Rows", "512"],
76            ["Columns", "512"],
77            ["Bits Stored", "8"],
78            ["Bits Allocated", "8"],
79            ["High Bit", "7"],
80            ["Pixel Representation", "0"],
81            ["Manufacturer", "FUJI"],
82            ["Pixel Data", "gdcm::NotLoaded. Address:796 Length:262144 x(40000)"]
83                           ] ],
84       ["CT-MONO2-12-lomb-an2.acr",
85          [ ["Modality", "CT"],
86            #"Transfer Syntax UID" and "Photometric Interpretation" are absent.
87            ["Rows", "512"],
88            ["Columns", "512"],
89            ["Bits Stored", "12"],
90            ["Bits Allocated", "16"],
91            ["High Bit", "11"],
92            ["Pixel Representation", "0"],
93            ["Manufacturer", "SIEMENS"],
94            ["Pixel Data", "gdcm::NotLoaded. Address:1230 Length:524288 x(80000)"]
95                           ] ],
96       ["CT-MONO2-16-chest.dcm",
97          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.4.70"], # jpeg...
98            ["Modality", "CT"],
99            ["Photometric Interpretation", "MONOCHROME2"],
100            ["Rows", "400"],
101            ["Columns", "512"],
102            ["Bits Stored", "16"],
103            ["Bits Allocated", "16"],
104            ["High Bit", "15"],
105            ["Pixel Representation", "1"],
106            ["Manufacturer", "GE MEDICAL SYSTEMS"],
107            ["Pixel Data", "gdcm::NotLoaded. Address:1638 Length:143498 x(2308a)"]
108                           ] ],
109       ####################################
110       ### MR modality examples:
111       ####################################
112       ["MR-MONO2-12-angio-an1.acr",
113          [ ["Recognition Code (RET)", "ACR-NEMA 1.0"],
114            ["Modality", "MR"],
115            #"Transfer Syntax UID" and "Photometric Interpretation" are absent.
116            ["Rows", "256"],
117            ["Columns", "256"],
118            ["Bits Stored", "12"],
119            ["Bits Allocated", "12"],
120            ["High Bit", "11"],
121            ["Pixel Representation", "0"],
122            ["Manufacturer", "Philips"],
123            # Note: 256*256*12/8 = 98304
124            ["Pixel Data", "gdcm::NotLoaded. Address:650 Length:98304 x(18000)"]
125                           ] ],
126       ["MR-MONO2-12-an2.acr",
127          [ ["Modality", "MR"],
128            ["Photometric Interpretation", "MONOCHROME2"],
129            ["Rows", "256"],
130            ["Columns", "256"],
131            ["Bits Stored", "12"],
132            ["Bits Allocated", "16"],
133            ["High Bit", "11"],
134            ["Pixel Representation", "0"],
135            ["Manufacturer", "SIEMENS"],
136            ["Manufacturer's Model Name", "MAGNETOM VISION"],
137            ["Pixel Data", "gdcm::NotLoaded. Address:1866 Length:131072 x(20000)"]
138                           ] ],
139       ["MR-MONO2-16-head.dcm",
140          [ ["Transfer Syntax UID", "1.2.840.10008.1.2"], # Imp VR, LE
141            ["Modality", "MR"],
142            ["Photometric Interpretation", "MONOCHROME2"],
143            ["Rows", "256"],
144            ["Columns", "256"],
145            ["Bits Stored", "16"],
146            ["Bits Allocated", "16"],
147            ["High Bit", "15"],
148            ["Pixel Representation", "1"],
149            ["Manufacturer", "GE MEDICAL SYSTEMS"],
150            ["Manufacturer's Model Name", "GENESIS_SIGNA"],
151            ["Pixel Data", "gdcm::NotLoaded. Address:1804 Length:131072 x(20000)"]
152                           ] ],
153       # MR-MONO2-12-shoulder example is present in the Jpeg section.
154       # MR-MONO2-16-knee is not present in the test suite since it is too
155       #    closely related to MR-MONO2-16-head.dcm to be of interest.
156       ####################################
157       # OT modality examples:
158       ####################################
159       # OT-MONO2-8-hip is not present in the test suite since it is too
160       #    closely related to OT-MONO2-8-a7 to be of interest.
161       ["OT-PAL-8-face.dcm",
162          # Interest: has a color palette
163          [#"Transfer Syntax UID", and "Manufacturer" are absent.
164            ["Modality", "OT"],
165            ["Photometric Interpretation", "PALETTE COLOR"],
166            ["Rows", "480"],
167            ["Columns", "640"],
168            ["Bits Stored", "8"],
169            ["Bits Allocated", "8"],
170            ["High Bit", "7"],
171            ["Pixel Representation", "0"],
172            ["Pixel Data", "gdcm::NotLoaded. Address:1654 Length:307200 x(4b000)"]
173                           ] ],
174       # OT-MONO2-8-colon is not present in the test suite since it is too
175       #    closely related to OT-MONO2-8-a7 to be of interest.
176       ["OT-MONO2-8-a7.dcm",
177          [#"Transfer Syntax UID" is absent.
178            ["Modality", "OT"],
179            ["Photometric Interpretation", "MONOCHROME2"],
180            ["Rows", "512"],
181            ["Columns", "512"],
182            ["Bits Stored", "8"],
183            ["Bits Allocated", "8"],
184            ["High Bit", "7"],
185            ["Pixel Representation", "0"],
186            ["Manufacturer", "Philips Medical Systems"],
187            ["Pixel Data", "gdcm::NotLoaded. Address:438 Length:262144 x(40000)"]
188                           ] ],
189       ####################################
190       # US (Ultra Sound) modality examples:
191       ####################################
192       ["US-RGB-8-esopecho.dcm",
193          # Interest: RGB image
194          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"],  # Exp VR, LE
195            ["Modality", "US"],
196            ["Photometric Interpretation", "RGB"],
197            ["Rows", "120"],
198            ["Columns", "256"],
199            ["Bits Stored", "8"],
200            ["Bits Allocated", "8"],
201            ["High Bit", "7"],
202            ["Pixel Representation", "0"],
203            ["Manufacturer", "Acme Products"],
204          # FIXME: 92160 / (120*256) = 3 bytes per pixel NOT 1. Maybe
205          # it has something to do with [Samples Per Pixel] = [3] ???
206          # You said it, puffy (tu l'as dit, bouffi, in french language)
207          # RGB is 3 bytes per pixel
208          # + Planar configuration (0028,0006) = 0 --> Pixels RGB       
209            ["Pixel Data", "gdcm::NotLoaded. Address:904 Length:92160 x(16800)"]
210                           ] ],
211       ["US-RGB-8-epicard.dcm",
212          # Interest: Big endian transfert syntax
213          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.2"],  # Big endian
214          # But ... group 0000 is LE .
215            ["Modality", "US"],
216            ["Photometric Interpretation", "RGB"],
217            ["Rows", "480"],
218            ["Columns", "640"],
219            ["Bits Stored", "8"],
220            ["Bits Allocated", "8"],
221            ["High Bit", "7"],
222            ["Pixel Representation", "0"],
223            ["Manufacturer", "G.E. Medical Systems"],
224            ["Manufacturer's Model Name", "LOGIQ 700"],
225          # + Planar configuration (0028,0006) = 1 --> Plane R, Plane G, Plane B  
226            ["Implementation Version Name", "OFFIS-DCMTK-311"],
227            ["Pixel Data", "gdcm::NotLoaded. Address:1012 Length:921600 x(e1000)"]
228                           ] ],
229    ]
230
231    MultiFrameFiles = [
232    # The number of images is contained in the "Number of Frames" element
233       ["MR-MONO2-8-16x-heart.dcm",
234          # Interest: multi-frame
235          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"], # ExpVR, LE
236            ["Number of Frames", "16"],
237            ["Modality", "MR"],
238            ["Photometric Interpretation", "MONOCHROME2"],
239            ["Rows", "256"],
240            ["Columns", "256"],
241            ["Bits Stored", "8"],
242            ["Bits Allocated", "8"],
243            ["High Bit", "7"],
244            ["Pixel Representation", "0"],
245            ["Manufacturer", "Philips"],
246            # Note: 256*256*16=1048576 (16 is the number of Frames) 
247            ["Pixel Data", "gdcm::NotLoaded. Address:920 Length:1048576 x(100000)"]
248                           ] ],
249       ["NM-MONO2-16-13x-heart.dcm",
250          # Interest: NM modality, multi-frame
251          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"], # ExpVR, LE
252            ["Number of Frames", "13"],
253            ["Modality", "NM"],
254            ["Photometric Interpretation", "MONOCHROME2"],
255            ["Rows", "64"],
256            ["Columns", "64"],
257            ["Bits Stored", "16"],
258            ["Bits Allocated", "16"],
259            ["High Bit", "15"],
260            ["Pixel Representation", "0"],
261            ["Manufacturer", "ACME Products"],
262            # Note: 64*64*13*2=106496
263            ["Pixel Data", "gdcm::NotLoaded. Address:1234 Length:106496 x(1a000)"]
264                           ] ],
265       ["US-MONO2-8-8x-execho.dcm",
266          # Interest: multi-frame
267          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"], # ExpVR, LE
268            ["Number of Frames", "8"],
269            ["Modality", "US"],
270            ["Photometric Interpretation", "MONOCHROME2"],
271            ["Rows", "120"],
272            ["Columns", "128"],
273            ["Bits Stored", "8"],
274            ["Bits Allocated", "8"],
275            ["High Bit", "7"],
276            ["Pixel Representation", "0"],
277            ["Manufacturer", "Acme Products"],
278            ["Pixel Data", "gdcm::NotLoaded. Address:976 Length:122880 x(1e000)"]
279                           ] ],
280       ["US-PAL-8-10x-echo.dcm",
281          # Interest: RLE (Run Length Encoded) compression, multiframe
282          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.5"], # RLE
283            ["Number of Frames", "10"],
284            ["Modality", "US"],
285            ["Photometric Interpretation", "PALETTE COLOR"],
286            ["Rows", "430"],
287            ["Columns", "600"],
288            ["Bits Stored", "8"],
289            ["Bits Allocated", "8"],
290            ["High Bit", "7"],
291            ["Pixel Representation", "0"],
292            ["Manufacturer", "ACME Products"],
293            ["Pixel Data", "gdcm::NotLoaded. Address:2428 Length:481182 x(7579e)"]
294                           ] ],
295       ["XA-MONO2-8-12x-catheter.dcm",
296          # Interest: XA modality, multi-frame
297          [ #["Transfer Syntax UID", "1.2.840.10008.1.2.4.70"], # jpeg
298            ["Number of Frames", "12"],  # 12 images
299            ["Modality", "XA"],
300            ["Photometric Interpretation", "MONOCHROME2"],
301            ["Rows", "512"],
302            ["Columns", "512"],
303            ["Bits Stored", "8"],
304            ["Bits Allocated", "8"],
305            ["High Bit", "7"],
306            ["Pixel Representation", "0"],
307            ["Manufacturer", "Acme Products"],
308            ["Pixel Data", "gdcm::NotLoaded. Address:1006 Length:920072 x(e0a08)"]
309                           ] ],
310    ]
311
312    GdcmFiles = [
313       ["gdcm-MR-SIEMENS-16-1.acr",
314          # Interest: good old Acr-Nema Version 1, see also Oddities below
315          [ ["Recognition Code (RET)", "ACR-NEMA 1.0"],
316            ["Modality", "MR"],
317            ["Rows", "256"],
318            ["Columns", "256"],
319            ["Bits Stored", "12"],
320            ["Bits Allocated", "16"],
321            ["High Bit", "11"],
322            ["Pixel Representation", "0"],
323            ["Manufacturer", "SIEMENS"],
324            ["Manufacturer's Model Name", "GBS III"],
325          # FIXME: this image looks padded at the end. The length of the file
326          # is 140288. Notice that, 256*256*2 + 1024 = 131072 + 1024 = 132096
327            ["Pixel Data", "gdcm::NotLoaded. Address:8192 Length:132096 x(20400)"],
328            # Oddities: "Study ID" and "Series Number" are empty
329            ["Study ID", ""],
330            ["Series Number", ""] ] ],
331            # Oddities: "Study" and "Serie Instance UID" are not present
332       ["gdcm-MR-SIEMENS-16-2.acr",
333          # Interest: Acr-Nema Version 2
334          [ ["Recognition Code (RET)", "ACR-NEMA 2.0"],
335            ["Modality", "MR"],
336            ["Rows", "512"],
337            ["Columns", "512"],
338            ["Bits Stored", "12"],
339            ["Bits Allocated", "16"],
340            ["High Bit", "11"],
341            ["Pixel Representation", "0"],
342            ["Manufacturer", "SIEMENS"],
343            ["Manufacturer's Model Name", "MAGNETOM VISION"],
344            ["Study Instance UID",
345             "1.3.12.2.1107.5.2.4.7630.20000918174641000"],
346            ["Study ID", "1"],
347            ["Series Instance UID",
348             "1.3.12.2.1107.5.2.4.7630.20000918175714000007"],
349            ["Series Number", "7"],
350            ["Pixel Data", "gdcm::NotLoaded. Address:6052 Length:524288 x(80000)"]
351                           ] ],
352       ["gdcm-US-ALOKA-16.dcm",
353          # Interest: - possesses 3 LUTS: a Green (checked), a Red and BLue.
354          #           - announced as implicit VR, but really explicit VR.
355          [ ["Transfer Syntax UID", "1.2.840.10008.1.2"],  # Implicit VR, LE
356            ["Modality", "US"],
357            ["Photometric Interpretation", "PALETTE COLOR"],
358            ["Segmented Green Palette Color Lookup Table Data",
359             "gdcm::NotLoaded. Address:89576 Length:113784 x(1bc78)"],
360            ["Rows", "480"],
361            ["Columns", "640"],
362            ["Bits Stored", "16"],
363            ["Bits Allocated", "16"],
364            ["High Bit", "15"],
365            ["Pixel Representation", "0"],
366            ["Manufacturer", "ALOKA CO., LTD."],
367            ["Manufacturer's Model Name", "SSD-4000"],
368            ["Pixel Data", "gdcm::NotLoaded. Address:258740 Length:614400 x(96000)"]
369                           ] ],
370       ["gdcm-MR-PHILIPS-16.dcm",
371          # Interest: - possesses a sequence
372          #           - dicom file, with a recognition code of ACR-NEMA1
373          [ ["Transfer Syntax UID", "1.2.840.10008.1.2"],  # Implicit VR, LE
374            ["Recognition Code (RET)", "ACR-NEMA 1.0"],
375            ["Modality", "MR"],
376            ["Photometric Interpretation", "MONOCHROME2"],
377            ["Rows", "256"],
378            ["Columns", "256"],
379            ["Bits Stored", "8"],
380            ["Bits Allocated", "16"],
381            ["High Bit", "7"],
382            ["Pixel Representation", "0"],
383            ["Manufacturer", "Philips Medical Systems"],
384            ["Manufacturer's Model Name", "Gyroscan Intera"],
385            ["Sequence Variant", "OTHER"],
386            ["Pixel Data", "gdcm::NotLoaded. Address:6584 Length:131072 x(20000)"]
387                           ] ],
388       ["gdcm-MR-PHILIPS-16-Multi-Seq.dcm",
389          # Interest: - possesses many sequences in group 0x0029
390          #           - Big sequence 28808 bytes at (0x0029, 0x263d)
391          #           - dicom file, with a recognition code of ACR-NEMA1
392          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"],
393            ["Recognition Code (RET)", "ACR-NEMA 1.0"],
394            ["Modality", "MR"],
395            ["Photometric Interpretation", "MONOCHROME2"],
396            ["Rows", "128"],
397            ["Columns", "128"],
398            ["Bits Stored", "12"],
399            ["Bits Allocated", "16"],
400            ["High Bit", "11"],
401            ["Pixel Representation", "0"],
402            ["Manufacturer", "Philips Medical Systems"],
403            ["Manufacturer's Model Name", "Gyroscan Intera"],
404            ["Sequence Variant", "OTHER"],
405            ["Pixel Data", "gdcm::NotLoaded. Address:35846 Length:32768 x(8000)"]
406                           ] ],
407       ["gdcm-MR-PHILIPS-16-NonRectPix.dcm",
408          # Interest: - pixels are non rectangular
409          #           - private elements are in explicit VR (which is normal)
410          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"],  # Explicit VR, LE
411            ["Modality", "MR"],
412            ["Photometric Interpretation", "MONOCHROME2"],
413            ["Rows", "64"],
414            ["Columns", "160"],
415            ["Bits Stored", "12"],
416            ["Bits Allocated", "16"],
417            ["High Bit", "11"],
418            ["Pixel Representation", "0"],
419            ["Manufacturer", "Philips Medical Systems"],
420            ["Manufacturer's Model Name", "Gyroscan Intera"],
421            ["Pixel Spacing", "0.487416\\0.194966"],
422            ["Pixel Data", "gdcm::NotLoaded. Address:5010 Length:20480 x(5000)"]
423                           ] ],
424       ["gdcm-CR-DCMTK-16-NonSamplePerPix.dcm",
425          # Interest: - Misses the "Samples Per Pixel" element which prevents
426          #             e-film from reading it.
427          #           - Misses the Manufacturer related info
428          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.1"],  # Explicit VR, LE
429            ["Modality", "CR"],
430            ["Photometric Interpretation", "MONOCHROME2"],
431            ["Rows", "750"],
432            ["Columns", "750"],
433            ["Bits Stored", "8"],
434            ["Bits Allocated", "8"],
435            ["High Bit", "7"],
436            ["Pixel Representation", "0"],
437            ["Implementation Version Name", "OFFIS_DCMTK_341"],
438            ["Pixel Data", "gdcm::NotLoaded. Address:740 Length:562500 x(89544)"]
439                           ] ],
440    ]
441
442    GdcmJpegFiles = [
443       ["gdcm-JPEG-Extended.dcm",
444          # Interest: Jpeg compression [Extended (2,4)]
445          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.4.51"],
446            ["Modality", "CT"],
447            ["Photometric Interpretation", "MONOCHROME2"],
448            ["Rows", "512"],
449            ["Columns", "512"],
450            ["Bits Stored", "12"],
451            ["Bits Allocated", "16"],
452            ["High Bit", "11"],
453            ["Pixel Representation", "0"],
454            ["Manufacturer", "SIEMENS"],
455            ["Manufacturer's Model Name", "Volume Zoom"],
456            ["Pixel Data", "gdcm::NotLoaded. Address:2946 Length:192218 x(2eeda)"]
457                           ] ],
458       ["MR-MONO2-12-shoulder.dcm",
459          # Interest: Jpeg compression [Lossless, non-hierar. (14)]
460          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.4.57"],
461            ["Modality", "MR"],
462            ["Photometric Interpretation", "MONOCHROME2"],
463            ["Rows", "1024"],
464            ["Columns", "1024"],
465            ["Bits Stored", "12"],
466            ["Bits Allocated", "16"],
467            ["High Bit", "11"],
468            ["Pixel Representation", "0"],
469            ["Manufacturer", "Philips Medical Systems"],
470            ["Manufacturer's Model Name", "Gyroscan NT"],
471            ["Pixel Data", "gdcm::NotLoaded. Address:1580 Length:718948 x(af864)"]
472                           ] ],
473       ["gdcm-JPEG-LossLess3a.dcm",
474          # Interest: - Jpeg compression [Lossless, hierar., first-order
475          #             pred. 14, Select. Val. 1]
476          #           - contains a sequence [circa (0008,2112)]
477          #           - contains additional data after the pixels ???
478          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.4.70"],
479            ["Modality", "CT"],
480            ["Photometric Interpretation", "MONOCHROME2"],
481            ["Rows", "512"],
482            ["Columns", "512"],
483            ["Bits Stored", "12"],
484            ["Bits Allocated", "16"],
485            ["High Bit", "11"],
486            ["Pixel Representation", "0"],
487            ["Manufacturer", "SIEMENS"],
488            ["Manufacturer's Model Name", "Volume Zoom"] ] ],
489          # FIXME: the pixel data looks like corrupted. As stated by "od -A d -c"
490          #   0002528     à 177 020 \0  O  B \0 \0   ÿ  ÿ   ÿ   ÿ  þ  ÿ \0  à
491          #   0002544    \0  \0  \0 \0  þ  ÿ \0  à 202  ? 003  \0  ÿ  Ø  ÿ  Ã
492          # which we interpret as follows:
493          #   - 2528: (à 177, 020 \0) = (0x7fe0, 0x0010) i.e. Pixel Data tag,
494          #   - 2532: OB i.e. encapsulated encoded Pixel Data,
495          #   - 2534: Two bytes reserved,
496          #   - 2536: ÿ ÿ ÿ ÿ = 0xffffffff i.e. data element length is undefined.
497          #   - 2540: (þ ÿ, \0 à) = (0xfffe, 0xe000) i.e. basic offset table
498          #           item tag
499          #   - 2544: \0 \0 \0 \0 i.e. offset table as length zero, i.e. no
500          #           item value for offset table.
501          #   - 2548: (þ ÿ, \0 à) = (0xfffe, 0xe000) i.e. item tag of first
502          #           fragment of (encoded) pixel data.
503          #   - 2552: 202 ? 003 \0 = 212866 bytes i.e. length of first fragment
504          #           of (encoded) pixel data.
505          # and so the next item tag should be found at the 2556+212866 th
506          # octet i.e. at address 215422. But, as stated by od, we find:
507          #   0215408   E   u Ö 026   Î   É 7 ¬ Ã ¸ ó ¿ ÿ Ù \f °
508          #   0215424   ¶ 016 P   Ñ 002 016
509          # and (\f °, ¶ 016) is NOT an OB item TAG which is required to be
510          # present (at least there should be a sequence delimiter), refer to
511          # PS 3.5-2001 page 50.
512          #
513          # That's right :
514          # at 9ec : ItemTag : fffe,e000
515          # at 9f0 : Basic Offset Table Item Lentgh (??) 0 x(00000000)
516          # at 9f4 : ItemTag : fffe,e000
517          #         at 9f8 : fragment length 212866 x(00033f82)
518          # at 3497e : ItemTag  b00c,0eb6 (should be fffe,e000 or fffe,e0dd):
519  
520       ["gdcm-JPEG-LossLessThoravision.dcm",
521          # Interest: - Jpeg compression [Lossless, hierar., first-order
522          #             pred. 14, Select. Val. 1]
523          #           - encoding is sligthly different from LossLess3a.dcm ???
524          [ ["Transfer Syntax UID", "1.2.840.10008.1.2.4.70"],
525            ["Modality", "CR"],
526            ["Photometric Interpretation", "MONOCHROME2"],
527            ["Rows", "2076"],
528            ["Columns", "1876"],
529            ["Bits Stored", "15"],
530            ["Bits Allocated", "16"],
531            ["High Bit", "14"],
532            ["Pixel Representation", "0"],
533            ["Manufacturer", "Philips Medical Systems"],
534            ["Manufacturer's Model Name", "Cassette Holder Type 9840 500 35201"],
535            ["Pixel Data", "gdcm::NotLoaded. Address:3144 Length:4795668 x(492d14)"]
536                           ] ],
537    ]
538
539    def _BaseTest(self, FileSet):
540       for entry in FileSet:
541          fileName = os.path.join(GDCM_TEST_DATA_PATH, entry[0])
542          reader = gdcmHeader(fileName)
543          assert reader.IsReadable(),\
544                 "File '%s' is not readable by gdcmHeader" % fileName
545
546          valDict = reader.GetEntry()
547          for subEntry in entry[1]:
548             element = subEntry[0]
549             value   = subEntry[1]
550             self.assertEqual(valDict[element], value,
551                              ("Wrong %s for file %s (got %s, shoud be %s)"
552                              % (element,fileName, valDict[element], value)) )
553
554    def testBarre(self):
555       gdcmTestCase._BaseTest(self, gdcmTestCase.BarreFiles)
556
557    def testMultiFram(self):
558       gdcmTestCase._BaseTest(self, gdcmTestCase.MultiFrameFiles)
559
560    def testFiles(self):
561       gdcmTestCase._BaseTest(self, gdcmTestCase.GdcmFiles)
562
563    def testJpeg(self):
564       gdcmTestCase._BaseTest(self, gdcmTestCase.GdcmJpegFiles)
565
566    def ZOBtestWrite(self):
567       import md5
568       SourceFileName = os.path.join(GDCM_TEST_DATA_PATH,
569                                     'gdcm-MR-PHILIPS-16-Multi-Seq.dcm')
570       Source = gdcmFile(SourceFileName);
571       Source.GetImageData()
572       TargetFileName = "junk"
573       Target = Source.WriteDcmImplVR(TargetFileName)
574 #       Sign = 'a1e2abdc2f6abedd86b93c8b88db5203' # new signature (found on Win)
575       Sign = '849e722e004d3bb37b87ab6006509b8f' # new signature without field strip
576       ComputeSign = md5.new(open(TargetFileName).read()).hexdigest()
577       self.assertEqual(ComputeSign, Sign,
578           ("Wrong signature for file %s (got %s, shoud be %s)"
579            % (SourceFileName, ComputeSign, Sign)) )
580       os.unlink(TargetFileName)
581       
582 if __name__ == '__main__':
583    if not GDCM_TEST_DATA_PATH:
584       print "GDCM_TEST_DATA_PATH (internal variable) is not setup properly."
585       print "   This test suite requires that some Dicom reference files be "
586       print "   installed."
587       print "   For further details on installation of gdcmData, please"
588       print "   refer to the developper's section of page "
589       print "       http://www.creatis.insa-lyon.fr/Public/Gdcm"
590       print ""
591       print "gdcmData directory (used in the test suite) must be placed in"
592       print "the gdcm directory. The gdcm tree must be :"
593       print "   gdcm"
594       print "    |____Dicts"
595       print "    |____Doc"
596       print "    |____gdcmData      (not in gdcm by default)"
597       print "    |____gdcmPython"
598       print "    |____Test"
599    else:
600       unittest.main()
601